2.1 变量
"""简单输出"""
print("hello python world!")
"""简单变量"""
message = "hello world!"
print(message)
2.2 字符串
"""使用方法修改字符串大小写"""
name = "ada lovelace"
print(name.title())
print(name.upper())
print(name.lower())
"""合并字符串"""
first_name = "ada"
last_name = "lovelace"
full_name = first_name + " " + last_name
print(full_name)
print("hello, " + full_name.title() + "!")
message = "hello, " + full_name.title() + "!"
print(message)
"""使用制表符或换行符来添加空白"""
print("languages:\n\tpython\n\tC\n\tjavascript")
"""删除额外空白"""
language = 'python '
language.rstrip()
language = language.rstrip()
"""注意单引号和双引号的区别,如果单引号内的字符串出现一撇即“ ’ ”,则系统会认为该撇之前的为字符串,之后的为代码"""
2.3 数字
2 + 3
3 - 2
2 * 3
3 / 2
3 ** 2
>>>0.2 + 0.1
0.300000000004
"""
age = 23
message = "Happy" + age + "rd Birthday!"
print(message)
"""
age = 23
message = "Happy " + str(age) + "rd Birthday!"
print(message)