Midterm review Flashcards
Zoom!!
Variables
a bucket to store information in
ex) camelCase or snake_case
Integers
int
3 or -1 or 0 or 2001
Real Numbers
float
3.14 or 0.094 or -12.0
Character Strings
str
“Hi” “ “ “a” “44”
Boolean
bool
True or False
What is this? 3 != 3
boolean bc it’s a comparison
What is this? “Exam, Day, Soon”
string
What is this? 5.9
float
What is this? 2
integer
What is this? 5.9 - 3
float
What is this? 9 // 1
integer ( just 9 divided by 1)
What is this? 5.9 x 3
float
Concatenation
- fancy name for string
- has “ “ or ‘ ‘
- concatenate by +
- like gluing strings
together (no spaces)
- like gluing strings
What is a method?
- function or command
- “called” with parenthesis
- to access method, use dot.operator
What are the two parts of a string?
it’s data and it’s methods
s = “panang Curry”
method = upper()
print(s.upper())
output?
PANANG CURRY
uppercase version of string
s = “panang Curry”
method = lower()
print(s.lower())
output?
panang curry
lowercase version of string
s = “panang Curry”
method = swapcase()
print(s.swapcase())
output?
PANANG cURRY
case of each letter is switched
s = “panang Curry”
method = capitalize()
print(s.capitalize())
output?
Panang curry
1st letter capitalized and the rest are lowercase
s = “panang Curry”
method = title()
print(s.title())
output?
Panang Curry
first letter of each word is caps and rest is lowercase
How do you display:
She said “You need escape characters”
Which are: \important\
print(“She said "You need escape characters"” \nWhich are: \important\”
Which escape character lets you use double quotes in a string?
"