May 2019
Beginner
528 pages
29h 51m
English
Unless specified otherwise, use IPython sessions for each exercise.
2.1 (What does this code do?) Create the variables x = 2 and y = 3, then determine what each of the following statements displays:
print('x =', x)
print('Value of', x, '+', x, 'is', (x + x))
print('x =')
print((x + y), 'x =', (y + x))
2.2 (What’s wrong with this code?) The following code should read an integer into the variable rating:
rating = input('Enter an integer rating between 1 and 10')
2.3 (Fill in the missing code) Replace *** in the following code with a statement that will print a message like 'Congratulations! Your grade of 91 earns you an A in this course'. Your statement should print the value stored in the variable grade:
if grade >= 90 ...Read now
Unlock full access