跳至主要內容
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
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
Python Exercises

Question 01: Hello,You!

Write a program that asks for the user's name, their age and prints a personalized welcome message for them.

For example, an execution could look like this:

Please enter your name: Aika
Please enter your age: 29
Aika, 29, is taking CS-UY 1114.

Cindy原创...大约 7 分钟python practicepracticepythonvariables
01 Practice

Variable & Print

1. 概念题

此题属于概念性问题,没有明确的答案标准,请您根据你所学的知识进行回答。

  1. 在 Python 中,print 函数是用来做什么的?

    输出/打印出代码运行结果

  2. 如何在 Python 中声明一个变量?请给出一个例子。

    a_b_c1 = "hello world"
    
  3. 如何在 Python 中进行多个变量同时赋值相同的值?请给出一个例子。

    a = b = c = 1
    
  4. 如何在 Python 中进行多个变量同时赋值不同的值?请给出一个例子。

    a, b, c = 1, 2, 3
    
  5. 在 Python 中,如果我们想要在一行中打印多个变量,应该怎么做?请给出一个例子。

    a, b, c = 1, 2, 3
    print(a, b, c)
    
  6. 什么是 Python 中的注释?怎么写注释?

    # 这是一行注释
    
  7. 在 Python 中,我们如何改变 print 函数中的 sep 参数,以改变多个变量的输出间隔?请给出一个例子。

    a = b = c = 1
    print (a, b, c, sep = 'hahaha')
    
  8. 在 Python 中 print 的 end 作用是什么?编写个代码示例。

    #end 的作用是改变输出时的结尾结束方式
    a = b = c = 1
    print (a, end = '/n/n')
    print (b)
    '''
    1
    
    
    1
    '''
    
  9. 在 Python 中,如果我们要覆盖一个变量的值,应该怎么做?请给出一个例子。

    a = 1
    print(a)
    a = 2
    print(a)
    #1
    #2
    
  10. 在 Python 中,我们怎么样才能让计算机“看不见”一行代码?

    可以对当行代码进行注释

  11. 当我们用 print 函数同时输出多个变量时,默认的间隔符是什么?

    是一个空格——— sep=‘ ’

  12. 在 Python 中,一个变量可以存储什么样的数据?请给出至少三个例子。

    a = 1 #integer
    b = 1.45 #float
    c = "hello"#string
    
  13. 在编写代码中,为什么要适当的加上空格?空格对代码有影响吗?

    增加代码的可读性,使代码更加规范

    空格对代码没有影响

  14. 变量命名为什么推荐:“见名知意”?

    方便检查

    便于理解


Cindy原创...大约 6 分钟python practicepracticepythonvariables