Python small practice (b)

# 1, 99 output the multiplication table: 
for I in Range (1,10):
for J in Range (1, I + 1):
Print (. "{} * {} = {: <2}" the format (J, I, I * J), End = "")
Print ()

result:

 

 

 

 

 

# 2, 1234 these four digital design program calculates how many other with no repeat of the 3-digit numbers can be composed? What are they? 
0 = NUM
for A in (1,2,3,4):
for B in (1,2,3,4):
for C in (1,2,3,4):
IF A == B or A = B or C == C =:
Continue
the else:
Print (STR (A) + STR (B) + STR (C))
NUM = +. 1
Print (NUM)

result:

 

 

 

 

 

# 3, by implementing a calculator function, respectively, to run the program prompts the user to enter a number 1, number 2, 
# and then prompts the user to select: 1 plus [Save] [2] by [3] [4] In addition, depending on the selection perform different calculations and returns the result.
counter DEF ():
num1 = int (INPUT ( "Please enter the first digit:"))
num2 = int (INPUT ( "Please enter the second number:"))
Algo = int (INPUT ( "plus [1] Save by [2] [3] [4] In addition "))
Result = 0
IF Algo. 1 ==:
Result = + num1 num2
elif Algo == 2:
Result = num1 - num2
3 elif Algo ==:
Result = num1 * num2
elif Algo ==. 4:
result = num1 / num2
Print (result)
counter ()

result:

 

 

 

 

 

# 4, the implementation process of registering a function, call the function to perform the following required function 
# 1, run the program prompts the user to enter a user name, password, confirm the password again.
# 2, the user name interpretation has not been registered, if the user name is registered, then print the results of that username has already been registered.
# 3, the user name is not registered, it is determined whether the two passwords are identical, if the registration is successful, otherwise give corresponding prompt.
DEF Registered ():
USER_INFO = [{ "User": "User01", "pwd": "123"}, { "User": "named user02", "pwd": "111"}]
USER_NAME = []
for I user_info in:
user_name.append (i [ "the user"])
the while True:
username = the iNPUT ( "Please enter your user name:")
IF username in user_name:
Print ( "the user name is already registered, please re-enter! ")
the else:
the while True:
pwd1 the iNPUT = (" Please enter your password: "


print ( "Enter the password twice inconsistent, please re-enter your password!")
the else:
print ( "Registration successful!")
user_info.append ({ "the User": username, "pwd": pwd2})
BREAK
BREAK
Print (user_info)
registered ()

result:

Guess you like

Origin www.cnblogs.com/Super-Treasure/p/12169318.html
Recommended