Python BASICS (1): python Basics
1. Dynamic Assignment Method
Name = input ("name :")
Age = int (input ("age :"))
Print (type (age ))
Job = input ("job :")
Info = '''
------ Info of % s ------
Name: % s
Age: % s
Job: % s
''' % (Name, name, age, job)
Info1 = '''
------ Info of {0 }------
Name: {0}
Age: {1}
Job: {2}
'''. Format (name, age, job)
Info2 = '''
------ Info of {_ name }------
Name: {_ name}
Age: {_ age}
Job: {_ job}
'''. Format (_ name = name, _ age = age, _ job = job)
Print (info)
Print (info1)
Print (info2)
2. Enter the verification age
Age_of_oldboy = 56
Count = 0
While count <3:
Guess_age = int (input ("guess age :"))
If guess_age = age_of_oldboy:
Print ("yes, you got it .")
Break
Elif guess_age> age_of_oldboy:
Print ("think smaller ...")
Else:
Print ("think bigger! ")
Count + = 1;
Else:
Print ("you have tried too times... fuck off ")
3. user name and password verification
Import getpass
_ Username = 'iefei'
_ Password = 'xf123'
Username = input ("username :")
Password = input ("password :")
If _ username = username and _ password = password:
Print ("Welcome user {name} login...". format (name = username ))
Else:
Print ("Invalid username or password! ")
Print ("end ")
Print (username, password)
4. for Loop
For I in range (0, 10 ):
If I <5:
Print ("loop", I)
Else:
Continue
Print ("hehe ...")
5. Exercise homework
I. Compile the logon Interface
(1) enter the user name and password
(2) display the welcome information after successful authentication
(3) Lock after three input errors
Ii. Multi-level menu
(1) Level 3 menu-provincial, municipal, and county
(2) You can choose to go to each sub-menu
(3) New knowledge points: List and Dictionary