-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript_01_ex.py
59 lines (43 loc) · 2.17 KB
/
script_01_ex.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# create a variable called color with an appropriate value on the line below
# (Remember, strings in Python must be enclosed in 'single' or "double" quotes)
color = "sky blue"
# ---------------------------------------------------------------------------------------------------------------------------------
pi = 3.14159 # approximate
diameter = 3
# Create a variable called 'radius' equal to half the diameter
radius = diameter / 2
# Create a variable called 'area', using the formula for the area of a circle: pi times the radius squared
area = pi*(radius**2)
print(round(area, 2))
print(area)
# ---------------------------------------------------------------------------------------------------------------------------------
########### Setup code - don't touch this part ######################
# If you're curious, these are examples of lists. We'll talk about
# them in depth a few lessons from now. For now, just know that they're
# yet another type of Python object, like int or float.
a = [1, 2, 3]
b = [3, 2, 1]
#q2.store_original_ids()
######################################################################
# Your code goes here. Swap the values to which a and b refer.
# If you get stuck, you can always uncomment one or both of the lines in
# the next cell for a hint, or to peek at the solution.
temp = a
a = b
b = temp
# ---------------------------------------------------------------------------------------------------------------------------------
# Add parentheses to the following expression so that it evaluates to 1.
expression_0 = (5 - 3) // 2
print(expression_0)
# Add parentheses to the following expression so that it evaluates to 0
expression_1 = 8 - (3 * 2) - (1 + 1)
print(expression_1)
# ---------------------------------------------------------------------------------------------------------------------------------
# Variables representing the number of candies collected by alice, bob, and carol
alice_candies = 121
bob_candies = 77
carol_candies = 109
# Your code goes here! Replace the right-hand side of this assignment with an expression
# involving alice_candies, bob_candies, and carol_candies
to_smash = (alice_candies+bob_candies+carol_candies) % 3
print(to_smash)