Variables and memory and input-output relations

The relationship between the variables memory, input and output practice

0, respectively, to draw the following two lists in memory of how to store

l1=[11,22,[333,444]]
l2=[11,22,[33,{'name':'egon','age':18}]]

1, the user enters the name, age, work, hobbies, and then printed in the following format

# 1, the user enters the name, age, work, hobbies, and then printed in the following format 
# ------------ ----------- info of Egon 
# the Name: Egon 
# Age: 22 
# Sex: MALE 
# the Job: Teacher 
# ------------- End ----------------- 
name = the iNPUT ( " Please enter your name: " )
Age = the INPUT ( " Please enter your age: " )
Sex = the INPUT ( " Please enter your gender: " )
Job = INPUT ( " Please enter your Occupation: " )
 Print (F " info of {name} " .center (37 [, " - " ),
 '' '
Name : {name}
Age  : {age}
Sex  : {sex}
Job  : {job}
'' ' .Format (name = name, Age = Age, Sex = Sex, Job = Job), " End " .center (37 [, " - " ))
 # Center () Returns a string of the original center, and spaces filled to the new string length of width. The default pad character is a space. 
# Str.center (width, FillChar) Parameters: width - the total width of the string. fillchar - filled characters.


# 2, enter the user account password, the program individually to determine whether the correct account number and password, the correct output True, False error output to
the INPUT = username ( " Please enter account: " )
password = the INPUT ( " Please enter your password: " )
user_data = {"Jil":1118}
if username in user_data:
    if password == user_data.get(username):
        print(True)
    else:
        print(False)
else:
    print(False)


3、让计算机提前记下egon的年龄为18岁,写一个才年龄的程序,要求用户输入所猜的年龄
,然后程序拿到用户输入的年龄与egon的年龄比较,输出比较结果即可
age_of_egon = 18
age_guess = input("请输入您猜的年龄:")
if age_guess == age_of_egon:
    print("猜对!")
else:
    print("猜错!")

 





4、程序从数据库中取出来10000条数据,打算显示到页面中,
但一个页面最多显示30条数据,请选取合适的算数运算符,计算
显示满30条数据的页面总共有多少个?
最后一页显示几条数据?
full_page = 10000 // 30
print("显示满30条的页面共有:{}页,最后一页显示{}条数据".format(full_page,10000%30))
 
5、egon 今年为 18 岁,请用增量赋值计算 3 年后 egon 老师的年龄

age_of_egon += 3
print(f"三年后egon老师{age_of_egon}岁")

6、将值10一次性赋值给变量名x、y、z
x = y = z = 10

7、请将下面的值关联到它应该对应的变量名上,你懂的
dsb = "egon"
superman = "alex"

dsb,superman = superman,dsb
8、我们只需要将列表中的傻逼解压出来,一次性赋值给对应的变量名即可
names=['alex_sb','wusir_sb','oldboy_sb','egon_nb','lxx_nb','tank_nb']

alex,wusir,oldboy,egon,lxx,tank = names
print(alex,wusir,oldboy,egon,lxx,tank )

 

Guess you like

Origin www.cnblogs.com/zhubincheng/p/12421552.html