1 getpass module setting password does not display clear text
User name and Password entry program:
Import getpassusername = input ("username:") password = getpass.getpass ("Password:") print (Username,password)
Determine login
_username = "JJ" _password = ' 123456 ' username = input ("username:") password = getpass.getpass ("Password:") if _username = = u Sername and _password==password: print (' Welcome login.. ') else: print (' Invalid username or password ')
Guess Age:
AGE_JJ = 35guess_age = Int (input (' Guess Age: ')) if guess_age = = Age_jj: print (' YES ') elif guess_age > AGE_JJ: pr Int (' think smaller.. ') else: print ("Think Bogger..")
Guess 3 times to guess the right to quit, the number of errors reached 3 times also exited
While
The while conditional loop statement is executed if it is submitted as true
AGE_JJ = 35count = 0while count< 3: guess_age = int (input (' Guess Age: ')) if guess_age = = Age_jj: print (' YE S ') break elif guess_age > AGE_JJ: print (' think smaller.. ') else: print ("Think Bogger..") Count + = 1
AGE_JJ = 35count = 0while count< 3: guess_age = int (input (' Guess Age: ')) if guess_age = = Age_jj: print (' YE S ') break elif guess_age > AGE_JJ: print (' think smaller.. ') else: print ("Think Bogger..") Count + = 1else: print (' You have tried too many times ... fuck you ... ')
While Else "
If the while condition is true, execute the code in the while
Executes the code inside the else if the condition of the while is false
For
There are two types of python for loops:
1 generates an integer sequence using the range () function.
Print (type range)) for I in range: print (i)
This sequence can be turned into a list
Print (List (range (10)))
2 for: In the loop list, iterating through the elements of the list in turn
names=[' Michael ', ' Bob ', ' Tracy ']for name in Names: print (name)
Python if Else while