#第一个程序
# -*- coding: utf-8 -*-
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('T "said" do not touch this.')
print("I love you!")
加分练习
1. 让你的脚本再多打印一行。
加一句print('\n')
2. 让你的脚本只打印一行。
print("Hello World!",end="")
print("Hello Again",end="")
print("I like typing this.",end="")
print("This is fun.",end="")
print("Yay! Printing.",end="")
print("I'd much rather you 'not'.",end="")
print('I "sai" do not touch this.',end="")
3. 在一行的起始位置放一个 ‘#’ (octothorpe) 符号。它的作用是什么?自己研究一下。
#就是注释的意思,所以该行不会被显示
习题2注释和井号
# -*- coding: utf-8 -*-
# A comment,this is so you can read your program later.
#Anything after the # is ignored by python.
print("I could have code like this.")#and the comment after is ignored
# You can also use a comment to "disable" or comment out a piece of code:
#print "This won't run."
print("This will run.")
加分习题
1. 弄清楚”#”符号的作用。而且记住它的名字。(中文为井号,英文为 octothorpe 或者 pound character)。
2. 打开你的 ex2.py 文件,从后往前逐行检查。从最后一行开始,倒着逐个单词单词检查回去。
3. 有没有发现什么错误呢?有的话就改正过来.
4. 朗读你写的习题,把每个字符都读出来。有没有发现更多的错误呢?有的话也一样改正过来。
习题3数学和数据计算
# -*- coding: utf-8 -*-
print("I will now count my chickens:")
print("Hens",25 + 30 / 6)
print("Roosters", 100 - 25 * 3 % 4)
print(4 % 2)
print("Now I will count the eggs:")
print(3 +