print('hello')
# result
>>> hello
age = 1
name = " Li Bai "
school = " Shenyang Institute of technology "
print(name, age, school) # Separated by commas
# result
>>> Li Bai 1 Shenyang Institute of technology
name = input(" Please enter a name :") # The words in parentheses are reminders
print(name)
# result
>>> Please enter a name : Li Bai
>>> Li Bai
Common data types are numbers 、 list 、 character string 、 Dictionaries 、 Tuples 、 aggregate .
heroList = [' Ruban 7 ', " Angela ", " Li Bai ", ' Hou Yi ', 100, 10.1]
print(heroList)
# result
>>> [' Ruban 7 ', ' Angela ', ' Li Bai ', ' Hou Yi ', 100, 10.1]
print(" Hero for :",heroList[1],heroList[0])
# result
>>> Hero for : Angela Ruban 7
heroList.append(' Ruban master ')
print(' List after adding ', heroList)
# result
>>> List after adding [' Ruban 7 ', ' Angela ', ' Li Bai ', ' Hou Yi ', 100, 10.1, ' Ruban master ']
heroList[4] = " The sable cicada "
print(" Modified list ", heroList)
# result
>>> Modified list [' Ruban 7 ', ' Angela ', ' Li Bai ', ' Hou Yi ', ' The sable cicada ', 10.1, ' Ruban master ']
del heroList[5]
print(" Deleted list ", heroList)
# result
>>> Deleted list [' Ruban 7 ', ' Angela ', ' Li Bai ', ' Hou Yi ', ' The sable cicada ', ' Ruban master ']
age = input(' Please enter your age :') # Enter the age
print(type(age)) # Determine the type of variable is type function
age = int(age) # Convert to numeric type int
print(type(age))
if age >= 18: # Judge the condition
print(" Congratulations on your adulthood , You can go to the Internet bar ")
else:
print('sorry, You're still a baby ')
# Older than or equal to 18, result
Please enter your age :18
<class 'str'>
<class 'int'>
Congratulations on your adulthood , You can go to the Internet bar
# Older than 18, result
Please enter your age :3
<class 'str'>
<class 'int'>
sorry, You're still a baby