Font size
WorksheetsIntro to Python 1
Total questions: 30
Worksheet time: 30mins
Debug the following code: pirnt (Welcome to my program!)
Add quotations
add curly brackets
add quotations and curly brackets
check spelling and add quotations
What kind of file extension must be on your file for Python code to run?
.html
.css
.py
.js
Is Python generally used on the back-end or front-end of web development?
Back-end
Front-end
What is a building block of code that allows you to store data in it like a box?
variable
output
name
attribute
True or False: Creating a variable is the same as declaring a variable.
False
True
What is the best practice when creating variables?
Use more than one word when naming a variable to make it specific.
Use one syllable words when creating variables.
Name your variable something that refers to what it holds.
Use letters like x, y, or n to make code as short as possible.
Debug the following code: class_pet : "snake"
class_pet = “snake”
class_pet & “snake”
class pet = “snake”
class_pet = “snake
Which line of code correctly asks the user for their name and assigns it to a variable?
name = input("What's your name?")
name = input "What's your name?"
name = input("What's your name?)
name = input("What's your name?"
How do you combine text and a variable in a print() statement?
Put the variable before the print() statement
Use the "+" sign
Put the variable outside the print() statement.
Include the variable in the quotation marks.
What key does the user need to press after typing in their input?
+
Enter
-
=
What makes Python syntax different from most other languages?
The order of parentheses matters.
It uses comments in the program.
It uses semicolons at the end of a thought.
It is similar to English syntax.
How do you create a comment in Python?
// Here is my comment
/* Here is my comment */
# Here is my comment
<!-- Here is my comment -->
Which examples are valid strings? Select all that apply.
goats are awesome-
"goats are awesome"
goats are awesome
'goats are awesome'
Which is an example of an integer data type in Python?
"3"
true
32
"three"
What is the benefit of using a float?
It lets us be more accurate by using decmials
There is no benefit.
It's a less accurate number.
It lets us avoid using decimals.
What happens when you change a float to an integer?
It drops the decimal
It moves the decimal to the right one space.
It rounds the decimal up.
It rounds the decimal down.
What data type is this? "7.45"
String
Integer
Float
What will print out with the following code? print("4" * 3)
7
444
12
1
Which symbol is used for multiplication in Python?
^
*
x
+
Which symbol is used for division in Python?
\
|
/
>
What is the output of this code? rocks = 15 print(rocks / 3)
5
15
7
3
What is the following symbol called in Python? %
percentage
modulus
decimal
addition
Which use of quotation marks is correct when creating strings in Python?
"Hello World"
'''Hello World'''
They are all valid ways to create strings.
'Hello World'
How many quotation marks are required at the beginning and end when creating a multi-line string?
2
3
4
1
What is concatenation?
Splitting up strings
Adding strings together
Printing strings.
A kind of string method
Which data grouping is ordered and changeable?
Tupul
List
Dictionary
alpha
What statement will catch everything that is not included in the IF statement?
The ELSE statement
The CATCH statement
The OTHER statement
The THEN statement
What kind of brackets are used for lists in Python?
{ }
( )
[ ]
< >
Debug the following code: distance = (5, 7, 20, 11, 18)
distance = [5, 7, 20, 11, 18]
distance = {5, 7, 20, 11, 18}
distance - [5, 7, 20, 11, 18]
distance + [5, 7, 20, 11, 18]
The results from this code if you enter 2.0 and 5 =
# num1 = input ("Enter a Number")
# num2 = input ("Enter another Number")
# results = int(num1) + int(num2)
# print (results)
2.5
syntax error
5.0
5
