What is python?
Python is a popular programming language.
for i in _________(5):
range
Python syntax can be executed by writing directly in the Command Line:
>>> print("Hello, World!")
Hello, World!
How can you create a variable?
A variable is created the moment you first assign a value to it.
forward(100)
right(90)
forward(100)
right(90)
forward(100)
right(90)
forward(100)
right(90)
What is a square
"str" is an example of...
Text Type
The Binary number system is based on this number. Called Base "___ "
2
What can Python do?
In Python, you can set conditions and have the program execute code according to what meets the conditions. What type of function are these?
Example:
What is conditionals
Or by creating a python file on the server, using the .py file extension, and running it in the Command Line:
C:\Users\Your Name>python myfile.py
What are variables?
Variables are containers for storing data values.
print(9 + 1 * 3 - 2)
What is 10
DAILY DOUBLE
"int", "float" and "complex" are examples of...
Numeric Types
Convert to Binary:
31
11111
We can use python for....
DAILY DOUBLE
how do you obtain information from the user
input()
What is Python Identation?
Indentation refers to the spaces at the beginning of a code line.
The number of variables in this problem
What is one.
for i in range(3):
pat.forward(100)
Pat will move over ___ Pixels
What is 300
5.0
float
212
11010100
Compared to other programming languages...
What does "calling a function" mean?
When you ask a function to perform what it has been defined to do.
print(5) is a function call
is_senior(65) is a function call
What does python use identation for?
Python uses indentation to indicate a block of code.
What can you do with the type() function?
You can get the data type of a variable with the type() function.
DAILY DOUBLE
x is 32?
if x > 12:
print("large")
else:
print("small")
What is large
TRUE
boolean / bool
Convert to Base 10:
11010100
44
What are some common errors that people make when writing programs?
Answers may vary:
Adding spaces between numbers
Forgetting a parentheses
Not checking data type when doing operations
Forgetting a colon
Indenting incorrectly
def word_multiplier(word, mult_num):
return word * mult_num
print(word_multiplier("Yes", 5))
What would it print? What are the parameters? Where is the function call? What is the function header? What is the function body? What is the function input?
The answer would print:
YesYesYesYesYes
Use the same number of spaces in the same block of code, otherwise
Python will give you an error
What can single or double quotes do?
String variables can be declared either by using single or double quotes:
def mystery( a, b ):
return a + b
n = mystery(2, 3)
m = mystery("french ", "fries")
print(n, m)
What is 5 french fries
word5andnum63r5
string
10100111001
1337
What is the output of the following code if the user enters 5:
def findSquare(num = 10):
return num * num
num = input("Enter a number: ")
mySquare = findSquare()
print(num, "squared is", mySquare)
5 squared is 100
This is tricky but function was defined with num = 10. The input statement never went into findSquare() function.