Codeavengers Python 1
What character would be best to use around a string that says: Don't click the wrong answer! ' " / \
"
What characters go around text to make it a string? " < + (
"
Which symbol is the symbol for writing comments in Python? * /* # //
#
What character would be best to use around a string that says: A "string" is a sequence of characters ' ( " <
'
What if the correct symbol for multiplication in python? * ^ # x
*
Which of these is the correct symbol for doing powers such as 2³? ^^ ^ xx **
**
Which operator increments (adds to) a variable? *= -= += /=
+=
Makes the first letter of the string a capital
.capitalize
Inserts values into {} placeholders in a string
.format
converts a whole string to lower case
.lower
removes all spaces from the start and end of the string
.strip
Gives Each Word A Capital
.title
CONVERTS A WHOLE STRING TO UPPER CASE
.upper
Which decimal number would calculate the price of a 15% discount if you multiplied the original price by it? 1.15 0.15 0.75 0.85
0.85
How far should code be indented if it's inside a block in python? 1 tab 1 space 2 tabs 3 spaces
1 tab
What is the value of var_1 at the end of the following code? [ var_1 = 3 += 7 *= 4 /= 8 -= 1 ] 3 6 4 5
4
Which character goes at the end of a line of code the starts with if? , { : ;
:
Which operator means less than? > >= <= <
<
Which if condition evaluated to False if the number 16 is stored inside the variable age? if age >= 15: if age <= 12: if age > 3: if age < 20:
<= 12
Which operator means is equal to in Python? => != == =
==
Which operator means greater than or equal to? <= =< => >=
>=
Why are well-named variables important in programming? They make the code easier to change later on They make the code more flexible They make the code easier to read All of these
All of these
What is BEDMAS short for?
Brackets Exponents Division Multiplication Addition Subtraction
We've got another program that calculates pay for workers: everyone works 40 hours/week, some people get paid different hourly rates, some work overtime (extra) hours. Which value is most likely to be a constant? HOURLY_RATE HOURS_WORKED OVERTIME_HOURS TOTAL_HOURS
HOURS_WORKED
How do you know which bit of code is inside an if statement? It is surrounded by {} It is written in CAPITALS It is indented It starts with a #
It is indented
There are 2 ways to print multi-line statements:
Triple " quotes The special newline character \n
A stored value that can be used later and modified by the program, its value can vary.
Variable
Typing ___ before a character tells the program to ignore that one and just treat it as part of the string.
\
Which of these is the 'new line' character for putting print statements on more than one line? /nl \nl \n /n
\n
a special character that makes the next character appear on a new line. also known as line break or end of line.
\n
Which of these is a valid Python variable name? answer#1 1st_answer first-answer answer_1
answer_1
An indented section of code inside something like an if statement or loop
block
A type of value that can only be True or False
boolean
One simple way that we can combine strings with numbers or calculations is to use a _______
comma ,
There to explain how code is structured and how it functions, they are not run.
comments
The type of data (string, int, float etc.) that is stored in a variable
datatype
Finding or removing mistakes in a computer program.
debugging
Lets you specify a second, third etc. condition to check if the first if condition is false
elif
What is the keyword used for making a second branch in an if statement when both branches have a condition? else if elf elif else
elif
Lets you specify a default block of code that will run if all of the previous if and elif conditions are False.
else
Code which is easy to change because coding features like variables, constants, and derived values are used, instead of just writing numbers everywhere
flexible
Have a decimal point in them
floating point numbers or floats
Lets you specify a condition, and the code inside it will run if that condition is True.
if
to increase the value of a variable
increment
To add white space between the start of a line and the left margin.
indented
Asks the user a question and allows them to type text in.
input
Which of these is the python command that lets the user type in some text? input() ask() print() write()
input()
What needs to be added to this input statement for this code to work? [ WORLD_RECORD = 272 #Ask the user for their height height = input("Enter your height in cm: ") #Tell them if they are short or tall if height <= 130: print("You are very short") elif height > 130 and height <= 160: print("You are short") elif height > 160 and height <= 175: print("You are average sized") elif height > 175 and height <= WORLD_RECORD: print("You are tall") else: print("Impossible! The record is 272cm!") ] int() and format() strip()
int()
A positive or negative whole number
integer
In the following code, what would be the best names for the variables labeled a, b and the number 15? [a = int(input("How many pizzas?") b = a * 15 print("Your total comes to: {}".format(b))] num_pizzas, total_cost, pizza_price pizza_price, order, number num_donuts, total_cost, price donut_price, total, numDonuts
num_pizzas, total_cost, pizza_price
If you wanted to store the number of students present in your class today, which would be the best 'Pythonic' variable name for it? Students number_of_students numberOdStudents n Number_Of_Students
number_of_students
Symbols that do maths and make comparisons e.g. +, *, /, -, >=, ==
operator
Which of these variables is a float? [distance = 50 * 3 price = 13.75 * 3 area = 20* 35] distance area price
price
Outputs information to the screen.
Which is the better print statement? print("Ramin is writing this.") print ("Ramin is writing this.")
print("Ramin is writing this.")
The word "Sally" is saved in a variable called name. Which of these print statements will correctly print out: "That snake is named Sally" print("That snake is named " + name) print("That snake is named " + Sally) print("That snake is named" + name) print("That snake is named name" )
print("That snake is named " + name)
Which of these print statements is written most correctly? print( 'Well, that's cast rather a gloom over the evening, hasn't it?' ) print( "Well, that's cast rather a gloom over the evening, hasn't it?" ) print("Well, that's cast rather a gloom over the evening, hasn't it?") print('Well, that's cast rather a gloom over the evening, hasn't it?')
print("Well, that's cast rather a gloom......")
Which of the following print statements prints 7? print(22 - 1 / 3) print(2 ** (2+3)) print(3 - 2 * 7) print(2 ** 3 - 1)
print(2 ** 3 - 1)
Which of these print statements will print out the number 7? print(3 + 8 - 4) print(4 + 5 - 14) print(3 + 7 + 3) print(2 + 2 - 3)
print(3 + 8 - 4)
In which of these calculations does the addition (+) happen first? print(5 + 8 * 3 - 4) print(5 / (2 ** 3 + 4)) print(3 + 4 * 5) print(32 * 4 - (5+3))
print(32 * 4 - (5+3))
Which of these print statements are True? print(32 < 45) print(3 == 55) print(4 > 7) print("Bob" == "bob")
print(32 < 45)
Which calculation prints 12? print() 24 / (3 + 4) 4+ 2 * 4 13 - 1 / 0 3 + 3 * 2
print(4 + 2 * 4)
Also called speech marks and often used for showing speech in text.
quotes
Code that makes decisions. Usually if/else statements...
selection
A sequence of characters "strung" together, enclosed in ' or " quotes.
string
A _______ is just a bunch of letter, number or punctuation characters all "_____" together
string, strung
Which of the following print statements will correctly take in a number that can be used in a calculation? number = int(input("Please enter a number: ")) number = int(input("Please enter a number: ") number = input("Please enter a number :") number = input(int("Please enter a number: "))
the first one
If book_price = 5.50 and the deal is "Buy 2 get the third half price" which calculation will give the correct total_price? (book_price * 3) / 2 3 * book_pruce + book_price / 2 2 * book_price + book_price / 2 2 * total_price + book_price
the third one
If var_2 = 4, which of these changes var_2 to 1? var_2 ( += -= /= *= ) 3
var_2 -= 3