From 63719d40d593b3fa954e8c62b942d64a6b6abf7d Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 1 Nov 2017 11:56:27 -0500 Subject: [PATCH 01/31] Done with lab 01 --- Lab 01 - Calculator/lab_01_part_a.py | 11 ++++++++++- Lab 01 - Calculator/lab_01_part_b.py | 12 +++++++++++- Lab 01 - Calculator/lab_01_part_c.py | 11 ++++++++++- 3 files changed, 31 insertions(+), 3 deletions(-) diff --git a/Lab 01 - Calculator/lab_01_part_a.py b/Lab 01 - Calculator/lab_01_part_a.py index 792d600..413f9de 100644 --- a/Lab 01 - Calculator/lab_01_part_a.py +++ b/Lab 01 - Calculator/lab_01_part_a.py @@ -1 +1,10 @@ -# +#!/usr/bin/evn python3 +#lab_01_part_a.py +#Steven Thompson +#November 1st 2017 + +fahrenheit_temp = int(input("Enter temperature in Fahrenheit: ")) +celcius = (fahrenheit_temp - 32) * 5/9 +print("The temperature in Celcius", celcius) + + diff --git a/Lab 01 - Calculator/lab_01_part_b.py b/Lab 01 - Calculator/lab_01_part_b.py index 792d600..ad56b6b 100644 --- a/Lab 01 - Calculator/lab_01_part_b.py +++ b/Lab 01 - Calculator/lab_01_part_b.py @@ -1 +1,11 @@ -# +#!/usr/bin/env python3 +#lab_01_part_b.py +#Steven Thompson +#November 1st 2017 + +print("Area of a trapezoid") +height = int(input("Enter the height of the trapezoid: ")) +bottom_length = int(input("Enter the length of the bottom base: ")) +top_length = int(input("Enter the legnth of the top base: ")) +area = (1/2)*(bottom_length + top_length)*height +print(area) diff --git a/Lab 01 - Calculator/lab_01_part_c.py b/Lab 01 - Calculator/lab_01_part_c.py index 792d600..4e4b014 100644 --- a/Lab 01 - Calculator/lab_01_part_c.py +++ b/Lab 01 - Calculator/lab_01_part_c.py @@ -1 +1,10 @@ -# +#!/usr/bin/env python3 +# lab_01_part_c.py +# Steven Thompson +# November 1st 2017 + +print("Area of an ellipse") +radius_x = int(input("What is radius x: ")) +radius_y = int(input("What is radius y: ")) +area = 3.14*radius_x*radius_y +print(area) From 0cd73df4b5ae178a3f6d59401c8808b59daac5d9 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 1 Nov 2017 13:07:34 -0500 Subject: [PATCH 02/31] Finished worksheet_01 --- Worksheets/worksheet_01.odt | Bin 0 -> 16295 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Worksheets/worksheet_01.odt diff --git a/Worksheets/worksheet_01.odt b/Worksheets/worksheet_01.odt new file mode 100644 index 0000000000000000000000000000000000000000..5fcf155b3c00d07e5d4dfad84fa91dbcf9708a87 GIT binary patch literal 16295 zcmb8W1y~)~(k=`HcM0z9?(XgmK{xL1?(XjH1b4UK?(XgoBn17F^ZoP9oO5T+b8kUE zy?Xbqcdf4OUT>}1RSMFdKtBTkK>`7d!~vvrhnQf=fq;O1Z@)eQvNpFic5=5f2H4qI znHvI}%x!JxU2Kf#Yypnuj&!zm#x_Q_hR)W;HcoU-#%@ju{|3hIF8YN99SG?6hVctb z#mw2-zy@G$%)Y5D<`+l~q<&*3r>1GBUEVvT|^6@bdEdU}5LKxnd(B7!PzYnM9V2^$;^sw-Qo*$-ux8tCEUmDNP{C@_fMK0Y$< z{Hq*U<}}pNQNNy<+=7gX6CjWl$EK`oid7 zn#GiUCTJ|DAGFl0Sqb~Dy7&{ZG5%a~?|-{`VrHmtjBtvl+d5fh70!T6La|aENtD?J z(~Mos=g(T$4XJUU)O%5cpBaS($O7MT_Q3Gr*^b zP0yJ)K;YakS4%@(lK?X)L5SIkQ9Of?uo`b?2kBA>K?+`N5C98#xJu#*6v%!S)yMVDh_itej%TWKfBY=CqzR>eexxo{RHE<#Ge+X_WP;^gJ%F$=CZadGLvpa3o@ z(sHDE!V9*wlbS;nD*;2Bm@<7C^!2i()xlPpBo!?BXcW~bivz2o5Irz>JFsMRQzDf1 z9=m~^)*_Rtypw%IQ>!GX^&t7h)K5C0V_hMFvGn5A7rj==PNyZBReBJ_fxboyK15py zVTwgEmxQJ4G{tSDxKL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0500 Subject: [PATCH 03/31] Completed Lab 03 --- Lab 03 - Create a Quiz/main_program.py | 70 +++++++++++++++++++++++++- 1 file changed, 69 insertions(+), 1 deletion(-) diff --git a/Lab 03 - Create a Quiz/main_program.py b/Lab 03 - Create a Quiz/main_program.py index 792d600..f941ea7 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -1 +1,69 @@ -# +#!/usr/bin/env python3 +# main_program.py +# Steven Thompson +# November 2nd 2017 + +""" This is a quiz """ + +#These are the possible answer choices for my first multiple choice question +a = "323.1 million" +b = "256.4 million" +c = "423.2 million" + + +#These are the messages that tell the user if they got a question right or wrong +congratulations = "Correct, Great Job!" +failure = "Inccorrect, Better luck next time" + +#This is an accumulator +average = 0 + +print("This is my awesome quiz") + + +#This is the first question +print("A:",A+"\n"+"B:",B+"\n"+"C:",C+"\n") +question1 = input("What is the total population of the United States? ") +if question1 == "A" or question1 == "a": + print(congratulations) + average += 1 +else: + print(failure) + + +#This is my second question +question2 = int(input("How many movies are in the Harry Potter series? ")) +if question2 == 8: + print(congratulations) + average += 1 +else: + print(failure) + +#This is my third question +question3 = int(input("How many champions are in league of legends? ")) +if question3 == 134: + print(congratulations) + average += 1 +else: + print(failure) + +#This is my fourth question +question4 = input("What is the name of the green train in 'Thomas the Tank Engine'? ") +if question4 == "percy" or question4 == "Percy": + print(congratulations) + average += 1 +else: + print(failure) + +#This is my final question +question5 = input("What is the name of Wukong's ultimate ability in the game 'League of legends'? ") +if question5 == "Cyclone" or question5 == "cyclone": + print(congratulations) + average += 1 +else: + print(failure) + +print("Your average", average/5) + + + From 674b522fd3211d417ef2ccf8c8c26b62825233f2 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Thu, 2 Nov 2017 12:21:22 -0500 Subject: [PATCH 04/31] Completed Lab 03 --- Lab 03 - Create a Quiz/main_program.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lab 03 - Create a Quiz/main_program.py b/Lab 03 - Create a Quiz/main_program.py index f941ea7..d02d093 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -22,7 +22,7 @@ #This is the first question -print("A:",A+"\n"+"B:",B+"\n"+"C:",C+"\n") +print("A:",a+"\n"+"B:",b+"\n"+"C:",c+"\n") question1 = input("What is the total population of the United States? ") if question1 == "A" or question1 == "a": print(congratulations) @@ -63,7 +63,7 @@ else: print(failure) -print("Your average", average/5) +print("Your average is",str(average/5*100)+"%") From 5a4bc31bf5c92d792eb6d2e91c14809f1242b993 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Thu, 2 Nov 2017 12:23:42 -0500 Subject: [PATCH 05/31] Completed Lab 03 --- Lab 03 - Create a Quiz/main_program.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lab 03 - Create a Quiz/main_program.py b/Lab 03 - Create a Quiz/main_program.py index d02d093..cf98ff0 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -13,7 +13,7 @@ #These are the messages that tell the user if they got a question right or wrong congratulations = "Correct, Great Job!" -failure = "Inccorrect, Better luck next time" +failure = "Incorrect, Better luck next time" #This is an accumulator average = 0 From c57477c02d59b6c63556e0d546aca94a7de12e3b Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Fri, 3 Nov 2017 12:42:16 -0500 Subject: [PATCH 06/31] Completed worksheet_02 --- Worksheets/worksheet_02.txt | 36 +++++++++++++++++++++--------------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/Worksheets/worksheet_02.txt b/Worksheets/worksheet_02.txt index abe4cd7..add51e6 100644 --- a/Worksheets/worksheet_02.txt +++ b/Worksheets/worksheet_02.txt @@ -6,37 +6,43 @@ 1. Give an example of a binary number. (While a number such as ``1'' can be a binary, decimal, and hexadecimal number, try coming up with an example that better illustrates the differences between the different bases of numbers.) - + 1 0000 2. Give an example of a decimal number. - + 13 3. Give an example of a hexadecimal number. - + F 4. Convert the numbers 1, 10, 100, 1000, and 10000 from binary to decimal. - + 1 2 4 8 16 5. What is a compiler? - + A compiler takes the code typed in by the user and turns it into machine code. 6. What is source code? - + source code is code that is typed in by the user 7. What is machine language? (Don't just say binary. That's not correct.) - + Machine lanauge are the binary numbers representing instructions that the computer interprets 8. What is a first generation language? (Don't just say binary. That's not correct.) - + The system of only using ones and zeros to represent numbers. This is also called the binary number system 9. What is a second generation language? - + each command used a mnemonic, and a program called a compiler would change the mnemonics into the numbers that represented the commands. This is also called assembly language 10. What is a third generation language? (Explain, don't just give one example.) - + Third generation languages made it a lot easier to program and allowed for higher-level abstractions. 11. What is an interpreter and how does it differ from a compiler? - + interpreters are programs that look at source code and interpret it to machine language instructions on the fly. These can work on any type of machine, while a while that is configured on a Windows computer would not work on Apple or Linux computers. 12. Search the web and find some of the most popular programming languages. List the website(s) you got the information from and what the languages are. - + java, python, C, Ruby, JavaScript, C#, PHP, Objective-C, SQL. + https://www.inc.com/larry-kim/10-most-popular-programming-languages-today.html 13. Look at the job boards and see what languages people are looking for. List the languages and the job board you looked at. - + SQL, java, JavaScript, C#, C++, Python, PHP, Ruby on Rails, IOS/Swift + http://www.codingdojo.com/blog/9-most-in-demand-programming-languages-of-2016/ 14. What is the difference between the ``syntax'' and ``semantics'' of a language? - + Syntax refers to the strcture or form of the code that a programming langauge specifices but Semantics deal with the meaning assigned to the symbols, characters and words. 15. Pick a piece of technology, other than a computer you use regularly. Briefly describe the hardware and software that run on it. - + My phone. It is a Samsung Galaxy J7 Prime. + It runs on Android 7.0 Nougat + Has a 13 megapixel camera in the back and an 8 megapixel camera in the front. + it has a 1080 x 1920 pixel display + and it runs off a Samsung exynos 7 Octa core processor. From c873a47d3bae90cf1d2dcd9c20581862cb467bf7 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Fri, 3 Nov 2017 12:43:55 -0500 Subject: [PATCH 07/31] Completed Lab 04 --- Lab 04 - Camel/main_program.py | 129 +++++++++++++++++++++++++++++++++ 1 file changed, 129 insertions(+) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index 792d600..4878518 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -1 +1,130 @@ # +import random + +print("Welcome to Camel!") +print("You have stolen a camel to make your way across the great Mobi desert.") +print("The natives want their camel back and are chasing you down!" "\n" "Survive your desert trek and out run the natives.") + +total_miles_traveled = 0 +miles_traveled = 0 +thirst = 0 +camel_tiredness = 0 +drinks_in_canteen = 3 +native_location = -20 + +done = False + +while done == False: + print("A. Drink from your canteen.") + print("B. Ahead moderate speed.") + print("C. Ahead full speed.") + print("D. Stop for the night.") + print("E. Status check.") + print("Q. Quit.") + + user_choice = input("Your choice? ") + if user_choice.upper() == "Q": + done = True + + + elif user_choice.upper() == "E": + print("Miles Traveled:", total_miles_traveled) + print("Drinks in canteen:", drinks_in_canteen) + print("The natives are", native_location*(-1), "miles behind you.") + print("Camel tiredness:", camel_tiredness) + print("Thirst", thirst) + + + elif user_choice.upper() == "D": + camel_tiredness = 0 + print("The camel is happy") + native_location += random.randint(7, 14) + if native_location >= 0: + print("The natives have caught you") + done = True + if -10 <= native_location <= -15: + print("The natives are getting close!") + if -8 <= native_location <= -2: + print("The natives are getting really close!") + + + elif user_choice.upper() == "C": + miles_traveled += random.randint(10,20) + print("You traveled",miles_traveled,"miles") + total_miles_traveled += miles_traveled + native_location += random.randint(7,14) - miles_traveled + miles_traveled = 0 + thirst += 2 + camel_tiredness += 2 + if 4<= thirst <= 6: + print("You are thirsty.") + if thirst > 6: + print("You died of thirst!") + done = True + if 5<= camel_tiredness >=8: + print("Your camel is getting tired.") + if camel_tiredness > 8: + print("Your camel is dead.") + done = True + if miles_traveled >= 200: + print("You have won! Good Job") + done = True + if native_location >= 0: + print("The natives have caught you") + done = True + if 10 <= native_location <= 15: + print("The natives are getting close!") + if 8 <= native_location <= 2: + print("The natives are getting really close!") + oasis = random.randint(1,20) + lucky_oasis_number = 5 + if oasis == lucky_oasis_number: + print("You found the oasis") + thirst = 0 + camel_tiredness = 0 + drinks_in_canteen = 4 + + + elif user_choice.upper() == "B": + miles_traveled += random.randint(5,12) + print("You traveled",miles_traveled,"miles.") + total_miles_traveled += miles_traveled + native_location += random.randint(7,14) - miles_traveled + miles_traveled = 0 + thirst += 1 + camel_tiredness += 1 + if 4<= thirst <= 6: + print("You are thirsty.") + if thirst > 6: + print("You died of thirst!") + done = True + if 5<= camel_tiredness >=8: + print("Your camel is getting tired.") + if camel_tiredness > 8: + print("Your camel is dead.") + done = True + if miles_traveled >= 200: + print("You have won! Good Job") + dont = True + if native_location >= 0: + print("The natives have caught you") + done = True + if 10 <= native_location <= 15: + print("The natives are getting close!") + if 5 <= native_location <= 2: + print("The natives are getting really close!") + oasis = random.randint(1,20) + lucky_oasis_number = 5 + if oasis == lucky_oasis_number: + print("You found the oasis") + thirst = 0 + camel_tiredness = 0 + drinks_in_canteen = 4 + + elif user_choice.upper() == "A": + if drinks_in_canteen > 0: + drinks_in_canteen = drinks_in_canteen - 1 + thirst = 0 + print("You have", drinks_in_canteen, "drinks left.") + else: + print("You're out of water") From b5d188ee3c51336bfb9463e9d2650c42e009e046 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Fri, 3 Nov 2017 13:18:05 -0500 Subject: [PATCH 08/31] Added comments to Lab 04 --- Lab 04 - Camel/main_program.py | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index 4878518..981ec3c 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -1,10 +1,18 @@ -# +#!/usr/bin/env python3 +# main_program.py +# Steven Thompson +# November 3rd 2017 + +""" This is a game about making your way across the desert on a stolen camel while trying to outrun the natives""" + + import random print("Welcome to Camel!") print("You have stolen a camel to make your way across the great Mobi desert.") print("The natives want their camel back and are chasing you down!" "\n" "Survive your desert trek and out run the natives.") +#These variables are the base mechanics of the game. total_miles_traveled = 0 miles_traveled = 0 thirst = 0 @@ -12,21 +20,24 @@ drinks_in_canteen = 3 native_location = -20 +#This is what keeps the game going. If it gets set to true, then the game ends. done = False while done == False: +#these are possible choices for your character print("A. Drink from your canteen.") print("B. Ahead moderate speed.") print("C. Ahead full speed.") print("D. Stop for the night.") print("E. Status check.") print("Q. Quit.") - +#this line allows you to select a choice from above. user_choice = input("Your choice? ") - if user_choice.upper() == "Q": + #If you select Q then the game ends. + if user_choice.upper() == "Q": done = True - +#If You select E then it will show you all the necessary stats to get you across the desert safely elif user_choice.upper() == "E": print("Miles Traveled:", total_miles_traveled) print("Drinks in canteen:", drinks_in_canteen) @@ -34,7 +45,7 @@ print("Camel tiredness:", camel_tiredness) print("Thirst", thirst) - +#If you select D then the tiredness of your camel is reset and the natives move in closer on your location elif user_choice.upper() == "D": camel_tiredness = 0 print("The camel is happy") @@ -47,7 +58,7 @@ if -8 <= native_location <= -2: print("The natives are getting really close!") - +#If you select C then you will move a random integer between 10 and 20 forward and there is also a 1 in 20 chance of finding an oasis elif user_choice.upper() == "C": miles_traveled += random.randint(10,20) print("You traveled",miles_traveled,"miles") @@ -84,7 +95,7 @@ camel_tiredness = 0 drinks_in_canteen = 4 - +#If you select B then you will move forward a random integer between 5 and 12. This also has a 1 in 20 chance of finding an oasis elif user_choice.upper() == "B": miles_traveled += random.randint(5,12) print("You traveled",miles_traveled,"miles.") @@ -121,6 +132,7 @@ camel_tiredness = 0 drinks_in_canteen = 4 +#if you select A then you will take a drink from your canteen elif user_choice.upper() == "A": if drinks_in_canteen > 0: drinks_in_canteen = drinks_in_canteen - 1 From b83612befb2f79b1a8b1efd0fea10f8f50605fed Mon Sep 17 00:00:00 2001 From: sthomp123 Date: Fri, 3 Nov 2017 18:10:47 -0500 Subject: [PATCH 09/31] Completed Worksheet 03 --- Worksheets/worksheet_03.txt | 67 ++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 15 deletions(-) diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index bc85b84..2a3abd3 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -4,7 +4,7 @@ 1. What is missing from this code? (1 pt) - + This code is missing a second parentheses after the temperature input temperature = float(input("Temperature: ") if temperature > 90: print("It is hot outside.") @@ -14,12 +14,21 @@ 2. Write a Python program that will take in a number from the user and print if it is positive, negative, or zero. Use a proper if/elif/else chain, don't just use three if statements. - + number = input("Enter a number: ") + if number > 0: + print("This number is positive") + elif number < 0: + print("This number is negative") + else: + print("This number is zero") 3. Write a Python program that will take in a number from a user and print out ``Success'' if it is greater than -10 and less than 10, inclusive. (1 pt) + number = input("Enter a number") + if -10 <= number <= 10: + print("Success") 4. This runs, but there is something wrong. What is it? (1 pt) - + You get asked for the input before you see the options. user_input = input("A cherry is a: ") print("A. Dessert topping") print("B. Desert topping") @@ -27,12 +36,23 @@ print("Correct!") else: print("Incorrect.") - - 5. There are two things wrong with this code that tests if x is set to a + C O R R E C T E D + print("A. Dessert topping") + print("B. Desert topping") + user_input = input("A cherry is a: ") + if user_input.upper() == "A": + print("Correct!") + else: + print("Incorrect.") + + + + 5. There are two things wrong with this code that tests if x is set to a positive value. One prevents it from running, and the other is subtle. Make sure the if statement works no matter what x is set to. Identify both issues. (2 pts) - + 1: there is a == when assigning x + 2: X will always be equal to 4. If you want to change what x is set to then you can use an input() statenent. x == 4 if x >= 0: print("x is positive.") @@ -40,21 +60,29 @@ print("x is not positive.") 6. What three things are wrong with the following code? (3 pts) - + 1. use a double == in the if statement. + 2. you want to use int(input() when trying to enter numbers + 3. There is no colon in the if statement. x = input("Enter a number: ") if x = 3 - print("You entered 3") + print("You entered 3") 7. There are four things wrong with this code. Identify all four issues. (4 pts) - answer = input("What is the name of Dr. Bunsen Honeydew's assistant? ") + 1. There is no double == in the if statement. + 2. Else statement is indented. + 3. else statement has no colon. + 4. the print statement inside the else statement has no indention. + + answer = input("What is the name of Dr. Bunsen Honeydew's assistant? ") if a = "Beaker": print("Correct!") else print("Incorrect! It is Beaker.") 8. This program doesn't work correctly. What is wrong? (1 pt) - + You to write it as: if x == "Happy" or x == "Glad": + x = input("How are you today?") if x == "Happy" or "Glad": print("That is good to hear!") @@ -67,7 +95,10 @@ While you don't need to write an explanation, make sure you understand why the computer prints what it does. Don't get caught flat-footed when you need to know later. (2 pts) - + My guess: buzz will be printed. + The answer: buzz was printed. + This is because x gets assigned the value 5, the new variables are checking if they are equal to 5. This is why "y" was returned as False + while "z" was returned as True. x = 5 y = x == 6 z = x == 5 @@ -81,7 +112,8 @@ 10. Look at the code below. Write you best guess on what it will print. Next, run the code and see if you are correct. (2 pts) - + My guess: I think it will print numbers in the print statements that correct. If they are incorrect I think it will error. + Correct asnwer: It did not print numbers and it did not error. Instead it gave me True and False answers. x = 5 y = 10 z = 10 @@ -99,7 +131,10 @@ 11. Look at the code below. Write you best guess on what it will print. Next, run the code and see if you are correct. (2 pts) - + My guess: This will give me true and false answers. + Correct Answer: After fixing the error, it gave me true and false answers. + ERROR: The first time I ran it I got a typerror for the line "print(3 < "3")" + I got this error because it is checking if an integer is less than a string. print("3" == "3") print(" 3" == "3") print(3 < 4) @@ -114,7 +149,9 @@ 12. What things are wrong with this section of code? The programmer wants to set the money variable according to the initial occupation the user selects. (1 pt) - + + They need to use == in the if statements + They could also shorten the else if statements by just using elif. print("Welcome to Oregon Trail!") print("A. Banker") @@ -129,7 +166,7 @@ money = 70 else if user_input = C: money = 50 - + From 1b4d276f5915a3e47e10d06d94cb272326f799ae Mon Sep 17 00:00:00 2001 From: sthomp123 Date: Fri, 3 Nov 2017 21:38:35 -0500 Subject: [PATCH 10/31] Completed Worksheet 04 --- Worksheets/worksheet_04.txt | 92 +++++++++++++++++++++++++++++++++++-- 1 file changed, 87 insertions(+), 5 deletions(-) diff --git a/Worksheets/worksheet_04.txt b/Worksheets/worksheet_04.txt index 341b2fa..3355a88 100644 --- a/Worksheets/worksheet_04.txt +++ b/Worksheets/worksheet_04.txt @@ -14,19 +14,40 @@ 1. Write a Python program that will use a for loop to print your name 10 times, and then the word ``Done'' at the end. +for name in range(1,11): + print("Steven Thompson") +print("Done") + + + 2. Write a Python program that will use a for loop to print ``Red'' and then ``Gold'' 20 times. (Red Gold Red Gold Red Gold... all on separate lines. Don't use \n.) + for word in range(1,21): + print("red gold") + + 3. Write a Python program that will use a for loop to print the even numbers from 2 to 100, inclusive. + for even in range(2,101,2) + print("even") + 4. Write a Python program that will use a while loop to count from 10 down to, and including, 0. Then print the words ``Blast off!'' Remember, use a WHILE loop, don't use a FOR loop. + number = 11 + while number != 0: + number = number -1 + print(number) + print("Blast off!") + 5. There are three things wrong with this program. List each. (3 pts) - + 1. x needs to = int(input()) + 2. you want to make the total += to x, not i. + 3. The print statement should print the total, not "x" print("This program takes three numbers and returns the sum.") total = 0 @@ -37,25 +58,66 @@ 6. Write a program that prints a random integer from 1 to 10 (inclusive). + import random + print(random.randint(1,10)) + 7. Write a program that prints a random floating point number somewhere between 1 and 10 (inclusive). Do not make the mistake of generating a random number from 0 to 10 instead of 1 to 10. + import random + number = random.randint(1,10) + print(float(number)) + 8. Write a Python program that will: (3 pts) - * Ask the user for seven numbers * Print the total sum of the numbers * Print the count of the positive entries, the number entries equal to zero, and the number of negative entries. Use an if, elif, else chain, not just three if statements. - 9. Coin flip tosser: (4 pts) - +total = 0 +count_positive = 0 +count_negative = 0 +zero = 0 + +for i in range(7): + numbers = int(input("Enter your number: ")) + total += numbers + if numbers <= -1: + count_negative += 1 + elif numbers >= 1: + count_positive += 1 + else: + zero += 1 +print("amount of negative numbers:", str(count_negative)) +print("amount of positive numbers:", str(count_positive)) +print("amount of times zero was entered:", str(zero)) +print("The sum of the numbers:", total) + + + + 9. Coin flip tosser: (4 pts) * Create a program that will print a random 0 or 1. * Instead of 0 or 1, print heads or tails. Do this using if statements. Don't select from a list, as shown in the chapter. * Add a loop so that the program does this 50 times. * Create a running total for the number of heads flipped, and the number of tails. + +import random +total_heads = 0 +total_tails = 0 +for i in range(50): + random_number = random.randint(0,1) + if random_number == 1: + total_heads += 1 + print("heads") + elif random_number == 0: + total_tails += 1 + print("tails") +print("Amount of times heads was flipped:", total_heads) +print("Amount of times tails was flipped:", total_tails) + 10. Write a program that plays rock, paper, scissors: (4 pts) @@ -65,5 +127,25 @@ * Add to the program so it first asks the user their choice. * (It will be easier if you have them enter 1, 2, or 3.) * Add conditional statement to figure out who wins. - + +import random +random_number = random.randint(0,2) +print("Press 0 to select rock") +print("Press 1 to select paper") +print("press 2 to select scissors") +user_choice = int(input("Make your choice: ")) +if user_choice == 0 and random_number == 2: + print("The computer has chosen scissors. You Win!") +elif user_choice == 0 and random_number == 1: + print("The computer has chosen paper. You lose :(") +elif user_choice == 1 and random_number == 0: + print("The computer has chosen rock. You Win!") +elif user_choice == 1 and random_number == 2: + print("The computer has chosen scissors. You lose :(") +elif user_choice == 2 and random_number == 1: + print("The computer has chosen paper. You Win!") +elif user_choice == 2 and random_number == 0: + print("The computer has chosen rock. You lose :(") +elif user_choice == random_number: + print("It's a draw, the computer has picked the same thing as you.") From 3f3047c031a2595b360a7ffea57a88beeb31a8f5 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Mon, 6 Nov 2017 11:02:17 -0600 Subject: [PATCH 11/31] Work on worksheet 03 --- Worksheets/worksheet_03.txt | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index bc85b84..0bca0a6 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -10,13 +10,25 @@ print("It is hot outside.") else: print("It is not hot out.") + This code is missing a second parentheses to close float() 2. Write a Python program that will take in a number from the user and print if it is positive, negative, or zero. Use a proper if/elif/else chain, don't just use three if statements. + number = int(input("Enter a number: ")) + if number > 0: + print("This number is positive") + elif number < 0: + print("this number is negative") + else: + print("this number is zero") + 3. Write a Python program that will take in a number from a user and print out ``Success'' if it is greater than -10 and less than 10, inclusive. (1 pt) + number = int(input("Enter a number: ")) + if -10 <= number <= 10: + print("Success") 4. This runs, but there is something wrong. What is it? (1 pt) @@ -27,12 +39,23 @@ print("Correct!") else: print("Incorrect.") + You have to put your guess in before you even see the choices. + print("A. Dessert topping") + print("B. Desert topping") + user_input = input("A cherry is a: ") + if user_input.upper() == "A": + print("Correct!") + else: + print("Incorrect.") + This is the corrected code. + 5. There are two things wrong with this code that tests if x is set to a positive value. One prevents it from running, and the other is subtle. Make sure the if statement works no matter what x is set to. Identify both issues. (2 pts) - + issue number 1: x needs to have one = sign, not two. + issue number 2: x == 4 if x >= 0: print("x is positive.") From 4f3d72d7fa4b4006b2aa76fb71e6a58ef86f30a8 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Mon, 6 Nov 2017 12:06:23 -0600 Subject: [PATCH 12/31] Finished chapter 5 worksheet --- Worksheets/worksheet_05.txt | 73 +++++++++++++++++++++++++++++-------- 1 file changed, 57 insertions(+), 16 deletions(-) diff --git a/Worksheets/worksheet_05.txt b/Worksheets/worksheet_05.txt index 275a18a..c538d59 100644 --- a/Worksheets/worksheet_05.txt +++ b/Worksheets/worksheet_05.txt @@ -6,64 +6,105 @@ where appropriate. 1. Explain how the computer coordinate system differs from the standard Cartesian - coordinate system. There are two main differences. List both. - + coordinate system. There are two main differences. List both. + + 1. The y coordinates are reversed. Rather than the zero y coordinate at the bottom of the graph like in cartesian graphics, the zero y coordinate is at the top of the screen with the computer. + 2. The screen covers the lower right quadrant, where the Cartesian coordinate system usually focuses on the upper right quadrant. You can still draw negative coordinates, but they will be drawn off screen. + 2. Before a Python Pygame program can use any functions like pygame.display.set_mode(), what two lines of code must occur first? - - 3. Explain how WHITE = (255, 255, 255) represents a color. + + import pygame + pygame.init() + + 3.Explain how WHITE = (255, 255, 255) represents a color. + + Each element of the RGB triad is a number ranging from 0 to 255. Zero means there is none of the color, and 255 tells the monitor to display as much of the color as possible. If all of the channels are set the their highest value, then it represents the color white. 4. When do we use variable names for colors in all upper-case, and when do we use variable names for colors in all lower-case? (This applies to all variables, not just colors.) - + + You put variables in upper-case if they are fixed variables. + 5. What does the pygame.display.set_mode() function do? - + + it opens and sets the window size. + 6. What does this for event in pygame.event.get() loop do? + + It signals that the user did something. 7. What is pygame.time.Clock used for? - + + It is used to manage how fast the screen updates + 8. For this line of code: (3 pts) pygame.draw.line(screen, GREEN, [0, 0], [100, 100], 5) * What does screen do? - * What does [0, 0] do? + screen is assigned to pygame.display.set_mode(size) which would open the window in the size that it is assigned to. + * What does [0, 0] do? + It is the starting point of the line. * What does [100, 100] do? + It is the end point of the line. * What does 5 do? + This sets the width of the line. 9. What is the best way to repeat something over and over in a drawing? + + A for loop is the easiest way to do it. 10. When drawing a rectangle, what happens if the specified line width is zero? - + + If the line width is 0, then there will not be a border around the rectangle. Instead it will be filled in with the color specified. + 11. Describe the ellipse drawn in the code below. * What is the x, y of the origin coordinate? + (20,20) * What does the origin coordinate specify? The center of the circle? + It specifies the upper left of a rectangle that contains the ellipse. * What is the length and the width of the ellipse? - + The ellipse is 250 pixels wide and 100 wixels tall. pygame.draw.ellipse(screen, BLACK, [20, 20, 250, 100], 2) 12. When drawing an arc, what additional information is needed over drawing an ellipse? - + + An arc includes start and end angles. + 13. Describe, in general, what are the three steps needed when printing text to - the screen using graphics? - + the screen using graphics? + + 1. The program needs to create a variables that holds information about the font to be used. + 2. The program creates an image of the text. + 3. The program tells where this image of the text should be stamped to the screen. + 14. When drawing text, the first line of the three lines needed to draw text should actually be outside the main program loop. It should only run once at - the start of the program. Why is this? You may need to ask. + the start of the program. Why is this? You may need to ask. + The first line sets the font of the text. You don't need to keep running that inside of a for loop. + 15. What are the coordinates of the polygon that the code below draws? + (50, 100), (0, 200), (200,200), (100,50) pygame.draw.polygon(screen, BLACK, [[50,100],[0,200],[200,200],[100,50]], 5) 16. What does pygame.display.flip() do? - + + This updates what was drawn to the screen. + 17. What does pygame.quit() do? - + + exits the pygame engine. + 18. Look up on-line how the pygame.draw.circle works. Get it working and paste a working sample here. I only need the one line of code that draws the circle, but make sure it is working by trying it out in a full working program. + pygame.draw.circle(screen, BLACK, (300, 50), 50, 1) + From b75a09e46d41262828d88faba4a620c22df96cdf Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Mon, 6 Nov 2017 13:01:34 -0600 Subject: [PATCH 13/31] Fixed some bugs with lab 04 --- Lab 04 - Camel/main_program.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index 981ec3c..8193c24 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -77,15 +77,15 @@ if camel_tiredness > 8: print("Your camel is dead.") done = True - if miles_traveled >= 200: + if total_miles_traveled >= 200: print("You have won! Good Job") done = True if native_location >= 0: print("The natives have caught you") done = True - if 10 <= native_location <= 15: + if -10 <= native_location <= -15: print("The natives are getting close!") - if 8 <= native_location <= 2: + if -8 <= native_location <= -2: print("The natives are getting really close!") oasis = random.randint(1,20) lucky_oasis_number = 5 @@ -114,15 +114,15 @@ if camel_tiredness > 8: print("Your camel is dead.") done = True - if miles_traveled >= 200: + if total_miles_traveled >= 200: print("You have won! Good Job") - dont = True + done = True if native_location >= 0: print("The natives have caught you") done = True - if 10 <= native_location <= 15: + if -10 <= native_location <= -15: print("The natives are getting close!") - if 5 <= native_location <= 2: + if -5 <= native_location <= -2: print("The natives are getting really close!") oasis = random.randint(1,20) lucky_oasis_number = 5 From 28dd89a2e3647ec4f5660102c23a66ead1fb2041 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 8 Nov 2017 12:28:54 -0600 Subject: [PATCH 14/31] Completed Lab 05 --- Lab 05 - Create a Picture/main_program.py | 98 ++++++++++++++++++++++- 1 file changed, 97 insertions(+), 1 deletion(-) diff --git a/Lab 05 - Create a Picture/main_program.py b/Lab 05 - Create a Picture/main_program.py index 792d600..19e3b4f 100644 --- a/Lab 05 - Create a Picture/main_program.py +++ b/Lab 05 - Create a Picture/main_program.py @@ -1 +1,97 @@ -# +#!/usr/bin/env python3 +# main_program.py +# Steven Thompson +# November 6 2017 + +""" This program draws a house in the dark """ + +import pygame +import random + +# Define some colors +BLACK = (0, 0, 0) +WHITE = (255, 255, 255) +GREEN = (0, 255, 0) +RED = (255, 0, 0) +DARK_BLUE = (13, 7, 124) +GROUND_GREEN = (14,104,16) +BRICK = (132, 67, 54) +CHIMNEY = (124, 25, 1) +GRAY = (124, 122, 122) + +pygame.init() + +# Set the width and height of the screen [width, height] +size = (700, 500) +screen = pygame.display.set_mode(size) + +pygame.display.set_caption("My picture") + +# Loop until the user clicks the close button. +done = False + +# Used to manage how fast the screen updates +clock = pygame.time.Clock() + +# -------- Main Program Loop ----------- +while not done: + # --- Main event loop + for event in pygame.event.get(): + if event.type == pygame.QUIT: + done = True + + + + screen.fill(WHITE) + + + + #This draws the ground and the sky + pygame.draw.rect(screen, GROUND_GREEN,[0,0,700,500]) + pygame.draw.rect(screen, DARK_BLUE,[0,0,700,250]) + + + #This draws the sun + pygame.draw.circle(screen, WHITE, (650, 60), 40, 0) + + + #This draws the snow around the house + for snow_y in range(500): + snow_x = random.randint(1,700) + pygame.draw.circle(screen, WHITE,(snow_x,snow_y), 1,0) + + + #This draws the house + pygame.draw.rect(screen, BRICK, [200,100, 200, 150],0) + + #This draws the first window to the house + pygame.draw.rect(screen, BLACK, [220, 125, 50, 50], 0) + + #This draws the second window to the house + pygame.draw.rect(screen, BLACK, [320, 125, 50, 50], 0) + + #This draws the door to the house + pygame.draw.rect(screen, BLACK, [270, 200, 50, 50], 0) + + + #This draws the smoke for the chimney + for smoke_y in range(0,51): + smoke_x = random.randint(355,370) + pygame.draw.circle(screen, GRAY, (smoke_x,smoke_y), 10, 0) + #This draws the chimney + pygame.draw.rect(screen, CHIMNEY, [350,50, 25, 50], 0) + + + #This draws the roof of my house + pygame.draw.polygon(screen, BLACK, [[300,25], [200,100], [400,100]],0) + + + + #Updates the screen with what is drawn + pygame.display.flip() + + #limits framerate to 60 + clock.tick(60) + +# Close the window and quit. +pygame.quit() From fd0a9a9512a6cc1c88e892e06c5152959561091f Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Mon, 13 Nov 2017 11:03:01 -0600 Subject: [PATCH 15/31] Completed Chapter 2 lab --- .../Chapter 2 report on video.docx | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Lab 02 - Computer History/Chapter 2 report on video.docx b/Lab 02 - Computer History/Chapter 2 report on video.docx index c4ed613..ef8d433 100644 --- a/Lab 02 - Computer History/Chapter 2 report on video.docx +++ b/Lab 02 - Computer History/Chapter 2 report on video.docx @@ -1 +1,10 @@ -Report goes here +Steven Thompson +November 12th 2017 + +The history of computers + +I watched part 3 of the Triumph of the Nerds documentary. It starts out talking about the release of Windows 95, and how the exploitation of opportunities allowed microsoft to make Bill Gates the “master of the gui universe”, but most of the ideas that came in Windows 95 were thought of over two decades ago inside of a think tank in Palo Alto that was started by Xerox.They called it PARC. It was said that out of the top 100 computer researchers in the world that 58 of them worked at PARC. That was confusing because PARC only had 50 researchers. These researchers had everything that they wanted. There was complete intellectual freedom and everyone was challenging ideas. Back in 1973, these people built a personal computer that they called the “Alto” it was never for sale and cost around $10000 to create, but if it was never built, we probably wouldn’t have windows or macintosh computers. The Alto was considered “Friendly and intuitive” it had the first gui that used a mouse to get information from the screen, it linked to other computers using ethernet, and it printed everything that was on the screen straight to a laser printer. Sadly, the researchers are PARC were unable to persuade Xerox that what they had made was the future. There was a huge mismatch between what the researchers were doing and what the managers were doing. The managers didn’t understand the vision that was getting created so there was nobody able to receive that vision. + +Steve Jobs toured the Xerox PARC facility in December of 1979. He said that they showed him three things but he didn’t pay attention to anything except for the first one. He was blindsided by the graphical user interface that was shown to him. It was obvious to him that all computers would run off of a gui in the future. A gui allowed a computer to be easy for anyone to use. Steve Jobs understood what the gui meant after seeing it for just a mere hour. The PARC researchers had been showing the executives their interface for years but they just didn’t get it. Steve Jobs persuaded the Apple board to invest in technology that copied what he had seen had Xerox PARC. They started building a new computer and codenamed it “Lisa”, but Lisa got too expensive and it didn’t work properly. + +The computer industry has changed drastically since this documentary was created. Graphical User Interfaces are everywhere nowadays. Steve Jobs was right about his prediction. Almost everything we do that involves technology uses a gui. The computer industry is the third largest industry in the world and it’s growing larger everyday. We are nearing a point where cars can drive themselves and we may only be a decade or two away from robots that are smarter than humans. From 98f62e3a9b7495f4774b51920bc8452241ec10b0 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Tue, 14 Nov 2017 13:39:18 -0600 Subject: [PATCH 16/31] Problems 1 - 4 worksheet6 --- Worksheets/worksheet_06.txt | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index 35e5f13..de1ad2f 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -13,27 +13,30 @@ 1. What does this program print out? (Remember: TWO answers. Your guess and the actual result. Label both.) + Guess: it is going to keep printing 0 on separate lines and never stop. + Answer: it printed 0,2,4,6,8 on separate lines and stopped but didn't print 10. I didn't see that x was reassigned at first. x = 0 while x < 10: print(x) x = x + 2 2. What does this program print out? - + Guess: It will print 1,2,4,8,16,32 on separate lines. + Answer: It will print 1,2,4,8,16,32 on separate lines. x = 1 while x < 64: print(x) x = x * 2 3. Why is the and x >= 0 not needed? - + This loop will never go below 0 so that makes it unnecessary to have a check for it going below 0. x = 0 while x < 10 and x >= 0: print(x) x = x + 2 4. What does this program print out? (0 pts) Explain. (1 pt) - + It prints out 5,4,3,2,1,0 but never prints "Blast off!" because the if statement checks if 1 is a string. x = 5 while x >= 0: print(x) From 15e2e07bbd47c091733e90ef733d2773e901b3f3 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 15 Nov 2017 11:52:46 -0600 Subject: [PATCH 17/31] Completed questions 5 - 8 --- Worksheets/worksheet_06.txt | 44 ++++++++++++++++++------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index de1ad2f..55842dc 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -51,41 +51,41 @@ while x <= 0: print("Too small. Enter a number greater than zero: ") + x = float(input("Enter a number greater than zero: ")) 6. Fix the following code: x = 10 - while x < 0: + while x > 0: print(x) - x - 1 + x -= 1 print("Blast-off") 7. What is wrong with this code? It runs but it has unnecessary code. Find all the unneeded code. Also, answer why it is not needed. (1 pt) - i = 0 for i in range(10): print(i) - i += 1 - + The for loop sets i as a variable already so defining it outside of the for loop is pointless. + 8. Explain why the values printed for x are so different. (2 pts) - - # Sample 1 - x = 0 - for i in range(10): - x += 1 - for j in range(10): - x += 1 - print(x) + + # Sample 1 + x = 0 + for i in range(10): + x += 1 + for j in range(10): + x += 1 + print(x) - # Sample 2 - x = 0 - for i in range(10): - x += 1 - for j in range(10): - x += 1 - print(x) - - + # Sample 2 + x = 0 + for i in range(10): + x += 1 + for j in range(10): + x += 1 + print(x) + + The printed values are different because in the second sample the for loop is nested. This causes it to run through every number between 10, 9 times. Whereas, since sample 1 does not have nested for loops, it just counts the numbers in the range of 10 twice and adds them together. From aaba1aa7f2eb214d7768d3eefb942802201ff129 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 15 Nov 2017 12:15:45 -0600 Subject: [PATCH 18/31] Completed lab part_1 --- Lab 06 - Loopy Lab/part_1.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index 8b13789..378d152 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -1 +1,13 @@ +#!/usr/bin/env python3 +# part_1.py +#Steven Thompson +#November 15th 2017 +""" This program prints a triangle made out of numbers """ + +number = 9 +for i in range(number+1): + for j in range(i): + number += 1 + print(number, end= " ") + print() From df7a0ece73e53303e163ab2bf533ffc9019bfb77 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 15 Nov 2017 12:25:45 -0600 Subject: [PATCH 19/31] Made loop that draws the top line --- Lab 06 - Loopy Lab/part_2.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 792d600..4e8a41f 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -1 +1,13 @@ -# +#!/usr/bin/env python3 +# part_2.py +# Steven Thompson +# November 15th 2017 + +""" This program makes a boxes of 'o's based on user input """ + + +n = int(input("Enter a number: ")) +for i in range(n*2): + print("o", end = "") +print() + From 8d5e22c62861a5c198f8553048b33b632aec9c6c Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 15 Nov 2017 12:31:23 -0600 Subject: [PATCH 20/31] Made loop that draws the bottom line and line on side --- Lab 06 - Loopy Lab/part_2.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 4e8a41f..2bd3694 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -8,6 +8,13 @@ n = int(input("Enter a number: ")) for i in range(n*2): - print("o", end = "") + print("o", end= "") +print() +for k in range(1,n-1): + print("o") + +for j in range(n*2): + print("o", end= "") + print() From dd890b02b759b14a67661dc94966402b59382594 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 15 Nov 2017 12:50:10 -0600 Subject: [PATCH 21/31] Made final loop for spaces and completed the part --- Lab 06 - Loopy Lab/part_2.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 2bd3694..fcc131b 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -10,9 +10,11 @@ for i in range(n*2): print("o", end= "") print() + for k in range(1,n-1): - print("o") + print("o", (n-2)*" ", "o") + for j in range(n*2): print("o", end= "") From 193d139fefd3d627fa901240e4fa27c287d822be Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Thu, 16 Nov 2017 11:08:24 -0600 Subject: [PATCH 22/31] Pasted the given pygame template. --- Lab 06 - Loopy Lab/part_4.py | 72 +++++++++++++++++++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index 792d600..87bc2b3 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -1 +1,71 @@ -# +#!/usr/bin/env python3 +#part_4.py +#Steven Thompson +#November 15th 2017 + +""" Makes a pattern of circles across a pygame window """ + + +""" + Pygame base template for opening a window + + Sample Python/Pygame Programs + Simpson College Computer Science + http://programarcadegames.com/ + http://simpson.edu/computer-science/ + + Explanation video: http://youtu.be/vRB_983kUMc +""" +import random +import pygame + +# Define some colors +BLACK = (0, 0, 0) +WHITE = (255, 255, 255) +GREEN = (0, 255, 0) +RED = (255, 0, 0) + + +pygame.init() + +# Set the width and height of the screen [width, height] +size = (700, 500) +screen = pygame.display.set_mode(size) + +pygame.display.set_caption("My Grid") + +# Loop until the user clicks the close button. +done = False + +# Used to manage how fast the screen updates +clock = pygame.time.Clock() + +# -------- Main Program Loop ----------- +while not done: + # --- Main event loop + for event in pygame.event.get(): + if event.type == pygame.QUIT: + done = True + + # --- Game logic should go here + + # --- Screen-clearing code goes here + + # Here, we clear the screen to white. Don't put other drawing commands + # above this, or they will be erased with this command. + + # If you want a background image, replace this clear with blit'ing the + # background image. + screen.fill(WHITE) + + # --- Drawing code should go here + + + # --- Go ahead and update the screen with what we've drawn. + pygame.display.flip() + + # --- Limit to 60 frames per second + clock.tick(60) + +# Close the window and quit. +pygame.quit() From f1fa859bf5e34a22c421f543ee581f67c90b6551 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Thu, 16 Nov 2017 11:21:29 -0600 Subject: [PATCH 23/31] Added comments --- Lab 06 - Loopy Lab/part_2.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index fcc131b..3a6f704 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -7,14 +7,16 @@ n = int(input("Enter a number: ")) + +#This loop makes the top line of o's for i in range(n*2): print("o", end= "") print() - +#This loop makes the spaces and vertical o's for k in range(1,n-1): print("o", (n-2)*" ", "o") - +#This loop makes the final line of o's for j in range(n*2): print("o", end= "") From 1a460002edfd29ddd24316c8a6f0ced2b75c745d Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Thu, 16 Nov 2017 11:35:48 -0600 Subject: [PATCH 24/31] Made the loops and the rectangles that they make --- Lab 06 - Loopy Lab/part_4.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index 87bc2b3..241d719 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -16,7 +16,6 @@ Explanation video: http://youtu.be/vRB_983kUMc """ -import random import pygame # Define some colors @@ -56,11 +55,12 @@ # If you want a background image, replace this clear with blit'ing the # background image. - screen.fill(WHITE) + screen.fill(BLACK) # --- Drawing code should go here - - + for y in range(0, 500, 10): + for x in range(0, 700, 10): + pygame.draw.rect(screen, GREEN, [(x,y), (5 ,5)]) # --- Go ahead and update the screen with what we've drawn. pygame.display.flip() From 8cc48f36bae9da00aa3a220d2907d4638d78be86 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Fri, 17 Nov 2017 12:22:13 -0600 Subject: [PATCH 25/31] Completed questions 1-13 --- Worksheets/worksheet_07.txt | 57 ++++++++++++++++++++++++++++++++++--- 1 file changed, 53 insertions(+), 4 deletions(-) diff --git a/Worksheets/worksheet_07.txt b/Worksheets/worksheet_07.txt index a87ff3f..1266ca9 100644 --- a/Worksheets/worksheet_07.txt +++ b/Worksheets/worksheet_07.txt @@ -8,6 +8,10 @@ 1. List the four types of data we've covered, and give an example of each: + String: ("My name is Steven Thompson") + Intger: (3) + Floating point: (3.534) + Boolean: (True) 2. What does this code print out? For this and the following problems, make sure you understand WHY it prints what it does. You don't have to explain it, @@ -18,12 +22,19 @@ print(my_list[1]) print(my_list[4]) print(my_list[5]) - + + It prints out 2, 101, and then errors saying "Index out of range". This is because it starts counting at 0 instead of 1. + 3. What does this code print out? my_list=[5, 2, 6, 8, 101] for my_item in my_list: print(my_item) + 5 + 2 + 6 + 8 + 101 4. What does this code print out? @@ -34,6 +45,9 @@ my_list2[2] = 10 print(my_list2) + [5,2,6,10,101] + TypeError: 'tuple' object does not support item assignment + 5. What does this code print out? my_list = [3 * 5] @@ -41,6 +55,9 @@ my_list = [3] * 5 print(my_list) + [15] + [3, 3, 3, 3, 3] + 6. What does this code print out? my_list = [5] @@ -48,6 +65,8 @@ my_list.append(i) print(my_list) + [5, 0, 1, 2, 3, 4] + 7. What does this code print out? print(len("Hi")) @@ -56,18 +75,37 @@ print(len("2")) print(len(2)) + 2 + 9 + 8 + 1 + builtins.TypeError: object of type 'int' has no len() + 8. What does this code print out? print("Simpson" + "College") print("Simpson" + "College"[1]) print( ("Simpson" + "College")[1] ) + SimpsonCollege + Simpsono + i + + 9. What does this code print out? word = "Simpson" for letter in word: print(letter) + S + i + m + p + s + o + n + 10. What does this code print out? word = "Simpson" @@ -75,17 +113,24 @@ word += "College" print(word) + SimpsonCollegeCollegeCollege + 11. What does this code print out? word = "Hi" * 3 print(word) - + + HiHiHi + 12. What does this code print out? my_text = "The quick brown fox jumped over the lazy dogs." print("The 3rd spot is: " + my_text[3]) print("The -1 spot is: " + my_text[-1]) + The 3rd spot is: + The -1 spot is: . + 13. What does this code print out? s = "0123456789" @@ -93,6 +138,10 @@ print(s[:3]) print(s[3:]) + 1 + 012 + 3456789 + 14. Write a loop that will take in a list of five numbers from the user, adding each to an array. Then print the array. Try doing this without looking at the book. @@ -103,6 +152,6 @@ (There is a sum function I haven't told you about. Don't use that. Sum the numbers individually as shown in the chapter.) - my_list = [3,12,3,5,3,4,6,8,5,3,5,6,3,2,4] - + + From 3d2aa633233006b40265e2396c74355aff0a8f22 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Fri, 17 Nov 2017 13:07:15 -0600 Subject: [PATCH 26/31] Completed questions 14-15 --- Worksheets/worksheet_07.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Worksheets/worksheet_07.txt b/Worksheets/worksheet_07.txt index 1266ca9..df51207 100644 --- a/Worksheets/worksheet_07.txt +++ b/Worksheets/worksheet_07.txt @@ -145,13 +145,24 @@ 14. Write a loop that will take in a list of five numbers from the user, adding each to an array. Then print the array. Try doing this without looking at the book. - + + user_input_list = [] + user_input = input("Enter 5 numbers: ") + for number in user_input: + user_input_list.append(number) + print(user_input_list) + 15. Write a program that take an array like the following, and print the average. Use the len function, don't just use 15, because that won't work if the list size changes. (There is a sum function I haven't told you about. Don't use that. Sum the numbers individually as shown in the chapter.) + item_sum = 0 + my_list = [3,12,3,5,3,4,6,8,5,3,5,6,3,2,4] + for item in my_list: + item_sum += item + print(item_sum/len(my_list)) From 0049597ecc3dc6329a04cadf9f14316307a35103 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Mon, 20 Nov 2017 12:10:08 -0600 Subject: [PATCH 27/31] Made room list and set done to false. --- Lab 07 - Adventure/main_program.py | 29 ++++++++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 792d600..05cef53 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1 +1,28 @@ -# +#!/usr/bin/env python3 +#main_program.py +#Steven Thompson +#November 17th 2017 + +""" Adventure game """ + +room_list = [] + +done = False + +current_room = 0 + +room = ["You're standing on the great lawn of a gigantic castle", 1, None, None, 2] +room_list.append(room) +room = ["You're in the castle's shed. There are many tools to keep the lawn tidy", None, 0, None, None] +room_list.append(room) +room = ["You're standing in the great entrance hall to the castle.\nThere are numerous guards and the room is decorated with a gigantic chandelier on the celing", 4, 3, 0, None] +room_list.append(room) +room = ["Dining Room", 5, None, None, 1] +room_list.append(room) +room = ["Center Hallway", None, 5, 1, None] +room_list.append(room) +room = ["East Hallway", 6, None, 3, 4] +room_list.append(room) +room = ["Bed Room", None, None, 5, None] + +print(room_list[current_room][0]) From f16fb8f16c3b0267ace1ab76e768d5db7162330a Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Mon, 20 Nov 2017 13:23:14 -0600 Subject: [PATCH 28/31] Made room descriptions and the user can now manuever through the rooms with ease. --- Lab 07 - Adventure/main_program.py | 66 +++++++++++++++++++++++++----- 1 file changed, 55 insertions(+), 11 deletions(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 05cef53..d36725e 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -4,25 +4,69 @@ #November 17th 2017 """ Adventure game """ - +#The list for the rooms room_list = [] - +#boolean variable to keep the while loop going done = False - +#keeps track of your current room current_room = 0 +#This appends the room to a list that contains all the rooms +room = ["You're standing on the great lawn of a gigantic castle.\nYou take your eyes off the castle for a second and notice a shed in the west. ", 1, None, None, 2] +room_list.append(room) -room = ["You're standing on the great lawn of a gigantic castle", 1, None, None, 2] +room = ["You're standing in the great entrance hall to the castle.\nThere is an alluring smell coming from the dining hall. ", 4, 3, 0, None] room_list.append(room) + room = ["You're in the castle's shed. There are many tools to keep the lawn tidy", None, 0, None, None] room_list.append(room) -room = ["You're standing in the great entrance hall to the castle.\nThere are numerous guards and the room is decorated with a gigantic chandelier on the celing", 4, 3, 0, None] -room_list.append(room) -room = ["Dining Room", 5, None, None, 1] + +room = ["The cooks are preparing a delicious meal. You look past the table and see a hallway in front of you.", 5, None, None, 1] room_list.append(room) -room = ["Center Hallway", None, 5, 1, None] + +room = ["You're in a long corridor that seems to only lead to another equally long corridor.", None, 5, 1, None] room_list.append(room) -room = ["East Hallway", 6, None, 3, 4] + +room = ["You can smell the meal coming from the dining room and see an entrance to a bedroom.", 6, None, 3, 4] room_list.append(room) -room = ["Bed Room", None, None, 5, None] -print(room_list[current_room][0]) +room = ["You have made it all the way to the kings spotless bedroom. It is the most amazing thing you have ever seen", None, None, 5, None] +room_list.append(room) +#Main loop for the program +while done == False: + print() + print("Press Q to quit at anytime") + print() + print(room_list[current_room][0]) + + user_input = input("Which direction do you want to explore? ").lower() + #Controls directions for north + if user_input == "north" or user_input == "n": + next_room = room_list[current_room][1] + if next_room == None: + print("You can't go that way.") + else: + current_room = next_room + #Controls directions for eat + elif user_input == "east" or user_input == "e": + next_room = room_list[current_room][2] + if next_room == None: + print("You can't go that way.") + else: + current_room = next_room + #Controls directions for south + elif user_input == "south" or user_input == "s": + next_room = room_list[current_room][3] + if next_room == None: + print("You can't go that way.") + else: + current_room = next_room + #Controls directions for west + elif user_input == "west" or user_input == "w": + next_room = room_list[current_room][4] + if next_room == None: + print("You can't go that way.") + else: + current_room = next_room + #Exits the while loop if q is entered + elif user_input == "q": + done = True \ No newline at end of file From db63397e1a79fd73a3f912e18a349455172eaa7c Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 29 Nov 2017 11:12:48 -0600 Subject: [PATCH 29/31] removed the hardcoded 'you are in' statements from room descriptions and put them in the while loop --- Lab 07 - Adventure/main_program.py | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index d36725e..3d09038 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -11,57 +11,57 @@ #keeps track of your current room current_room = 0 #This appends the room to a list that contains all the rooms -room = ["You're standing on the great lawn of a gigantic castle.\nYou take your eyes off the castle for a second and notice a shed in the west. ", 1, None, None, 2] +room = ["the great lawn of a gigantic castle.\nYou take your eyes off the castle for a second and notice a shed in the west. ", 1, None, None, 2] room_list.append(room) -room = ["You're standing in the great entrance hall to the castle.\nThere is an alluring smell coming from the dining hall. ", 4, 3, 0, None] +room = ["the great entrance hall to the castle.\nThere is an alluring smell coming from the dining hall. ", 4, 3, 0, None] room_list.append(room) -room = ["You're in the castle's shed. There are many tools to keep the lawn tidy", None, 0, None, None] +room = ["the castle's shed. There are many tools to keep the lawn tidy", None, 0, None, None] room_list.append(room) -room = ["The cooks are preparing a delicious meal. You look past the table and see a hallway in front of you.", 5, None, None, 1] +room = ["the dining room, the cooks are preparing a delicious meal. You look past the table and see a hallway in front of you.", 5, None, None, 1] room_list.append(room) -room = ["You're in a long corridor that seems to only lead to another equally long corridor.", None, 5, 1, None] +room = ["a long corridor that seems to only lead to another equally long corridor.", None, 5, 1, None] room_list.append(room) -room = ["You can smell the meal coming from the dining room and see an entrance to a bedroom.", 6, None, 3, 4] +room = ["a long corridor, you can smell the meal coming from the dining room and see an entrance to a bedroom.", 6, None, 3, 4] room_list.append(room) -room = ["You have made it all the way to the kings spotless bedroom. It is the most amazing thing you have ever seen", None, None, 5, None] +room = ["the kings bedroom, it is the most amazing thing you have ever seen", None, None, 5, None] room_list.append(room) #Main loop for the program while done == False: print() print("Press Q to quit at anytime") print() - print(room_list[current_room][0]) + print("You are in", room_list[current_room][0]) user_input = input("Which direction do you want to explore? ").lower() #Controls directions for north - if user_input == "north" or user_input == "n": + if user_input[0] == "n": next_room = room_list[current_room][1] if next_room == None: print("You can't go that way.") else: current_room = next_room #Controls directions for eat - elif user_input == "east" or user_input == "e": + elif user_input[0] == "e": next_room = room_list[current_room][2] if next_room == None: print("You can't go that way.") else: current_room = next_room #Controls directions for south - elif user_input == "south" or user_input == "s": + elif user_input[0] == "s": next_room = room_list[current_room][3] if next_room == None: print("You can't go that way.") else: current_room = next_room #Controls directions for west - elif user_input == "west" or user_input == "w": + elif user_input[0] == "w": next_room = room_list[current_room][4] if next_room == None: print("You can't go that way.") From 77c94b30dbc752ec8895eae4057c9f29bf56569b Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 29 Nov 2017 11:18:33 -0600 Subject: [PATCH 30/31] Program now prints exits --- Lab 07 - Adventure/main_program.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 3d09038..82c3427 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -37,6 +37,15 @@ print("Press Q to quit at anytime") print() print("You are in", room_list[current_room][0]) + #print exits + if room_list[current_room][1] != None: + print("/tThere is an exit to the North.") + if room_list[current_room][2] != None: + print("\tThere is an exit to the East.") + if room_list[current_room][3] != None: + print("\tThere is an exit to the South.") + if room_list[current_room][4] != None: + print("\tThere is an exit to the West.") user_input = input("Which direction do you want to explore? ").lower() #Controls directions for north From b9b9609e6e0bbd21e9c05f3e722a858039da9b43 Mon Sep 17 00:00:00 2001 From: Sthomp123 Date: Wed, 29 Nov 2017 11:21:02 -0600 Subject: [PATCH 31/31] Fixed indentation problem with lines that print exits --- Lab 07 - Adventure/main_program.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 82c3427..77932e7 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -39,7 +39,7 @@ print("You are in", room_list[current_room][0]) #print exits if room_list[current_room][1] != None: - print("/tThere is an exit to the North.") + print("\tThere is an exit to the North.") if room_list[current_room][2] != None: print("\tThere is an exit to the East.") if room_list[current_room][3] != None: