Note 5.41.1.
If you work in a group, have only one member of the group fill in the answers on this page. You will be able to share your answers with the group at the bottom of the page.
def keyword and then execute it using function_name(arguments).
b when function test starts executing?
test above and run the code again. What value is returned from a function that doesnβt have a return keyword?
print_greeting that asks for your name and prints βHello Nameβ. Then define a main function that calls print_greeting. Be sure to also call the main function. Note that you will have to indent the lines that are in the body of each function. Click the Check button to check your solution.
"hello" or 'hello'. This is especially useful when a string includes a single quote "they're". You can even use tripe quotes when a string covers more than one line.
string[index].
string[index] to get a character from a string. The first character in a string is at index 0 and the last is at the length of the string minus 1 (also know as index -1 in Python)
str_name[start:end].
[start:end] operator to get a slice (substring) from a string. It will return a new string starting at the start index and include all the characters up to just before the end (the last character will be from index end - 1). If start is missing the default is 0 and if end is missing the default value is the length of the string.
dna?
if. You can execute one block of code when a condition is true (using if) or false (using else). You can even speicfy more than two outcomes as shown in the code below.
str(number) before you add it to a string using +.
check_guess which will return 'too low' if the guess is less than the passed target, 'correct' if they are equal, and 'too high' if the guess is greater than the passed target. For example, check_guess(5,7) returns 'too low', check_guess(7,7) returns 'correct', and check_guess(9,7) returns 'too high'. There are three extra blocks that are not needed in a correct solution.
main function to test each possible letter grade. It should return A if the score is greater than or equal 90, B if greater than or equal 80, C if greater than or equal 70, D if greater than or equal 60, and otherwise E.
and, or, and not. These can be used to create complex conditionals.