Edit typos and grammar and add python files
This commit is contained in:
parent
c1222a8103
commit
991caf0521
16 changed files with 285 additions and 3 deletions
13
thinkcspy/Chapter-2-Exercises/Python-Files/problem10.py
Normal file
13
thinkcspy/Chapter-2-Exercises/Python-Files/problem10.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 10
|
||||
|
||||
miles = input('How many miles did you drive before refueling?')
|
||||
mi = int(miles)
|
||||
|
||||
gallons = input('How many gallons did you use to refuel your vehicle?')
|
||||
gal = int(gallons)
|
||||
|
||||
mpg = mi / gal
|
||||
|
||||
print('Your fuel efficiency is', mpg, 'MPG.')
|
||||
10
thinkcspy/Chapter-2-Exercises/Python-Files/problem11.py
Normal file
10
thinkcspy/Chapter-2-Exercises/Python-Files/problem11.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 11
|
||||
|
||||
celcius = input('What is the temperature in degrees celsius?')
|
||||
C = int(celcius)
|
||||
|
||||
F = (C * 9/5) + 32
|
||||
|
||||
print(C, 'degrees celcius is equivalent to', F, 'degrees fahrenheit.')
|
||||
10
thinkcspy/Chapter-2-Exercises/Python-Files/problem12.py
Normal file
10
thinkcspy/Chapter-2-Exercises/Python-Files/problem12.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 12
|
||||
|
||||
fahrenheit = input('What is the temperature in degrees fahrenheit?')
|
||||
F = int(fahrenheit)
|
||||
|
||||
C = (F - 32) * 5/9
|
||||
|
||||
print(F, 'degrees fahrenheit is equivalent to', C, 'degrees celcius.')
|
||||
20
thinkcspy/Chapter-2-Exercises/Python-Files/problem3.py
Normal file
20
thinkcspy/Chapter-2-Exercises/Python-Files/problem3.py
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 3
|
||||
|
||||
|
||||
currentTime = input('What time is it?')
|
||||
currentTime = int(currentTime)
|
||||
|
||||
waitTime = input('In how many hours do you need to wake up?')
|
||||
waitTime = int(waitTime)
|
||||
|
||||
print('It is currently', currentTime,'.')
|
||||
print('You need to wake up in', waitTime, 'hours.')
|
||||
|
||||
# My solution was more long winded than the actual answer, but it still works!
|
||||
totalTime = currentTime + waitTime
|
||||
time24hr = totalTime // 24
|
||||
alarmTime = totalTime - 24 * time24hr
|
||||
|
||||
print('The alarm has been set for', alarmTime, '.')
|
||||
32
thinkcspy/Chapter-2-Exercises/Python-Files/problem4.py
Normal file
32
thinkcspy/Chapter-2-Exercises/Python-Files/problem4.py
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
#5Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 4
|
||||
|
||||
currentDay = input('''Enter the current day using one of the following numbers:
|
||||
Sunday = 0
|
||||
Monday = 1
|
||||
Tuesday = 2
|
||||
Wednesday = 3
|
||||
Thursday = 4
|
||||
Friday = 5
|
||||
Saturday = 6''')
|
||||
currentDay = int(currentDay)
|
||||
|
||||
stayLength = input('How long is your stay?')
|
||||
stayLength = int(stayLength)
|
||||
|
||||
# Improved upon the long windedness of my answer this time by following the example of the solution
|
||||
# in the previous problem
|
||||
stay = currentDay + stayLength
|
||||
returnDay = stay % 7
|
||||
|
||||
print('It is currently Day', currentDay,'.')
|
||||
print('Your stay is ', stayLength, 'days long.')
|
||||
print('You will return on Day', returnDay, '.')
|
||||
print('''Sunday = 0
|
||||
Monday = 1
|
||||
Tuesday = 2
|
||||
Wednesday = 3
|
||||
Thursday = 4
|
||||
Friday = 5
|
||||
Saturday = 6''')
|
||||
17
thinkcspy/Chapter-2-Exercises/Python-Files/problem7.py
Normal file
17
thinkcspy/Chapter-2-Exercises/Python-Files/problem7.py
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 7
|
||||
|
||||
P = 10000
|
||||
n = 12
|
||||
r = 0.08
|
||||
n = 12
|
||||
|
||||
# Noticed that they gave separate variables to the inputs problem 3 and
|
||||
# the converted ints so decided to do the same here.
|
||||
t_string = input('For how many years will your principal be earning interest?')
|
||||
t = int(t_string)
|
||||
|
||||
A = P*(1+r/n)**(n*t)
|
||||
|
||||
print('The final amount after you will earn after', t, 'years is', A)
|
||||
11
thinkcspy/Chapter-2-Exercises/Python-Files/problem8.py
Normal file
11
thinkcspy/Chapter-2-Exercises/Python-Files/problem8.py
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 8
|
||||
|
||||
r_string = input('Enter the radius of the circle')
|
||||
r = int(r_string)
|
||||
pi = 3.14
|
||||
|
||||
area = pi * r**2
|
||||
|
||||
print('The approximate area of the circle with', r, 'radius is', area, '.')
|
||||
13
thinkcspy/Chapter-2-Exercises/Python-Files/problem9.py
Normal file
13
thinkcspy/Chapter-2-Exercises/Python-Files/problem9.py
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
# Runestone.Academy thinkcspy course
|
||||
# Chapter 2
|
||||
# Problem 9
|
||||
|
||||
width = input('What is the width of the rectangle?')
|
||||
w = int(width)
|
||||
|
||||
height = input('What is the height of the rectangle?')
|
||||
h = int(height)
|
||||
|
||||
area = w*h
|
||||
|
||||
print('The area of the rectangle with a width of', w, 'and a height of', h, 'is', area, '.')
|
||||
Loading…
Reference in a new issue