Python Basics Flashcards
how do you pass a string as an instruction to output the string without ‘ ‘
print(stringname)
how do you import information about what version of python you’re using
import sys
what do you use to have python ignore everything you write past it in the same line
#
if you mistype a function, what type of error will you get
NameError
if you forget a “, what type of error will you get
SyntaxError
what type of object is ‘7.1’
a string - it has quotation marks
what type of object is 7.1
a float - it contains a decimal
what type of object is 7
an int- short for integer
how can you figure out whether something is outputting a string, an integer, a float, or something else
type(input)
how do you cast 2 as a float
float(2)
how do you cast 1.1 as a string
str(1.1)
what is important to remember about boolean operators
they must have capital letters (ie True and False)
does a false convert to a 0 or 1 integer
0
what is different between / for division and // for division
// will give you an integer, / will give you a float