python theory Flashcards
Python’s governing body recommends breaking up multi-word
variables with
underscore (__)
another way to write age = age + 1 is
age += 1
In a list, these
values are known as
elements
enclosed in square brackets is what kind of data type
lists
Return keyword is used to show the results in or within using
functions, methods, lambdas
A list can contain various data types (True or False)
True
.append keyword for the list does what
add element to the end of the list
todays_tasks = todays_tasks + [“Washing the car”, “Cleaning the car”]
what is happening in the code
a way to add elements to the list using a list
if you want to add something new in the middle of the list what keyword would you use
insert
cities.insert(0, “New York”) what is happening here
using insert the work new york is places first in the list of cities.
in slicing the number following the colon is the index number of the element that
comes _____(when) the last element in the slice:
after
keywords used to remove items in a list
del and .remove
the .remove need what
the string value
to strike off an element of a list the keyword used is
.pop
what is similar to a list but elements are fixed unless the entire thing is redefined
tuple
We’re looping through the list y and assigning each element to the variable x. Code the first line.
for x in y:
what statement is used to stop the loop
break
contains an element less than 1, meaning
c < 1:
that you ____ provide a variable to hold the user’s input. If you omit
it python breaks
must
the default data type of a input by a user is
string
what does .lower() do
for a list, variable or anything it changes all to lower case
what does .title() do
The first letter of the word is capitalized like “Cheyenne” to “Cheyenne”
the data type that has ( ) brackets
tuples