Python 7 Levels, L1, Unit 2, print

Powered By EmbedPress

Exercise 1:

print("\tFrench\tMath\tEnglish\tComputer")
print("Luk\t92\t89\t80\t100")
print("Aaron\t80\t85\t99\t99")
print("Jaydon\t82\t89\t93\t95")

Exercise 2:

print(“Sun.\tMon.\tTue.\tWed.\tThu.\tFri.\tSat.”)
print(“\t\t\t\t\t1\t2”)
print(“3\t4\t5\t6\t7\t8\t9”)
print(“10\t11\t12\t13\t14\t15\t16”)
print(“17\t18\t19\t20\t21\t22\t23”)
print(“24\t25\t26\t27\t28\t29\t30”)

GuessNumber:

import random #Introduce random number module
print("---------------------Guess the number game-------------------- ---")
print("---------Please guess a random number range (1~49) generated by the computer----------")
answer = random.randint(1,49)#The system generates random numbers and saves them in the answer variable
n = int(input("Please enter a number (1~49)"))#Save the number entered by the user into the n variable
while n != answer:#Enter the while loop if the condition is true, jump out of the loop if the condition is not true
    if(n > answer):#If the number in n > the number in answer
        print("The number you entered is too large")
        n = int(input("Please re-enter"))
    else:#Otherwise the number in n < the number in answer
        print("The number you entered is too small")
        n = int(input("Please re-enter"))
print("Congratulations, you guessed correctly, the random number generated by the computer is %d"%n)#Execute this program when the while loop ends

dahan1999

1 Comment

Leave a Reply

Your email address will not be published. Required fields are marked *

Related Posts