课程简介
Python for Everybody 零基础程序设计(Python 入门)
- This course aims to teach everyone the basics of programming computers using Python. 本课程旨在向所有人传授使用 Python 进行计算机编程的基础知识。
- We cover the basics of how one constructs a program from a series of simple instructions in Python. 我们介绍了如何通过 Python 中的一系列简单指令构建程序的基础知识。
- The course has no pre-requisites and avoids all but the simplest mathematics. Anyone with moderate computer experience should be able to master the materials in this course. 该课程没有任何先决条件,除了最简单的数学之外,避免了所有内容。任何具有中等计算机经验的人都应该能够掌握本课程中的材料。
- This course will cover Chapters 1-5 of the textbook “Python for Everybody”. Once a student completes this course, they will be ready to take more advanced programming courses. 本课程将涵盖《Python for Everyday》教科书的第 1-5 章。学生完成本课程后,他们将准备好学习更高级的编程课程。
- This course covers Python 3.
coursera
Python for Everybody 零基础程序设计(Python 入门)
Charles Russell Severance
Clinical Professor
课程资源
coursera原版课程视频
coursera原版视频-中英文精校字幕-B站
Dr. Chuck官方翻录版视频-机器翻译字幕-B站
Quiz 2: Variables, expressions and statements
We learn how to make variables and store data in those variables.
单选题(1-14)
- In the following code,
print(98.6)
What is “98.6”?
- An iteration / loop statement
- A constant
- A variable
- A conditional statement
- Which of the following is a comment in Python?
- /* This is a test */
- // This is a test
- * This is a test
- # This is a test
3.What does the following code print out?
print("123" + "abc")
- 123+abc
- This is a syntax error because you cannot add strings
- 123abc
- hello world
- In the following code,
x = 42
What is “x”?
- A variable
- A constant
- A Central Processing Unit
- A function
- Which of the following is a bad Python variable name?
- 23spam
- _spam
- Spam
- SPAM23
- Which of the following variables is the “most mnemonic”?
- hours
- x
- x1q3z9ocd
- variable_173
- Which of the following is not a Python reserved word?
- if
- for
- else
- speed
- Which of the following is not a Python reserved word?
- iterate
- else
- break
- continue
- Assume the variable x has been initialized to an integer value (e.g., x = 3). What does the following statement do?
x = x + 2
- Produce the value “false” because “x” can never equal “x+2”
- Create a function called “x” and put the value 2 in the function
- This would fail as it is a syntax error
- Retrieve the current value for x, add two to it and put the sum back into x
- Which of the following elements of a mathematical expression in Python is evaluated first?
- Parentheses ( )
- Multiplication *
- Addition +
- Subtraction -
- What is the value of the following expression
42 % 10
Hint - the “%” is the remainder operator
- 10
- 1042
- 2
- 420
- What will be the value of x after the following statement executes:
x = 1 + 2 * 3 - 8 / 4
- 15
- 3.0
- 4
- 5.0
- What will be the value of x when the following statement is executed:
x = int(98.6)
- 6
- 100
- 98
- 99
- What does the Python input() function do?
- Pause the program and read data from the user
- Read the memory of the running program
- Connect to the network and retrieve a web page.
- Take a screen shot from an area of the screen
编程题
Exercise 2.2
题目:
Write a program that usesinput
to prompt a user for their name and then welcomes them.
Note thatinput
will pop up a dialog box.
EnterSarah
in the pop-up box when you are prompted so your output will match the desired output.
[Desired Output]
Hello Sarah
解题代码:
# The code below almost works name = input("Enter your name") print("Hello",name)
Exercise 2.3
题目:
Write a program to prompt the user for hours and rate per hour using input to compute gross pay.
Use 35 hours and a rate of 2.75 per hour to test the program (the pay should be 96.25).
You should useinput
to read a string andfloat()
to convert the string to a number.
Do not worry about error checking or bad user data.
[Desired Output]
Pay: 96.25
解题代码:
# This first line is provided for you hrs = input("Enter Hours:") per = input("Enter rate:") pay = float(hrs) * float(per) print("Pay:",pay)