Python pycharm learning code text record(3)

五迷三道 提交于 2020-02-14 07:36:30

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

dictionary.字典基础注释

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!