diff --git a/thinkcspy/Chapter-2-Exercises/Chapter-2-Exercises.md b/thinkcspy/Chapter-2-Exercises/Chapter-2-Exercises.md index cda9450..5eb983a 100644 --- a/thinkcspy/Chapter-2-Exercises/Chapter-2-Exercises.md +++ b/thinkcspy/Chapter-2-Exercises/Chapter-2-Exercises.md @@ -32,7 +32,7 @@ Problem 4 _It is possible to name the days 0 through 6 where day 0 is Sunday and day 6 is Saturday. If you go on a wonderful holiday leaving on day number 3 (a Wednesday) and you return home after 10 nights you would return home on a Saturday (day 6) Write a general version of the program which asks for the starting day number, and the length of your stay, and it will tell you the number of day of the week you will return on._ ```text-x-python -Runestone.Academy thinkcspy course +#Runestone.Academy thinkcspy course # Chapter 2 # Problem 4 diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem10.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem10.py new file mode 100644 index 0000000..4cbbef9 --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem10.py @@ -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.') \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem11.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem11.py new file mode 100644 index 0000000..7c7bdc5 --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem11.py @@ -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.') \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem12.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem12.py new file mode 100644 index 0000000..4ffe7bd --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem12.py @@ -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.') \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem3.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem3.py new file mode 100644 index 0000000..c481082 --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem3.py @@ -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, '.') \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem4.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem4.py new file mode 100644 index 0000000..3db9027 --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem4.py @@ -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''') \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem7.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem7.py new file mode 100644 index 0000000..141a11d --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem7.py @@ -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) \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem8.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem8.py new file mode 100644 index 0000000..dedd102 --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem8.py @@ -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, '.') \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/Python-Files/problem9.py b/thinkcspy/Chapter-2-Exercises/Python-Files/problem9.py new file mode 100644 index 0000000..f28f533 --- /dev/null +++ b/thinkcspy/Chapter-2-Exercises/Python-Files/problem9.py @@ -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, '.') \ No newline at end of file diff --git a/thinkcspy/Chapter-2-Exercises/python-files b/thinkcspy/Chapter-2-Exercises/python-files deleted file mode 100644 index e69de29..0000000 diff --git a/thinkcspy/Chapter-4-Exercises/Chapter-4-Exercises.md b/thinkcspy/Chapter-4-Exercises/Chapter-4-Exercises.md index 0733282..278eaf2 100644 --- a/thinkcspy/Chapter-4-Exercises/Chapter-4-Exercises.md +++ b/thinkcspy/Chapter-4-Exercises/Chapter-4-Exercises.md @@ -192,9 +192,9 @@ Used what I learned from problem 9 on this one. Even took the time to figure out ```text-x-python # Runestone.Academy thinkcspy course # Chapter 4 -# Problem 10 +# Problem 11 - import turtle +import turtle wn = turtle.Screen() wn.bgcolor("black") diff --git a/thinkcspy/Chapter-4-Exercises/Python-Files/problem10.py b/thinkcspy/Chapter-4-Exercises/Python-Files/problem10.py new file mode 100644 index 0000000..b6e8db8 --- /dev/null +++ b/thinkcspy/Chapter-4-Exercises/Python-Files/problem10.py @@ -0,0 +1,37 @@ +# Runestone.Academy thinkcspy course +# Chapter 4 +# Problem 10 + +import turtle +wn = turtle.Screen() + +wn.bgcolor("lightgreen") + +stella = turtle.Turtle() +stella.color("blue") +stella.shape("turtle") + +avery = turtle.Turtle() +avery.color("blue") + +stella.up() +avery.up() + +stella.stamp() + +for i in range(12): + stella.forward(100) + stella.stamp() + + avery.forward(70) + avery.down() + avery.forward(10) + avery.up() + + stella.forward(-100) + avery.forward(-80) + + stella.right(30) + avery.right(30) + +wn.exitonclick() \ No newline at end of file diff --git a/thinkcspy/Chapter-4-Exercises/Python-Files/problem11.py b/thinkcspy/Chapter-4-Exercises/Python-Files/problem11.py new file mode 100644 index 0000000..5cb8b0f --- /dev/null +++ b/thinkcspy/Chapter-4-Exercises/Python-Files/problem11.py @@ -0,0 +1,59 @@ +# Runestone.Academy thinkcspy course +# Chapter 4 +# Problem 11 + +import turtle +wn = turtle.Screen() + +wn.bgcolor("black") + +stella = turtle.Turtle() +stella.color("lightblue") +stella.speed(10) + +avery = turtle.Turtle() +avery.color("purple") +avery.speed(10) +avery.up() +avery.right(90) +avery.down() + +missy = turtle.Turtle() +missy.color("purple") +missy.speed(10) +missy.up() +missy.left(90) +missy.down() + +dun = turtle.Turtle() +dun.color("gold") +dun.speed(10) +dun.up() +dun.left(90) +dun.forward(30) +dun.right(90) +dun.down() + +for i in range(8): + stella.left(135) + stella.forward(-120) + + avery.right(45) + avery.forward(-50) + +for i in range(30, -32, -1): + missy.forward(i) + missy.left(20) + +dun.forward(120) +dun.left(120) +dun.forward(70) +for i in range(2): + dun.left(120) + dun.forward(30) + dun.right(120) + dun.forward(30) +dun.left(120) +dun.forward(70) + +wn.exitonclick() \ No newline at end of file diff --git a/thinkcspy/Chapter-4-Exercises/Python-Files/problem4.py b/thinkcspy/Chapter-4-Exercises/Python-Files/problem4.py new file mode 100644 index 0000000..c246544 --- /dev/null +++ b/thinkcspy/Chapter-4-Exercises/Python-Files/problem4.py @@ -0,0 +1,9 @@ +# Runestone.Academy thinkcspy course +# Chapter 4 +# Problem 4 + +for i in [12, 10, 32, 3, 66, 17, 42, 99, 20]: + print(i) + +for i in [12, 10, 32, 3, 66, 17, 42, 99, 20]: + print("The square of", i,"is", i**2) \ No newline at end of file diff --git a/thinkcspy/Chapter-4-Exercises/Python-Files/problem5.py b/thinkcspy/Chapter-4-Exercises/Python-Files/problem5.py new file mode 100644 index 0000000..c4f8fd5 --- /dev/null +++ b/thinkcspy/Chapter-4-Exercises/Python-Files/problem5.py @@ -0,0 +1,32 @@ +# Runestone.Academy thinkcspy course +# Chapter 4 +# Problem 5 + +import turtle +wn = turtle.Screen() +avery = turtle.Turtle() +avery.color("blue") +dun = turtle.Turtle() +dun.color("pink") +elliot = turtle.Turtle() +elliot.color("lime") +missy = turtle.Turtle() +missy.color("yellow") + +for i in range(3): + avery.forward(50) + avery.left(120) + +for i in range(4): + dun.backward(70) + dun.left(90) + +for i in range(6): + elliot.left(60) + elliot.forward(40) + +for i in range(8): + missy.right(45) + missy.backward(80) + +wn.exitonclick() \ No newline at end of file diff --git a/thinkcspy/Chapter-4-Exercises/Python-Files/problem9.py b/thinkcspy/Chapter-4-Exercises/Python-Files/problem9.py new file mode 100644 index 0000000..8700d6f --- /dev/null +++ b/thinkcspy/Chapter-4-Exercises/Python-Files/problem9.py @@ -0,0 +1,19 @@ +# Runestone.Academy thinkcspy course +# Chapter 4 +# Problem 9 + +import turtle +wn = turtle.Screen() + +stella = turtle.Turtle() +stella.color("yellow") + +stella.up() +stella.forward(-50) +stella.down() + +for i in range(5): + stella.left(144) + stella.forward(-100) + +wn.exitonclick() \ No newline at end of file