跳至主要內容
VividVerve

VividVerve

分享快乐

项目名称
项目详细描述
链接名称
链接详细描述
书籍名称
书籍详细描述
文章名称
文章详细描述
伙伴名称
伙伴详细介绍
自定义项目
自定义项目
自定义详细介绍
Python Exercises

Question 01: Find the Missing Number

Acquire user input, where the user inputs a specific list. This list consists of consecutive numerical elements. However, one number is missing. Please write a program to find the missing number without using any built-in functions.

Sample Test 1:


Cindy原创...大约 3 分钟python practicepracticepython
11 Python for loop

1. for循环

lst = [1, 2, 3, 4, 5, 6, 7, 8, 9]
for number in lst:
    print (f"{number}: {number*'*'}")

Cindy原创...大约 1 分钟python notebooknotespython
11 Python while

1. while 循环

当满足条件是一直执行里面的代码块

user_answer_correct = False
while not user_answer_correct:
    user_gender = input("Please input your gender(F/M): ")
    if user_gender == 'F':
        print("Your are a girl")
        user_answer_correct = True
    elif user_gender == 'M':
        print("Your are a boy")
        user_answer_correct = True
    else:
        print("Wrong inout, please input F or M")

 










Cindy原创...大约 5 分钟python notebooknotespython
10 Python if

python代码缩进问题

用四个空格或者一个tab表示缩进都可以,但不要混用。

相同位置表示他们是同一个代码块

while True:
 if True:
        print('hhhh')
 print('bo')

Cindy原创...大约 3 分钟python notebooknotespython
Python exercise

Chapter1 after class test

  1. 以下哪个变量可以做 Python 的变量: C

    A. 01a B. class C. a_int D. b-int

  2. 以下哪个选项不是 Python 的基本数据类型关键字 C

    A. int B.bool C. string D. dict

  3. 此题无需在线作答,请在纸上作答后查看答案解析

    语句 x, y, z = 1, 2, 3 执行后,变量 y 的值为. 2

  4. 查看变量类型的 Python 内置函数是. type()

  5. 此题无需在线作答,请在纸上作答后查看答案解析

    请写出该代码的输出结果. XYZ

    a = 'ABC'
    b = a
    a = 'XYZ'
    print(b)
    

Cindy原创...大约 5 分钟python notebookpracticepython
Python Exercises

通过一句一句的提问获取用户的信息,生成一个格式化的简历。

如例:

fb736dc40ee235cf8565a7d6ed222fd3.png
name = input("请输入你的姓名: ")
gender = input("请输入你的性别: ")
age = input("请输入你的年龄: ")
school = input("请输入你的学校: ")
print("is processing......")
print("    简历     ")
print(f"姓名: {name}")
print(f"性别: {gender}")
print(f"年龄: {age}")
print(f"就读学校: {school}")

#---output---
请输入你的姓名: Cindy
请输入你的性别: female
请输入你的年龄: 17
请输入你的学校: Cambridge
is processing......
    简历     
姓名: Cindy
性别: female
年龄: 17
就读学校: Cambridge

Cindy原创...小于 1 分钟python practicepracticepythonvariables
09 Python boolean value

1.布尔值的意义

用于表示判断中的是与否。一般用于条件测试当中

In [1]: a = True

In [2]: print(a)
True

In [3]: 10<5
Out[3]: False


Cindy原创...大约 1 分钟python notebooknotespython
08 Python set

1. 创建集合

  1. 直接用花括号创建集合
set1 = {1, 2, 3, 4, 5, 6, 7, 8}

Cindy原创...大约 1 分钟python notebooknotespython
07 Python dictionary

1. 如何创建一个电话薄

我们现在有下面的联系人:

姓名 手机号
李雷 123456
韩梅梅 132456
大卫 154389
Mr.Liu 131452
Bornforthis 180595
Alexa 131559

Cindy原创...大约 6 分钟python notebooknotespython
06 Python tuple

1.创建元组

  • 使用小括号创建
  • 里面的元素用英文逗号隔开
tup = ('毒药', '解药', '感冒药')
print(tup, type(tup))
#output
('毒药', '解药', '感冒药') <class 'tuple'>

Cindy原创...大约 3 分钟python notebooknotespython