Skip to content
python
message = "Hello Python world!"
print(message)
Hello Python world!
python
# 2.1
message = "xixixi"
print(message)
xixixi
python
# 2.2
m2 = "lalala"
print(m2)
m2 = "hahaha"
print(m2)
lalala
hahaha
python
name = "ada lovelace"
print(name.title())
print(name.upper())
print(name.lower())
Ada Lovelace
ADA LOVELACE
ada lovelace
python
first_name = "ada"
last_name = "lovelace"
full_name = f"{first_name} {last_name}"
print(full_name)
print(f"Hello, {full_name.title()}!")
ada lovelace
Hello, Ada Lovelace!
python
favorite_language = '  python  '
print(favorite_language.rstrip())
print(favorite_language.lstrip())
print(favorite_language.strip())
  python
python  
python
python
nostarch_url = 'https://nostarch.com'
simple_url = nostarch_url.removeprefix('https://')
print(nostarch_url)
print(simple_url)
https://nostarch.com
nostarch.com
python
# 2.3
name = "eric"
message = f"Hello {name.title()}, would you like to learn some Python today?"
print(message)
Hello Eric, would you like to learn some Python today?
python
# 2.4
name = "justin bieber"
print(name.lower())
print(name.upper())
print(name.title())
justin bieber
JUSTIN BIEBER
Justin Bieber
python
# 2.5
name = "albert einstein"
talk = "A person who never made a mistake never tried anything new."
full = f'{name.title()} once said, "{talk}"'
print(full)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
python
# 2.6
famous_person = "albert einstein"
message = f'{famous_person.title()} once said, "A person who never made a mistake never tried anything new."'
print(message)
Albert Einstein once said, "A person who never made a mistake never tried anything new."
python
# 2.7
name = "\t\t  selena gomez  \n\t"
print('1.--' + name + '--')
print('2.--' + name.lstrip() + '--')
print('3.--' + name.rstrip() + '--')
print('4.--' + name.strip().title() + '--')
1.--		  selena gomez  
	--
2.--selena gomez  
	--
3.--		  selena gomez--
4.--Selena Gomez--
python
# 2.8
filename = 'python_notes.txt'
print(filename)
print(filename.removesuffix('.txt'))
python_notes.txt
python_notes
python
# 2.9
print(5+3)
print(9-1)
print(2*4)
print(16//2)
8
8
8
8
python
# 2.10
number = 36
print('the number is ' + str(number))
the number is 36
python
# 2.11
# 啦啦啦
print('lalala')
lalala
python
import this
The Zen of Python, by Tim Peters

Beautiful is better than ugly.
Explicit is better than implicit.
Simple is better than complex.
Complex is better than complicated.
Flat is better than nested.
Sparse is better than dense.
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!