2-1简单消息
message = "hello world!"
print(message)
2-2多条简单消息
message="hello"
print(message)
message="world"
print(message)
2-3个性化消息
name="Eric"
print("Hello "+name+", would you like to learn some Python today?")
2-4调整名字的大小写
name="Alice Green"
print(name.lower())
print(name.upper())
print(name.title())
2-5名言
print('Albert Einstein once said."A person who never made a mistake never tried anything new."')
2-6名言2
name="albert einstein"
message=name.title()+' once said."A person who never made a mistake never tried anything new."'
print(message)
2-7剔除人名中的空白
name=" \n\tAlbert Einstein\n\t"
print("'"+name+"'")
print("'"+name.lstrip()+"'")
print("'"+name.rstrip()+"'")
print("'"+name.strip()+"'")
2-8数字8
print(1+7)
print(10-2)
print(2*4)
print(24/3)
2-9最喜欢的数字
num=18
message="My favorite number is "+str(num)
print(message)
2-10添加程序
#coding=gbk
'''
高级编程基础
chapter2
注释练习
'''
a=3
b=4
#加法
print(a+b)
#减法
print(a-b)
#乘法
print(a*b)
#除法
print(a/b)
#整除
print(int(a/b))
#幂运算
print(a**b)
#取余
print(a%b)
2-11Python之禅
import this