. Flashcards
What is a list ?
Lists are used to store multiple items in a single variable
.—contains—
Checks if a value or variable is inside a list or variable
What is programming?
Creating a set of instructions that tells a computer how to perform a task
What is a variable?
A value that can change. Variables are containers for storing data values.
How to add numbers together?
answer = 2+3
print (answer)
What is a comment?
Allows you to write about what your code does so that you don’t lose track of it, similar to writing on your notebooks.
What is the symbol for writing a comment?
(hashtag)
What are the 4 different data types?
1)Integer (numbers)
2)String (Eg: “Hello World” )
3) Boolean (TRUE and FALSE)
4) Lists (expList = [a,b,c,d,e] )
What are If, elif, and else statements in python?
Evaluates whether a condition is equal to (else) true or false (If, elif)
Create a variable that is set to 5, if the variable is more than 5 print “more than 5” if it is less than 5 print “ less than 5”
answer = 5
if answer > 5:
print ( “Greater than 5” )
elif answer < 5:
print ( “Less than 5” )
else:
print ( “Equal to 5” )
What are these symbols used for (+,-,<,>, ==, !=, /, *)
(+) addition
(-) subtracting
(<) less than
(>) more than
(==) equal to
(!=) not equal
(*) multiplication
(/) Division
What is the assignment operator?
=
How to check if a value or variable is inside a list or variable?
myList = [ 1,2,3,4 ]
if myList .—contains—(2):
print (True)
else :
print (False)
Create a variable called hello that takes the value “Hello World”. Then create a list with the following variables, 1, “Goodbye”, True, hello. Check if the list contains hello print True otherwise print False.
hello = “Hello World”
myList = [ 1, “Goodbye” , True, hello]
if myList .—contains—(hello):
print (True)
else:
print (False)