Level 6 Flashcards
If ELSE or and elif formating slicing for loop while loop
Get client input
name=input(“What is your name ? “)
print(name)
if statement
if name == “Chris” :
print(name)
elif
name=input(“name please”)
if name==”Chris” :
print(name)
elif :
print(“Ranine”)
else
or
name=input(“name please”)
if name==”Chris or name ==”Ranine”
print(“married”)
else:
print(“Don’t know you”)
match
case
good_not_good = input(“Are you good or evil? “)
match good_not_good:
case (“good”):
print(“good”)
case (“evil”):
print(“evil”)
formating /n
Get user input on new line
name=print(“Whats your name?\n”)
formating (f)
name=print(“Whats your name?\n”)
print(f”Yourname is {name})
formating (f”……………/.2f”)
Add 2 digets after decimal after number
number = 800
print(f”Number is {number:.2f}”)
Answer is 800.00
Slicing
# Printing specifc letters in a word eg,
Name=(“Titanic”)
print(name[6])
c
Slicing
# Printing specifc letters in a word eg,
Name=(“Titanic”)
print(name[-1])
c
Slicing
Name=(“Titanic”)
print(name[5:])
ic
the 5th letter then print till the rest till the end
listing items
[……]
jedi = [“Dart Vader”, “Rey”, “Yoda”, “Leia”]
for loop
jedi = [“Dart Vader”, “Rey”, “Yoda”, “Leia”]
for x in jedi:
print(x + (“ is a jedi”))
Dart Vader is a jedi
Rey is a jedi
Yoda is a jedi
Leia is a jedi