Python pycharm learning code text record (3)
文章编号:Python学【2020】003号
日期:2020-02-13
customer = {
"name": "Jhon Smith",
"age":30,
"is_verified":True
}
customer["name"]="Jack Smith"
print(customer["name"])
print out
Jack Smith
customer = {
"name": "Jhon Smith",
"age":30,
"is_verified":True
}
customer["birthdate"]=" Jan 1 1980 "
print(customer["birthdate"])
print out
Jan 1 1980
phone = input("phone:")
digits_mapping = {
"1":"one",
"2":"two",
"3":"three",
"4":"four"
}
output = ""
for ch in phone:
output += digits_mapping.get(ch,"!") + ""
print(output)
print out
phone:123
onetwothree
message = input(">")
words = message.split(' ')
print(words)
print out
good morning sunshine
[‘good morning sunshine’]
message = input(">")
words = message.split(' ')
emojis = {
":)":"☺",
":(":"sad"
}
output = ""
for word in words:
output +=emojis.get(word,word) + ""
print(output)
print out
😦
sad
def greet_user():
print("Hi there! ")
print("Welcome aboard ")
print("Start ")
greet_user()
print("Finish ")
==print out
Start
Hi there!
Welcome aboard
Finish ==
def greet_user(name):
name = "Jhon"
print(f'Hi {name}! ')
print("Welcome aboard ")
print("Start ")
greet_user(" ")
print("Finish ")
Start
Hi Jhon!
Welcome aboard
Finish
def greet_user(name):
print(f'Hi {name}! ')
print("Welcome aboard ")
print("Start ")
greet_user("Jhon" )
greet_user("Mike")
print("Finish ")
Start
Hi Jhon!
Welcome aboard
Hi Mike!
Welcome aboard
Finish
def greet_user(first_name, last_name):
print(f'Hi {first_name} {last_name}! ')
print("Welcome aboard ")
print("Start ")
greet_user("Jhon","Mike" )
print("Finish ")
Start
Hi Jhon Mike!
Welcome aboard
Finish
def greet_user(first_name, last_name):
print(f'Hi {first_name} {last_name}! ')
print("Welcome aboard ")
print("Start ")
greet_user(last_name= "Jhon",first_name="Mike" )
print("Finish ")
Start
Hi Mike Jhon!
Welcome aboard
Finish
02:00-02:45
来源:CSDN
作者:Gake.W
链接:https://blog.csdn.net/GakeWang/article/details/104300584