第二天的代码——尝试一些简单的运算
代码
print ("Hello world!")
print ("Hello again")
print ("I like typing this.")
print ("This is fun.")
print ("Yay!Printing.")
print ("I'd much rather you 'not'.")
print ('I "said" do not touch this.')
# Anything after the # is ingnord by python.octothorpe.
print ("now I will count my chickens.")
print ("Hens",20+30/6)
print ("Roosters",100-25*3%5)
print ("now I will count my eggs.")
print (3 + 2 + 1 - 5 + 4 % 2 - 1 / 4 + 6)
print ("IS it ture that 3 + 2 < 5 - 7 ?")
print (3 + 2 < 5 - 7)
print ("oh,that's why it's false.")
print ("what is 3 + 2?", 3 + 2)
print ("what is 5 - 7?", 5 - 7)
cars = 100
space_in_a_car = 4.0
drivers = 30
passengers = 90
#定义了四个对象,并赋值
cars_not_driven = cars - drivers
cars_driven = drivers
carpool_capacity = cars_driven * space_in_a_car
average_passengers_per_car = passengers / cars_driven
#一些计算过程
print ( cars )
print ( drivers )
print ( average_passengers_per_car )
#一些输出
结果
PS C:\Users\HH\lpthw> python ex1.py
Hello world!
Hello again
I like typing this.
This is fun.
Yay!Printing.
I'd much rather you 'not'.
I "said" do not touch this.
now I will count my chickens.
Hens 25.0
Roosters 100
now I will count my eggs.
6.75
IS it ture that 3 + 2 < 5 - 7 ?
False
oh,that's why it's false.
what is 3 + 2? 5
what is 5 - 7? -2
100
30
3.0
PS C:\Users\HH\lpthw>
浙公网安备 33010602011771号