Add Exercise files
This commit is contained in:
parent
18b3326b8e
commit
47b74f6a04
9 changed files with 154 additions and 0 deletions
9
thinkcspy/Chapter-5-Exercises/Python-files/problem16.py
Normal file
9
thinkcspy/Chapter-5-Exercises/Python-files/problem16.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 5
|
||||
# Problem 16
|
||||
|
||||
import random
|
||||
|
||||
for i in range(10):
|
||||
prob = random.random()
|
||||
print(i+1, '-', prob)
|
||||
9
thinkcspy/Chapter-5-Exercises/Python-files/problem17.py
Normal file
9
thinkcspy/Chapter-5-Exercises/Python-files/problem17.py
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 5
|
||||
# Problem 17
|
||||
|
||||
import random
|
||||
|
||||
for i in range(10):
|
||||
prob = random.randrange(25, 36)
|
||||
print(i+1, '-', prob)
|
||||
12
thinkcspy/Chapter-5-Exercises/Python-files/problem18.py
Normal file
12
thinkcspy/Chapter-5-Exercises/Python-files/problem18.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 5
|
||||
# Problem 16
|
||||
|
||||
import math
|
||||
|
||||
a = float(input('What is the length of the first side of the triangle?'))
|
||||
b = float(input('What is the length of the second side of the triangle?'))
|
||||
|
||||
c = math.sqrt(a*a + b*b)
|
||||
|
||||
print('The hypotenuse of this triangle with is', c, '.')
|
||||
13
thinkcspy/Chapter-5-Exercises/Python-files/problem19.py
Normal file
13
thinkcspy/Chapter-5-Exercises/Python-files/problem19.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 5
|
||||
# Problem 19
|
||||
|
||||
import math
|
||||
|
||||
c = float(input("Today we are going to calculate pi from the dimensions of a circle. What is the circumference of your circle?"))
|
||||
d = float(input("And what is the diameter of your circle?"))
|
||||
|
||||
zpi = c/d
|
||||
|
||||
print("The approximate value of pi from the dimensions provided is", zpi)
|
||||
print("The actual (also technically approximate) value of pi is", math.pi)
|
||||
Loading…
Reference in a new issue