Print ("Hello World")
#变量定义: a container for storing data in memory
#意义: Why is there a variable because it saves the intermediate result or state of the program execution to be called at the back of the low?
Day1 = 200+43+22+44+44
Day2 = 100+25+64+98+45+557
Day3 = #数字不需要加引号
Total = Day1+day2+day3
Print ("September revenue:", total) #字符串需要加引号
x = 4
y = 5
C =-(x + Y)
Print ("c's result is:", c)
Name = "alex li"
Age = 18
Print (name,age) #变量先定义后引用
#字符串定义
Age_of_oldboy = #下划线 (python recommended Notation)
Ageofoldboy = #驼峰写法
Age_of_oldboy = #常量, Constant Quantity
#定义变量规则
#不能数字开头, cannot contain special characters such as spaces
#不能使用关键字 (internal syntax) as a variable
Universal encoding = Unicode 4bytes
Utf-16 = 65535
Utf-8 = variable-length Encoding set = utf-8, English by ASCII storage, Chinese save 3 bytes, Europe 2 bytes
Python line comments are # numbers,
Multiline comment is three "' (single Quote)
Three "" "can represent the entire string of paragraphs
################### #代码练习 ####################
#打印信息
Print ("Hello World")
#根据输入进行输出
Name = Input ("name:")
Age = Input ("age:")
Job = input ("jobs:")
Hobby =input ("hobby:")
#print ("my name is", name, "I am", age, "yesrs old,\n",
# "my Job is", job, "my hobby is", Hobby
# )
info = ""
------info of%s------
name:%s
age:%s
job:%s
hobby:%s
------end------
"% (name,name,age,job, Hobby)
Print (info)
#流程判断
Username = input ("usernaame:")
Password = input ("password:")
If username = = "alex" and Password = = "abc123": #如果这个条件满足了
Print ("welecome!") #就执行这个语句
Else: #如果条件不满足 (otherwise)
Print ("error!please Tryagain!!!") #就执行这个
#猜年龄
Oldboy_age = 38
Guess_age =int (input ("age:")) #str--->int
if guess_age = = Oldboy_age:
Print ("you is Right!")
Elif guess_age > Oldboy_age:
Print ("try Small!!")
Else:
Print ("try Biggest!!!")
Python15-day1 Classroom Random