-
Notifications
You must be signed in to change notification settings - Fork 5
Description
Tutorial Questions - Intro to Python (Tutorial A)
Pre-Tutorial Work:
None this week.
Problem 1
Write a statement that finds the second letter of the value stored in the variable colour and assigns it to a new variable. Make sure to choose a meaningful name for your new variable.
# Given variable
colour = "yellow"write your solution here
Problem 2
Write a code fragment (i.e. one or more lines of code) that calculates the average of the three grades. Your code fragment should still calculate the correct average even if you change the values assigned to the three variables grade1, grade2, and grade3.
grade1 = 80
grade2 = 67
grade3 = 91
# write your solution hereProblem 3
The following code fragment is supposed to add 15% tip to a cost (in cents) if add_tip is True, but it contains one or more errors. If add_tip is False, no tip should be added. Debug (fix) the code fragment until it is correct and runs without errors.
cost = 2450
add_tip = True
if add_tip
cost = cost * .15Problem 4
Write the step-by-step evaluation of the expression 11 > 4 or 10 <= 9.
Note that you are allowed to elide steps as seen in Example 3 in Section 3.2.2 of the Evaluation Rules document.
# Original expression
11 > 4 or 10 <= 9
# write your solution here