这是所有的语言
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 )
#一些输出
my_name = 'Zed A. Shaw'
my_age = 35# not a lie
my_Height = 163#CM
cm_feet = ( my_Height ) / 30.48
print ( cm_feet )#这是一些实验
my_weight = 53#KG
kg_pound = 0.4535923 * ( my_weight )
print ( kg_pound )#这是一些实验
my_eyes = 'black'
my_hair = 'black'#我是中国人,这是一些输入
print (f"Let's talk about {my_name}.")
#不要忘记f
print (f"He is {my_age} years old.")
print (f"He is {my_weight} kg heavy.")
print (f"He is {kg_pound} pound heavy.")
print ("He is {} pound heavy.".format(kg_pound))#这是一个实验(他成功了)
print (f"Actually , it's not too heavy.")
#以上基于实际数据
types_of_people = 10
x = f"There are {types_of_people} types of people."
binary = " binary "
do_not = " don't "
y = f" Those who know {binary} and those who {do_not}."
print ( x )
print ( y )
print (f"I said :{ x }")
print (f"I also said :'{ y }'")
hilarious = False
#应该是固定格式,F大写
joke_evaluation = "Isn't the joke so funny? {}!"
#应该是使用了format函数,我承认我不大了解
print (joke_evaluation.format(hilarious))
w = "This is the left side of..."
e = "a string with a right side."
print ( w + e )
print ("Mary had a little lamb.")
print ("It's fleece was wite as {}.".format('snow'))
print ("And everywhere that Mary went.")
print ("." * 10)
#what'd that do?
end1 = "C"
end2 = "h"
end3 = "e"
end4 = "e"
end5 = "s"
end6 = "e"
end7 = "B"
end8 = "u"
end9 = "r"
end10 = "g"
end11 = "e"
end12 = "r"
print (end1 + end2 + end3 + end4 + end5 + end6, end = ' ')#另外一种输入,可以输入空格
print (end7 + end8 + end9 + end10 + end11 + end12 )
formatter = "{} {} {} {} "#这是一个定义字符串的过程,是一个固定搭配
print(formatter.format(1, 2, 3, 4))
print(formatter.format("one", "two", "three", "four"))
print(formatter.format(True, False, True, False))
print(formatter.format(formatter,formatter, formatter,formatter))
print(formatter.format(
"Try your",
"Own text here",
"Maybe a poem",
"Or a song about fear"
))#formatter.format()是一个给字符串赋值的过程
# Here's some new strange stuff, remember type it exactly.
days = "Mon Tue Wed Thu Fri Sat Sun"
months = "\nJan\nFeb\nMar\nApr\nMay\nJun\nJul\nAug"
#换行字符(new line character)
#三个双引号是用来换行的
print("Here are the days: ", days)
print("Here are the months: ", months)
print("""
There's something going on here.
With the three double-quotes.
We will be able to type as much as we like.
Even 4 lines if we whant , or 5, or 6.
""")
#三个双引号也是用来换行的,也可以用'''
tabby_cat = "\tI'm tabbed in."
persian_cat = "I'm split\non a line."
backslash_cat = "I'm \\a\\cat."
fat_cat = """
I'll do a list:
\t* cat food
\t* Fishies
\t* Catnip\n\t* Grass
"""
#转义字符(escape sequence)
print(tabby_cat)
print(persian_cat)
print(backslash_cat)
print(fat_cat)
#以上都是输出的内容,下面会做一些输入
print("How old are you?", end=' ')
age = input()
print("How tall are you?", end=' ')
print("要记得单位是cm哦!")
print("这里只能输入一个小数。")
height = int(float(input()))#这里输入的是一个小数,可以加一个if语句。
print("How much do you weight?", end=' ')
print("要记得单位是kg哦!")
print("这里只能输入一个小数。")
weight = int(float(input()))
#int()给输入的数字取整。float表示输入的是一个小数。
print(f"So,you are {age} years old, {height} cm tall and {weight} kg heavy.")
#下面是另一种写法。
age1 = input("How old are you?")
height1 = int(float(input("\nHow tall are you?\n要记得单位是cm哦!\n这里只能输入一个小数。")))
weight1 = int(float(input("\nHow much do you weight?\n要记得单位是kg哦!\n这里只能输入一个小数。")))
print(f"So,you are {age1} years old, {height1} cm tall and {weight1} kg heavy.")
# python -m pydoc -w ex1这个可以输出一个exe文件,和一个html文件(可以按A-Z整理出所有的变量)
这是所有的运行结果
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
5.347769028871391
24.0403919
Let's talk about Zed A. Shaw.
He is 35 years old.
He is 53 kg heavy.
He is 24.0403919 pound heavy.
He is 24.0403919 pound heavy.
Actually , it's not too heavy.
There are 10 types of people.
Those who know binary and those who don't .
I said :There are 10 types of people.
I also said :' Those who know binary and those who don't .'
Isn't the joke so funny? False!
This is the left side of...a string with a right side.
Mary had a little lamb.
It's fleece was wite as snow.
And everywhere that Mary went.
..........
Cheese Burger
1 2 3 4
one two three four
True False True False
{} {} {} {} {} {} {} {} {} {} {} {} {} {} {} {}
Try your Own text here Maybe a poem Or a song about fear
Here are the days: Mon Tue Wed Thu Fri Sat Sun
Here are the months:
Jan
Feb
Mar
Apr
May
Jun
Jul
Aug
There's something going on here.
With the three double-quotes.
We will be able to type as much as we like.
Even 4 lines if we whant , or 5, or 6.
I'm tabbed in.
I'm split
on a line.
I'm \a\cat.
I'll do a list:
* cat food
* Fishies
* Catnip
* Grass
How old are you? 21
How tall are you? 要记得单位是cm哦!
这里只能输入一个小数。
163.3
How much do you weight? 要记得单位是kg哦!
这里只能输入一个小数。
53.3
So,you are 21 years old, 163 cm tall and 53 kg heavy.
How old are you?21
How tall are you?
要记得单位是cm哦!
这里只能输入一个小数。163.7
How much do you weight?
要记得单位是kg哦!
这里只能输入一个小数。53.7
So,you are 21 years old, 163 cm tall and 53 kg heavy.
PS C:\Users\HH\lpthw>