
Unit 1 Python Test
Presentation
•
Computers
•
7th Grade
•
Hard
Danielle Staton
Used 3+ times
FREE Resource
29 Slides • 0 Questions
1
Unit 1 Python Test
by Danielle Staton
2
What command creates text output in Python?
print()
Explanation:
The print() command creates basic text output in the console.
3
What type conversion should be used for the input below?
sibs = input("Enter the number of siblings you have: ")
Explanation:
Siblings are counted in whole numbers.
(One can't have 3.3 siblings.)
So it makes sense to use integers.
4
What type conversion should be used for the variable total in line 2 below?
total = 50 + 50
print("The total is: " + total)
Explanation:
Before concatenating, number values must be typecast to strings.
5
What type conversion should be used for the input below?
temp = input("Enter temperature as a decimal value: ")
Explanation:
Values that have a decimal point are represented by floats.
6
Given the following code, choose the output that would appear in the console.
var1 = "Hello "
var2 = "World"
print(var1 + var2)
Explanation:
The + is used to concatenate, or join, two strings together. Strings are designated with quotation marks, which don't appear in the final output.
7
Given the following code, choose the output that would appear in the console.
1var = "Hello "
var += "World"
print(var)
Explanation:
The +=, or increment operator, performs a + operation, followed by updating the variable with the new value.
8
Add a float() typecast to the code below to prevent an error.
Explanation:
Only numbers can be used in math calculations. Since input is a string, val must be converted before it can be divided.
9
Can words be used in math calculations?
​
10
Highlight the literals in the following code.
(There are 4.)
11
Change line 2 of this code so that the user's name is printed after the word Hello (on the same line).
​
12
​
13
What will the console print on the screen?
14
Correct the syntax error in the code below so it prints Hello World.
Explanation:
The print command must be followed by parentheses ( ) around the value being printed.
15
Correct the syntax error in the code below so it prints Hello World.
​
Explanation:
A string literal must be surrounded by " " symbols. Otherwise, the code will look for a variable with that name.
16
Add a str() typecast to the code below to prevent an error.
Explanation:
In order to concatenate a number with a string, that number must first be converted with a str() typecast.
17
Add an operator to the code below to prevent an error.
​
Explanation:
The assignment operator = is used to store values (such as input) in variables.
18
Why is this NOT a useful quality of error messages?
Explanation:
Error messages occur when something unexpected happens. They give information about where the error occurred and what caused it.
19
Why are variables useful?
Explanation:
Variables are useful for many reasons.
Some things, such as using values without knowing what they are, cannot be done without variables.
20
Rewrite this line of code to use the increment operator.
Explanation:
+= is the same as performing a + operation, followed by a = operation. It increases the variable on the left by the amount on the right.
21
What symbol is used for the assignment operator?
Explanation:
= is the assignment operator, used to assign values to variables.
For example, my_int = random.randint(1, 5) puts a random value into the variable my_int.
22
In the code below, highlight the concatenation operator. Do NOT highlight the addition operator.
Explanation:
Concatenation is when two strings are joined with the + sign. When + is used to add numbers together, it becomes addition.
23
What is a literal?
​
24
What is the final value stored in total?
total = "50" + "50"
Explanation:
When two strings are concatenated, the symbols of the second string are placed at the end of the first string. This is true even if those symbols happen to be numeric.
25
Which of the following is an expression, but not a statement?
Explanation:
Expressions produce values, but unless they are part of a larger statement, that value is immediately thrown away.
26
What value is the result of this expression?
Explanation:
The modulus operator (%) gives the remainder after division.
27
Explanation:
Lines inside a header comment or lines that start with a # symbol are ignored by the computer. They are used as notes to other coders.
28
What data type is the result of the following expression?
Explanation:
Division always gives a float, even if you are dividing whole numbers. This is because the result of a division is often a fractional value. (In this case, 3.5)
29
Explanation:
Input always returns a string, no matter what symbols the user types
(including numeric symbols).
Unit 1 Python Test
by Danielle Staton
Show answer
Auto Play
Slide 1 / 29
SLIDE
Similar Resources on Wayground
23 questions
7th Grade Math Review
Presentation
•
7th Grade
21 questions
PRONOUNS
Presentation
•
7th Grade
21 questions
Compound vs Complex Sentences
Presentation
•
7th Grade
21 questions
Finding Scale Factor
Presentation
•
7th Grade
21 questions
Clauses
Presentation
•
7th Grade
24 questions
SCRATCH PROJECT 2: My Short Story
Presentation
•
7th Grade
22 questions
Surface Area or Volume?
Presentation
•
7th Grade
23 questions
Organelles and Review
Presentation
•
7th Grade
Popular Resources on Wayground
24 questions
PBIS-HGMS Day 10
Quiz
•
6th - 8th Grade
10 questions
HCS SCI 03 Summer School Review 3
Quiz
•
3rd Grade
11 questions
Home Scope
Quiz
•
7th - 8th Grade
15 questions
HCS SCI 05 Summer School Assessment 3 Review
Quiz
•
5th Grade
35 questions
Lufkin Road Middle School Student Handbook & Policies Assessment
Quiz
•
7th Grade
18 questions
Geo 11.3 Area of Circles and Sectors
Quiz
•
9th - 11th Grade