python based learning (c)

5. How to obtain input data from a user

# Input function 
name = the INPUT ( " Please enter your name: " ) 
Age = the INPUT ( " Please enter the Age: " ) 
Print (f ' {Age}-year-old {name}, hello Welcome!! ' )

run results:

 

 6. string

# String String 
# Slash   / slash backslash The \ backslash 
# escape string 

MyStr1 = ' "Song" Ke ' 
MyStr2 = " \" Song \ "\ n-Ke " 
mystr3 = " songKe " 

Print (MyStr1 + " : string concatenation " ) 
Print (MyStr2) 
Print (mystr3 * 3 ) 
Print ( " Ke "  in MyStr2)

run results:

 

 7. String Format

# I used to have a man called Song Ke, his age is 21 years old. 
name = " Song Ke " 
Age = 21 

Massage = " before a man named " + name + " , his age is " + str (Age) + " years old. " 
msg = f " before someone called {name}, he age {age} years old. " 

Print (Massage) 
Print (msg)

run results:

 

 

Guess you like

Origin www.cnblogs.com/songxiaoke/p/11880755.html