[Python] basic grammar exercises Day 2 jobs

"" " 
1, the user enters a value, please determine whether the user input is an even number is even output True, not output False (Tip:? Input whatever input that will be converted into a string, own expansion, will find a way string into a numeric type, then a determination section) 
2, selling oranges calculator: write the code, the user is prompted orange price, and then generates a random number for later (between 5 and 10 kg) pounds, finally calculate ! amount should be paid 
3, there are variables a = ( 'hello', ' python18', '!'), converted by operation related to a string: 'hello python18!' (Note the point: there are spaces between words after conversion ) 
4, and a module using the random string concatenation method, 130 begins with a randomly generated phone number. 
"" " 
Import random
 # first title 
# mode a: 
DEF input_sz (): 
    SZ = iNPUT ( " enter a number: " )
     the try :
         IF int (sz) / 2 =! 0:
             Print ( " True ")
        else:
             Print ( " False " )
     the except Exception AS E: 
        input_sz () 
input_sz () 

# Second way: 
A = INPUT ( " Enter a number: " ) 
B = int (A)
 Print (B% 2 == 0) 

# The second question 
DEF fruit_price (): 
    . price = the iNPUT ( " Please enter the price of fruit: " )
     Print ( " fruit prices: " ,. price) 
    weight = random.randint (5, 10 )
     Print (" Fruit weight: " , weight) 
    total_price = float (. Price) * weight
     Print ( " payment amount: " , total_price) 
fruit_price () 

# The third question 
A = ( ' the Hello ' , ' python18 ' , ' ! ' )
 # Create empty string 
str1 = "  " 
RES = str1.join (A)
 Print (RES) 

# fourth question 
Number The random.randint = (10000000,99999999 ) 
PHONE_NUMBER = "130{}".format(number)
print(Phone_number)

 

Guess you like

Origin www.cnblogs.com/python-test001/p/12336856.html