首页 > 其他分享 >the_Fourth_lesson

the_Fourth_lesson

时间:2022-09-28 11:55:26浏览次数:36  
标签:Fourth pet describe animal print lesson type name

1、

字典的基本操作测试

 

执行结果:

 

 

2、

函数测试代码

# -*- coding: utf-8 -*-
"""
Created on Thu Sep 22 14:14:00 2022

@author: Administrator
"""

def great_user():
'''显示简单的问候语'''
print("Hello!")

great_user()

print(range(1,3))
a=range(1,3)
print(a)

def greet_user2(username):
#显示简单的问候语
print(f"Hello,{username.title()}")

greet_user2('Fnmlet.N')

# 添加默认值,位置传参和关键值传参
def describe_pet(animal_type,pet_name=2):
# 显示宠物信息
print(f"\nI have a {animal_type}.")
print(f"My{animal_type}'s name is {pet_name}.")

describe_pet("hamster",'harry')
describe_pet(1,2)
describe_pet(pet_name=2,animal_type=1)

函数测试结果:

 

3、

leetcode刷题练习

 测试代码:

 

 测试结果:

 

标签:Fourth,pet,describe,animal,print,lesson,type,name
From: https://www.cnblogs.com/FnmletN/p/16737498.html

相关文章