From 67f14d7128ca20e3d29926a3383d54d9ef772c87 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Wed, 1 Nov 2017 13:45:13 -0500 Subject: [PATCH 01/47] Update worksheet_01.txt --- Worksheets/worksheet_01.txt | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/Worksheets/worksheet_01.txt b/Worksheets/worksheet_01.txt index 728ad02..53ed30f 100644 --- a/Worksheets/worksheet_01.txt +++ b/Worksheets/worksheet_01.txt @@ -6,23 +6,24 @@ and punctuation. Please limit the length of each line to 80 characters. 1. Write a line of code that will print your name. - + print('Conner') 2. How do you enter a comment in a program? - +use # before the comment 3. What do the following lines of code output? ALSO: Why do they give a different answer? print(2 / 3) + 0.66 print(2 // 3) - + 0 4. Write a line of code that creates a variable called pi and sets it to an appropriate value. - +pi = 3.14 5. Why does this code not work? A = 22 print(a) - + Because the A variable is different than the a variable called to print. 6. All of the variable names below can be used. But which ONE of these is the better variable name to use? @@ -34,6 +35,8 @@ area_of_rectangle Area_Of_Rectangle + area_of_rectangle + 7. Which of these variables names are not allowed in Python? (More than one might be wrong. Also, this question is not asking about improper names, just names that aren't allowed. Test them if you aren't sure.) @@ -43,11 +46,11 @@ APPLE Apple2 1Apple - account number + account number this isn't allowed account_number account.number accountNumber - account# + account# this isn't allowed pi PI fred @@ -58,17 +61,18 @@ great.big.variable 2x x2x - total% - #left + total% this isn't allowed + #left this isn't allowed 8. Why does this code not work? print(a) a = 45 - + Because it's telling the program to print something that hasn't been defined yet, then defining it. 9. Explain the mistake in this code: pi = float(3.14) + the number 3.14 is already a float, it doesn't need a float in front of it 10. This program runs, but the code still could be better. Explain what is wrong with the code. From 60aec494375ab8cba6b0f383a0f2b32309fad497 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 2 Nov 2017 12:46:30 -0500 Subject: [PATCH 02/47] Update worksheet_01.txt --- Worksheets/worksheet_01.txt | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/Worksheets/worksheet_01.txt b/Worksheets/worksheet_01.txt index 53ed30f..80997f7 100644 --- a/Worksheets/worksheet_01.txt +++ b/Worksheets/worksheet_01.txt @@ -82,68 +82,69 @@ pi = 3.14 pi = x area = pi * radius ** 2 print(area) - + You don't need to assign x to 3.14 to assign pi to 3.14(or x), you could just assign pi to 3.14 11. Explain the mistake in the following code: x = 4 y = 5 a = ((x) * (y)) print(a) - + You don't need the extra parenthesis around each variable (x and y). 12. Explain the mistake in the following code: x = 4 y = 5 a = 3(x + y) print(a) - + the 'int' object is not callable. 13. Explain the mistake in the following code: radius = input(float("Enter the radius:")) - + could not convert string to float, use of " instead of ' 14. Do all these print the same value? Which one is better to use and why? print(2/3+4) print(2 / 3 + 4) print( 2 / 3+ 4 ) - + Yes, print(2 / 3 + 4) 15. What is a constant? - +a values that cannot be altered by the program. 16. How are variable names for constants different than other variable names? - +constant variable names are immutable. 17. What is a single quote and what is a double quote? Give and label an example of both. - +'hello' +"hello" 18. Write a Python program that will use escape codes to print a double-quote and a new line using the Window's standard. (Note: I'm asking for the Window's standard here. Look it up out of Chapter 1.) - +print("I want to print a double quote \"\n for some reason.") 19. Can a Python program print text to the screen using single quotes instead of double quotes? - +Yes, print("I want to print a double quote \'\n for some reason.") 20. Why does this code not calculate the average? print(3 + 4 + 5 / 3) - + It does in this specific situation, with these numbers. 21. What is an ``operator'' in Python? - +special symbols that carry out arithmetic or logical computation. 22. What does the following program print out? x = 3 x + 1 print(x) - + SyntaxError: multiple statements found while compiling a single statement 23. Correct the following code: user_name = input("Enter your name: )" - + user_name = input("Enter your name: ") 24. Correct the following code: value = int(input(print("Enter your age"))) - + value = int(input("Enter your age: ")) From b380e77b101c04e415c78defff7845f0cb1a4048 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 2 Nov 2017 13:04:27 -0500 Subject: [PATCH 03/47] Update lab_01_part_a.py --- Lab 01 - Calculator/lab_01_part_a.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Lab 01 - Calculator/lab_01_part_a.py b/Lab 01 - Calculator/lab_01_part_a.py index 792d600..4ce89a4 100644 --- a/Lab 01 - Calculator/lab_01_part_a.py +++ b/Lab 01 - Calculator/lab_01_part_a.py @@ -1 +1,9 @@ -# +#!/usr/bin/env python3 +# 1.1 Part A +# Conner Walkenhorst +# 11/2/2017 +"""ask the user for a temperature in Fahrenheit, then print the temperature in Celsius""" + +temperature = int(input('Enter a temperature in Fehrenheit: ')) +celsius = ((temperature - 32)/1.8) +print(celsius) From f1485aa7ae5a397249ba108ae68478d9cba9038a Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 2 Nov 2017 13:43:23 -0500 Subject: [PATCH 04/47] Update lab_01_part_b.py --- Lab 01 - Calculator/lab_01_part_b.py | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Lab 01 - Calculator/lab_01_part_b.py b/Lab 01 - Calculator/lab_01_part_b.py index 792d600..368a7fd 100644 --- a/Lab 01 - Calculator/lab_01_part_b.py +++ b/Lab 01 - Calculator/lab_01_part_b.py @@ -1 +1,13 @@ -# +#!/usr/bin/env python3 +# 1.2 Part B +# Conner Walkenhorst +# 11/2/2017 +"""ask user for information needed to find area of trapazoid, then print area""" + +print('Area of a trapezoid') +height = int(input('Enter the height of the trapezoid: ')) +lenght_bottom = int(input('Enter the length of the bottom base: ')) +lenght_top = int(input('Enter the length of the top base: ')) +area1 = (lenght_bottom + lenght_top) +area2 = (0.5*area1*height) +print('The area is:',area2) From a633e6d1edf86146757eb63b09e002eb4a5de93d Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 3 Nov 2017 11:19:42 -0500 Subject: [PATCH 05/47] Update lab_01_part_c.py --- Lab 01 - Calculator/lab_01_part_c.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Lab 01 - Calculator/lab_01_part_c.py b/Lab 01 - Calculator/lab_01_part_c.py index 792d600..d51dcac 100644 --- a/Lab 01 - Calculator/lab_01_part_c.py +++ b/Lab 01 - Calculator/lab_01_part_c.py @@ -1 +1,9 @@ -# +#!/usr/bin/env python3 +# 1.3 Part C +# Conner Walkenhorst +# 11/3/2017 +"""calculate the area of square from user input values""" + +length = int(input('Length: ')) +width = int(input('Width: ')) +print('Area of Square: ',length*width) From 522accc18950ac297ff7d7c5a815f701e591033c Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 3 Nov 2017 11:58:58 -0500 Subject: [PATCH 06/47] Update worksheet_02.txt --- Worksheets/worksheet_02.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/Worksheets/worksheet_02.txt b/Worksheets/worksheet_02.txt index abe4cd7..04354a3 100644 --- a/Worksheets/worksheet_02.txt +++ b/Worksheets/worksheet_02.txt @@ -6,27 +6,27 @@ 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.) - +101101 2. Give an example of a decimal number. - +82 3. Give an example of a hexadecimal number. - +3FA 4. Convert the numbers 1, 10, 100, 1000, and 10000 from binary to decimal. - +1 = 1, 10 = 2, 100 = 4, 1000 = 8, 10000 = 16 5. What is a compiler? - +Converts source code to machine code 6. What is source code? - +The program the developer types into the computer 7. What is machine language? (Don't just say binary. That's not correct.) - +The native code the computer runs 8. What is a first generation language? (Don't just say binary. That's not correct.) - +Machine Language 9. What is a second generation language? - +Assembly Language 10. What is a third generation language? (Explain, don't just give one example.) - +Language like Python or C that has logical structures 11. What is an interpreter and how does it differ from a compiler? - +an interpreter translates a program one statement at a time, a compiler scans the entire program and translates it as a whole into machine code. 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. From d5fb81642f382b140b8af3d12a1b3470a9d1f3e8 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 3 Nov 2017 12:39:17 -0500 Subject: [PATCH 07/47] Update worksheet_02.txt --- Worksheets/worksheet_02.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Worksheets/worksheet_02.txt b/Worksheets/worksheet_02.txt index 04354a3..42e5020 100644 --- a/Worksheets/worksheet_02.txt +++ b/Worksheets/worksheet_02.txt @@ -29,14 +29,14 @@ Language like Python or C that has logical structures an interpreter translates a program one statement at a time, a compiler scans the entire program and translates it as a whole into machine code. 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, website: 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. - +Java, website: https://www.indeed.com/q-Software-Engineer-l-Missouri-jobs.html 14. What is the difference between the ``syntax'' and ``semantics'' of a language? - - 15. Pick a piece of technology, other than a computer you use regularly. Briefly +syntax refers to formal rules governing the construction of valid statements in a language, semantics refers to the set of rules which give the meaning of a statement. + 15. Pick a piece of technology, other than a computer, that you use regularly. Briefly describe the hardware and software that run on it. - +Cell Phone: a cell phone uses a touch screen to interact with the user through touch and sight, applications serve as software that run on the device. From b7dc3f47b6f28ce7a08388ba7af12b9959035f8b Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 3 Nov 2017 13:42:29 -0500 Subject: [PATCH 08/47] Update worksheet_03.txt --- Worksheets/worksheet_03.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index bc85b84..2dcc50d 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -10,7 +10,7 @@ print("It is hot outside.") else: print("It is not hot out.") - + the second parenthesis on the end of the first line 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. From 14582eaa680c862e8b8f3171c45da5f08525b54d Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Mon, 6 Nov 2017 11:21:25 -0600 Subject: [PATCH 09/47] Update worksheet_03.txt --- Worksheets/worksheet_03.txt | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index 2dcc50d..fd833f7 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -14,6 +14,14 @@ 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('Number is negative') +elif number > 0: + print('Number is posative') +elif number == 0: + print('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) From e8329ef6efa9410ebe31ad81d03c984ff4a6ba81 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Mon, 6 Nov 2017 12:04:04 -0600 Subject: [PATCH 10/47] Update worksheet_03.txt --- Worksheets/worksheet_03.txt | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index fd833f7..3ee5575 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -26,6 +26,10 @@ elif number == 0: 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 -11 < number < 11: + print('Success') + 4. This runs, but there is something wrong. What is it? (1 pt) user_input = input("A cherry is a: ") @@ -35,7 +39,9 @@ elif number == 0: print("Correct!") else: print("Incorrect.") - + + the ".upper" is not needed, it will only count a capital "A" as correct without it anyway. + 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. @@ -47,12 +53,16 @@ elif number == 0: else: print("x is not positive.") + there can't be a double equal sign in the assigning line of code. also as long as x is assigned to 4 the output can never print "x is not posirive." + 6. What three things are wrong with the following code? (3 pts) x = input("Enter a number: ") if x = 3 print("You entered 3") + there is no colon at the end of the if statement, + 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? ") From 92159fa9b6c45279216d670a321bb3f44e151dd3 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Mon, 6 Nov 2017 13:43:44 -0600 Subject: [PATCH 11/47] Update worksheet_03.txt --- Worksheets/worksheet_03.txt | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index 3ee5575..465904e 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -61,7 +61,7 @@ if -11 < number < 11: if x = 3 print("You entered 3") - there is no colon at the end of the if statement, + there is no colon at the end of the if statement, "x" is a terrible variable name!, the print statement will not print the user's input like it should it will only print "You entered 3". 7. There are four things wrong with this code. Identify all four issues. (4 pts) @@ -71,13 +71,17 @@ if -11 < number < 11: else print("Incorrect! It is Beaker.") + else statement doesn't have a colon at the end of it. a is not defined, answer needs to be spelled out fully. there needs to be a double equals sign after what should be answer and before "Beaker" in the if statement. and the else statement needs to be backed up the same indentation as the if statement. + 8. This program doesn't work correctly. What is wrong? (1 pt) x = input("How are you today?") if x == "Happy" or "Glad": print("That is good to hear!") - 9. Look at the code below. Write you best guess here on what it will print. + the colon brings up a syntax error. + + 9. Look at the code below. Write your best guess here on what it will print. Next, run the code and see if you are correct. Clearly label your guess and the actual answer. Also, if this or any other example results in an error, make sure to @@ -97,6 +101,8 @@ if -11 < number < 11: if z: print("Buzz") + i think it will print "x= 5, y= 5, z= 5, Buzz". what it acually prints "x= 5, y= False, z= True, Buzz" + 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) @@ -115,6 +121,9 @@ if -11 < number < 11: print(x == 5 and y == 5) print(x == 5 or y == 5) + i think it will print "True, False, False, False, True, False, False, True, False, True" + it actually prints "True, False, True, False, False, True, False, False, True, False, True" + 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) @@ -128,6 +137,7 @@ if -11 < number < 11: print( (2 == 2) == True ) print(3 < "3") + True False True True True False False True 12. What things are wrong with this section of code? The programmer wants to set the money variable according to @@ -148,6 +158,6 @@ if -11 < number < 11: else if user_input = C: money = 50 - + not using double equal signs, the user might put a lowercase letter, no space after user_input question, uses else if instead of elif and else From 554da546ef29f195bacc3b4355b02928f30485fc Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Tue, 7 Nov 2017 11:27:54 -0600 Subject: [PATCH 12/47] Update main_program.py --- Lab 03 - Create a Quiz/main_program.py | 8 +++++++- 1 file changed, 7 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..a8568c4 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -1 +1,7 @@ -# +#!/usr/bin/env python3 +# Lab 03 - Create a Quiz +# Conner Walkenhorst +# 11/7/2017 + +"""Make my own quiz from scratch""" + From cd2ef1fed8141cc8cd6836b147e87098f3006a16 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Tue, 7 Nov 2017 12:52:45 -0600 Subject: [PATCH 13/47] Update main_program.py --- Lab 03 - Create a Quiz/main_program.py | 34 ++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/Lab 03 - Create a Quiz/main_program.py b/Lab 03 - Create a Quiz/main_program.py index a8568c4..62823f1 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -5,3 +5,37 @@ """Make my own quiz from scratch""" +total = 0 +print('Welcome to My Quiz') +answer1 = int(input('Question #1: What is 2+2? ')) +if answer1 == 4: + total += 1 + print(answer1,'is correct.') +else: + print('Sorry',answer1,'is incorrect.') +answer2 = int(input('Question #2: How many letters does the color blue have in its name? ')) +if answer2 == 4: + total += 1 + print(answer2,'is correct.') +else: + print('Sorry',answer2,'is incorrect.') +answer3 = input('Question #3: What is the name of the United States National Anthem? ') +if answer3 == 'The Star-Spangled Banner' or answer3 == 'the star-spangled banner' or answer3 == 'The Star Spangled Banner' or answer3 == 'the star spangled banner': + total += 1 + print(answer3,'is correct.') +else: + print('Sorry',answer3,'is incorrect.') +answer4 = int(input('Question #4: How many letters does the color red have in its name? ')) +if answer4 == 3: + total += 1 + print(answer4,'is correct.') +else: + print('Sorry',answer4,'is incorrect.') +answer5 = input('Question #5: What is the best soda ever made? ') +if answer5 == 'Mountain Dew' or answer5 == 'mountain dew' or answer5 == 'mt. dew' or answer5 == 'mt dew': + total += 1 + print(answer5,'is correct.') +else: + print('Sorry',answer5,'is incorrect.') +percentCorrect = (total/5)*100 +print(str(percentCorrect) + '%') From c558463a9ab489c5de21eafe72f8d958ca1e8f24 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Wed, 8 Nov 2017 13:44:45 -0600 Subject: [PATCH 14/47] Update worksheet_04.txt --- Worksheets/worksheet_04.txt | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Worksheets/worksheet_04.txt b/Worksheets/worksheet_04.txt index 341b2fa..ed91e3f 100644 --- a/Worksheets/worksheet_04.txt +++ b/Worksheets/worksheet_04.txt @@ -14,17 +14,39 @@ 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. +name = input('Enter Your Name: ') +for number in range(10): + print(name) +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 i in range(20): + print('red') + print('gold') + + 3. Write a Python program that will use a for loop to print the even numbers from 2 to 100, inclusive. +for i in range(2,201,2): + print(i) + + 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. +launch = 10 +number = launch +while number > -1: + print(number) + number = number - 1 +print('Blast Off!') + 5. There are three things wrong with this program. List each. (3 pts) print("This program takes three numbers and returns the sum.") @@ -35,6 +57,8 @@ total = total + i print("The total is:", x) + for one, 'x' is a terrible variable name, it does not describe what it is/does at all. where total is assigned to total + i, i should be x. in the last print statement where it calls to print x, it should print total instead. + 6. Write a program that prints a random integer from 1 to 10 (inclusive). 7. Write a program that prints a random floating point number somewhere between From 48e43fb633fb40f3fac89f23ccf939903447f84f Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 9 Nov 2017 13:43:55 -0600 Subject: [PATCH 15/47] Update worksheet_04.txt --- Worksheets/worksheet_04.txt | 39 +++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/Worksheets/worksheet_04.txt b/Worksheets/worksheet_04.txt index ed91e3f..61289b1 100644 --- a/Worksheets/worksheet_04.txt +++ b/Worksheets/worksheet_04.txt @@ -61,10 +61,16 @@ print('Blast Off!') 6. Write a program that prints a random integer from 1 to 10 (inclusive). +from random import randint +print(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 +print(random.uniform(1.0,10.0)) + 8. Write a Python program that will: (3 pts) * Ask the user for seven numbers @@ -73,6 +79,25 @@ print('Blast Off!') and the number of negative entries. Use an if, elif, else chain, not just three if statements. + total = 0 +totalPositive = 0 +totalNegative = 0 +totalZero = 0 +number = input('Enter seven numbers: ') +number = number.split() +for num in number: + total = total+int(num) + if int(num) > 0: + totalPositive += 1 + elif int(num) < 0: + totalNegative += 1 + else: + totalZero += 1 +print('Total:',total) +print('Total Positive:',totalPositive) +print('Total Negative:',totalNegative) +print('Total Zero:',totalZero) + 9. Coin flip tosser: (4 pts) * Create a program that will print a random 0 or 1. @@ -81,6 +106,20 @@ print('Blast Off!') * 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 + numberHeads = 0 +numberTails = 0 +for i in range(50): + number = random.randrange(0, 2) + if number == 1: + numberHeads += 1 + print('Heads') + elif number == 0: + numberTails += 1 + print('Tails') +print('Heads:', numberHeads) +print('Tails:', numberTails) + 10. Write a program that plays rock, paper, scissors: (4 pts) * Create a program that randomly prints 0, 1, or 2. From c0fb86471337e7ec245d05c3eef34ccf2cdb9b85 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 10 Nov 2017 10:17:56 -0600 Subject: [PATCH 16/47] Update main_program.py --- Lab 04 - Camel/main_program.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index 792d600..a6d5b18 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -1 +1,9 @@ # +# Lab 04 Camel +# Conner Walkenhorst +# 11/10/2017 + +"""the user is running from a hoard of zombies, the user decides what to do""" + +print('Welcome to Zombie Run!') +print('You have found yourself being chased by a hoard of flesh eating zombies while going on a supply run. The hoard is coming for you fast. Survive at all costs and outrun the hoard.') From 4da99e9160e6fc9dff13aaed44a7b6f579b9d6bf Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 10 Nov 2017 11:07:12 -0600 Subject: [PATCH 17/47] Update worksheet_04.txt --- Worksheets/worksheet_04.txt | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/Worksheets/worksheet_04.txt b/Worksheets/worksheet_04.txt index 61289b1..76c67f4 100644 --- a/Worksheets/worksheet_04.txt +++ b/Worksheets/worksheet_04.txt @@ -129,4 +129,30 @@ print('Tails:', numberTails) * (It will be easier if you have them enter 1, 2, or 3.) * Add conditional statement to figure out who wins. - + from random import randint +options = [1,2,3] +computerPlayer = options[randint(0,2)] +player = False +while player == False: + player = int(input('Rock = 1, Paper = 2, Scissors = 3. Enter your choice: ')) + if player == computerPlayer: + print('Tie, no one wins.') + elif player == 1: + if computerPlayer == 2: + print('You lose.',computerPlayer, 'beats',player) + else: + print('You win.',player,'beats',computerPlayer) + elif player == 2: + if computerPlayer == 3: + print('You lose.',computerPlayer,'beats',player) + else: + print('You win.',player,'beats',computerPlayer) + elif player == 3: + if computerPlayer == 1: + print('You lose.',computerPlayer,'beats',player) + else: + print('You win.',player,'beats',computerPlayer) + else: + print('That is not a valid choice, please try again.') + player = False + computerPlayer = options[randint(0,2)] From 3883ce7e9a8c0fd5bfab1a05df2b740d6dce2300 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 10 Nov 2017 12:21:16 -0600 Subject: [PATCH 18/47] Update main_program.py --- Lab 04 - Camel/main_program.py | 71 ++++++++++++++++++++++++++++++++-- 1 file changed, 67 insertions(+), 4 deletions(-) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index a6d5b18..45c63dc 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -1,9 +1,72 @@ -# +#!/usr/bin/env python3 # Lab 04 Camel # Conner Walkenhorst # 11/10/2017 -"""the user is running from a hoard of zombies, the user decides what to do""" +"""the user is running from the natives in the great mobi desert on a stolen camel, the user decides what to do""" -print('Welcome to Zombie Run!') -print('You have found yourself being chased by a hoard of flesh eating zombies while going on a supply run. The hoard is coming for you fast. Survive at all costs and outrun the hoard.') +from random import randint +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! Survive your') +print('desert trek and out run the natives.') +done = False +milesTraveled = 0 +thirst = 0 +camelTiredness = 0 +distanceNativesTraveled = -20 +initialDrinks = 5 +while done is 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.') + userChoice = input('What will you do? ') + if userChoice.upper() == 'Q': + done = True + elif userChoice.upper() == 'E': + print('Miles traveled:',milesTraveled) + print('Drinks in canteen:',initialDrinks) + print('The natives are ',distanceNativesTraveled,'miles behind you.') + elif userChoice.upper() == 'D': + camelTiredness = 0 + print('The camel is happy.') + distanceNativesTraveled += 7 + elif userChoice.upper() == 'C': + milesTraveled += randint(10,20) + print('Miles Traveled:',milesTraveled) + thirst += 1 + camelTiredness += randint(1,3) + distanceNativesTraveled += 7 + elif userChoice.upper() == 'B': + milesTraveled += randint(5,12) + print('Miles Traveled:',milesTraveled) + thirst += 1 + camelTiredness += 1 + distanceNativesTraveled += randint(7,14) + elif userChoice.upper() == 'A': + if initialDrinks > 0: + initialDrinks -= 1 + thirst = 0 + else: + print('Error, no drinks left.') + if thirst > 4: + print('You are thirsty.') + elif thirst > 6: + print('You died of thirst.') + done = True + if camelTiredness > 5: + print('Your camel is getting tired.') + elif camelTiredness > 8: + print('Your camel is dead.') + done = True + if distanceNativesTraveled == milesTraveled: + print('The natives caught you.') + done = True + elif distanceNativesTraveled == 15 < milesTraveled: + print('The natives are getting close.') + if milesTraveled == 200: + print('You won.') + done = True From e89db7d0b8127cf5bf75951b75489c587e2f5649 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 10 Nov 2017 13:42:23 -0600 Subject: [PATCH 19/47] Update worksheet_05.txt --- Worksheets/worksheet_05.txt | 34 ++++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/Worksheets/worksheet_05.txt b/Worksheets/worksheet_05.txt index 275a18a..7f7c6bc 100644 --- a/Worksheets/worksheet_05.txt +++ b/Worksheets/worksheet_05.txt @@ -8,38 +8,60 @@ 1. Explain how the computer coordinate system differs from the standard Cartesian coordinate system. There are two main differences. List both. +The computer coordinate system has point (0,0) in the top left corner, +while the standard cartesian coordinate system has point (0,0) in the center. +The computer coordinate system also goes up in x and y values by the more down and right the point goes, +while the standard cartesian coordinate system goes up in x and y values by the more up and right the point goes. + 2. Before a Python Pygame program can use any functions like pygame.display.set_mode(), what two lines of code must occur first? +import pygame and pygame.init() + 3. Explain how WHITE = (255, 255, 255) represents a color. +Because this format represents (red, green, blue) values. If you have full red, full green, and full blue values +than the resulting color would be white due to white being the absolution of color. + 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.) +If the variable is a constant than it will be all uppercase lettering. + 5. What does the pygame.display.set_mode() function do? +Pull up a pygame window on screen. + 6. What does this for event in pygame.event.get() loop do? +This gets an event. + 7. What is pygame.time.Clock used for? +Contains routines to help keep track of time. + 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? - * What does [100, 100] do? - * What does 5 do? + * What does screen do? Screen tells the program where to execute + * What does [0, 0] do? [0, 0] sets the starting point + * What does [100, 100] do? [100, 100] sets the ending point + * What does 5 do? 5 tells the z axis value 9. What is the best way to repeat something over and over in a drawing? +void draw() + 10. When drawing a rectangle, what happens if the specified line width is zero? +Then there will not be a border around the rectangle. + 11. Describe the ellipse drawn in the code below. - * What is the x, y of the origin coordinate? - * What does the origin coordinate specify? The center of the circle? + * What is the x, y of the origin coordinate? x = 250 y = 100 + * What does the origin coordinate specify? The center of the circle? * What is the length and the width of the ellipse? From 5438b1eaebee791584356d3cb05b58f99bb5f6c3 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 10 Nov 2017 20:34:45 -0600 Subject: [PATCH 20/47] Update worksheet_05.txt --- Worksheets/worksheet_05.txt | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/Worksheets/worksheet_05.txt b/Worksheets/worksheet_05.txt index 7f7c6bc..c7cabda 100644 --- a/Worksheets/worksheet_05.txt +++ b/Worksheets/worksheet_05.txt @@ -60,9 +60,9 @@ void draw() Then there will not be a border around the rectangle. 11. Describe the ellipse drawn in the code below. - * What is the x, y of the origin coordinate? x = 250 y = 100 - * What does the origin coordinate specify? The center of the circle? - * What is the length and the width of the ellipse? + * What is the x, y of the origin coordinate? x = 20 y = 20 + * What does the origin coordinate specify? The center of the circle? The upper left corner + * What is the length and the width of the ellipse? Length = 100 Width = 250 pygame.draw.ellipse(screen, BLACK, [20, 20, 250, 100], 2) @@ -70,22 +70,36 @@ Then there will not be a border around the rectangle. 12. When drawing an arc, what additional information is needed over drawing an ellipse? +Start and end angles, which are radians. + 13. Describe, in general, what are the three steps needed when printing text to the screen using graphics? +Create a variable that holds information about font to be used, create an image of the text, +tell where the image is to be stamped. + 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. +Because it only needs to run once at the start of the program, it doesn't hold things that change. + 15. What are the coordinates of the polygon that the code below draws? pygame.draw.polygon(screen, BLACK, [[50,100],[0,200],[200,200],[100,50]], 5) + [50,100],[0,200],[200,200],[100,50] + 16. What does pygame.display.flip() do? +Updates the display 'flipping' the new graphics to the screen. + 17. What does pygame.quit() do? +Properly shuts down a pygame program. + 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, (50,50), 5, 1) From 14bfc376bb712597c05798b4e80114720a6f7c34 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Fri, 10 Nov 2017 22:49:13 -0600 Subject: [PATCH 21/47] Update main_program.py --- Lab 05 - Create a Picture/main_program.py | 92 ++++++++++++++++++++++- 1 file changed, 91 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..21da2e7 100644 --- a/Lab 05 - Create a Picture/main_program.py +++ b/Lab 05 - Create a Picture/main_program.py @@ -1 +1,91 @@ -# +#!/usr/bin/env python3 +# Lab 03 Creat a Picture +# Conner Walkenhorst +# 11/10/2017 + +"""Create a picture from python code""" + +import pygame + +# Initialize the game engine +pygame.init() + +# Define some colors +BLACK = (0, 0, 0) +WHITE = (255, 255, 255) +BLUE = (0, 0, 255) +GREEN = (0, 255, 0) +RED = (255, 0, 0) + +PI = 3.141592653 + +# Set the height and width of the screen +size = (500, 500) +screen = pygame.display.set_mode(size) + +pygame.display.set_caption("Conner's Python House") + +# Loop until the user clicks the close button. +done = False +clock = pygame.time.Clock() + +# Loop as long as done == False +while not done: + for event in pygame.event.get(): # User did something + if event.type == pygame.QUIT: # If user clicked close + done = True # Flag that we are done so we exit this loop + + # All drawing code happens after the for loop and but + # inside the main while not done loop. + + # Clear the screen and set the screen background + screen.fill(BLACK) + + # Draw a rectangle for grass + pygame.draw.rect(screen, GREEN, [0, 400, 500, 100], 0) + + # Draw a rectangle for house + pygame.draw.rect(screen, BLUE, [150, 200, 200, 200], 0) + + #draw a rectangle for door + pygame.draw.rect(screen, RED, [200, 400, 100, -95], 0) + + #draw an ellipse for door knob + pygame.draw.ellipse(screen, BLACK, [265, 335, 15, 15], 0) + + # This draws a triangle for the house using the polygon command + pygame.draw.polygon(screen, RED, [[250, 75], [150, 200], [350, 200]], 0) + + # Draw an ellipse, using a rectangle as the outside boundaries + pygame.draw.ellipse(screen, BLUE, [200, 130, 100, 50], 0) + + #draw an ellipse for the moon + pygame.draw.ellipse(screen, WHITE, [60, 60, 60, 60], 0) + + #draw a line for upper window + pygame.draw.line(screen, BLACK, [250, 130], [250, 177], 2) + + #draw other line for upper window + pygame.draw.line(screen, BLACK, [200, 150], [300, 150], 2) + + # Select the font to use, size, bold, italics + font = pygame.font.SysFont('Calibri', 25, True, False) + + # Render the text. "True" means anti-aliased text. + # Black is the color. This creates an image of the + # letters, but does not put it on the screen + text = font.render("Hello World", True, BLACK) + + # Put the image of the text on the screen at 250x250 + screen.blit(text, [200, 250]) + + # Go ahead and update the screen with what we've drawn. + # This MUST happen after all the other drawing commands. + pygame.display.flip() + + # This limits the while loop to a max of 60 times per second. + # Leave this out and we will use all CPU we can. + clock.tick(60) + +# Be IDLE friendly +pygame.quit() From e9cf1ba427e3c8df2ec2e9bc600fde4c397eb878 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Tue, 14 Nov 2017 13:40:06 -0600 Subject: [PATCH 22/47] problems 1 through 4 worksheet 6 --- Lab 06 - Loopy Lab/part_1.py | 10 ++++++++ Lab 06 - Loopy Lab/part_3.py | 15 +++++++++++- Lab 06 - Loopy Lab/part_4#10.py | 15 ++++++++++++ Lab 06 - Loopy Lab/part_4#11.py | 24 +++++++++++++++++++ Lab 06 - Loopy Lab/part_4#12.py | 37 +++++++++++++++++++++++++++++ Lab 06 - Loopy Lab/part_4#13.py | 42 +++++++++++++++++++++++++++++++++ Lab 06 - Loopy Lab/part_4.py | 19 ++++++++++++++- Worksheets/worksheet_06.txt | 10 ++++++++ part_1.py | 1 - part_2.py | 1 - part_3.py | 1 - part_4.py | 1 - 12 files changed, 170 insertions(+), 6 deletions(-) create mode 100644 Lab 06 - Loopy Lab/part_4#10.py create mode 100644 Lab 06 - Loopy Lab/part_4#11.py create mode 100644 Lab 06 - Loopy Lab/part_4#12.py create mode 100644 Lab 06 - Loopy Lab/part_4#13.py delete mode 100644 part_1.py delete mode 100644 part_2.py delete mode 100644 part_3.py delete mode 100644 part_4.py diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index 8b13789..3f0b962 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -1 +1,11 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 +"""Lab 06 programs""" + +#Do 10 times +for i in range(10): + #print an * and a space + print('*', end=' ') diff --git a/Lab 06 - Loopy Lab/part_3.py b/Lab 06 - Loopy Lab/part_3.py index 792d600..7f17482 100644 --- a/Lab 06 - Loopy Lab/part_3.py +++ b/Lab 06 - Loopy Lab/part_3.py @@ -1 +1,14 @@ -# +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do this 10 times +for i in range(10): + #print 10 *'s on 1 line + for j in range(10): + print('*',end=' ') + #print a new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_4#10.py b/Lab 06 - Loopy Lab/part_4#10.py new file mode 100644 index 0000000..0b63434 --- /dev/null +++ b/Lab 06 - Loopy Lab/part_4#10.py @@ -0,0 +1,15 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do 9 times starting at 1 (row) +for row in range(1,10): + + #Loop to print multiples + for i in range(1,10): + print(repr(row*i).rjust(2),end=' ') + #print a new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_4#11.py b/Lab 06 - Loopy Lab/part_4#11.py new file mode 100644 index 0000000..90d2156 --- /dev/null +++ b/Lab 06 - Loopy Lab/part_4#11.py @@ -0,0 +1,24 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do 9 times starting at 1 (row) +for row in range(1,10): + + #Loop to print spaces + for space in range(9 - row): + print(' ', end=' ') + + #Loop to print digits + for digit in range(1, row + 1): + print(digit,end=' ') + + #Loop to print digits2 + for digit2 in range(row - 1,0,-1): + print(digit2, end=' ') + + #print a new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_4#12.py b/Lab 06 - Loopy Lab/part_4#12.py new file mode 100644 index 0000000..68bf4f2 --- /dev/null +++ b/Lab 06 - Loopy Lab/part_4#12.py @@ -0,0 +1,37 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do 9 times starting at 1 (row) +for row in range(1,10): + + #Loop to print spaces + for space in range(9 - row): + print(' ', end=' ') + + #Loop to print digits + for digit in range(1, row + 1): + print(digit,end=' ') + + #Loop to print digits2 + for digit2 in range(row - 1,0,-1): + print(digit2, end=' ') + + #print a new line + print() + +#Do 8 times starting at 8 down to 1 +for row2 in range(8,0,-1): + + #Loop to print spaces + for space in range(9 - row2): + print(' ',end=' ') + + #Loop to print digits + for digit3 in range(1,row2 + 1): + print(digit3,end=' ') + #print new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_4#13.py b/Lab 06 - Loopy Lab/part_4#13.py new file mode 100644 index 0000000..4714699 --- /dev/null +++ b/Lab 06 - Loopy Lab/part_4#13.py @@ -0,0 +1,42 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do 9 times starting at 1 (row) +for row in range(1,10): + + #Loop to print spaces + for space in range(9 - row): + print(' ', end=' ') + + #Loop to print digits + for digit in range(1, row + 1): + print(digit,end=' ') + + #Loop to print digits2 + for digit2 in range(row - 1,0,-1): + print(digit2, end=' ') + + #print a new line + print() + +#Do 8 times starting at 8 down to 1 +for row2 in range(8,0,-1): + + #Loop to print spaces + for space in range(9 - row2): + print(' ',end=' ') + + #Loop to print digits3 + for digit3 in range(1,row2 + 1): + print(digit3,end=' ') + + #Loop to print digits3 + for digit4 in range(row2 - 1, 0, -1): + print(digit4,end=' ') + + #print new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index 792d600..6a6c72f 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -1 +1,18 @@ -# +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do this 10 times + +for i in range(10): + #print leading spaces + #print the digits + for j in range(i): + print(' ',end=' ') + for j in range(10-i): + print(j,end=' ') + #print a new line + print() \ No newline at end of file diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index 35e5f13..81b38fa 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -18,6 +18,8 @@ print(x) x = x + 2 + It will print 0 2 4 6 8 all on separate lines + 2. What does this program print out? x = 1 @@ -25,6 +27,8 @@ print(x) x = x * 2 + It will print 1 2 4 6 8 16 32 all on separate lines + 3. Why is the and x >= 0 not needed? x = 0 @@ -32,6 +36,8 @@ print(x) x = x + 2 + Because there is no way for x to go down in value anyway. + 4. What does this program print out? (0 pts) Explain. (1 pt) x = 5 @@ -41,6 +47,8 @@ print("Blast off!") x = x - 1 + It will print 5 4 3 2 1 0, an integer will never be equal to a string, so "Blast Off!" will never print. + 5. Fix the following code so it doesn't repeat forever, and keeps asking the user until he or she enters a number greater than zero: (2 pts) @@ -49,6 +57,8 @@ while x <= 0: print("Too small. Enter a number greater than zero: ") + + 6. Fix the following code: x = 10 diff --git a/part_1.py b/part_1.py deleted file mode 100644 index 792d600..0000000 --- a/part_1.py +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/part_2.py b/part_2.py deleted file mode 100644 index 792d600..0000000 --- a/part_2.py +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/part_3.py b/part_3.py deleted file mode 100644 index 792d600..0000000 --- a/part_3.py +++ /dev/null @@ -1 +0,0 @@ -# diff --git a/part_4.py b/part_4.py deleted file mode 100644 index 792d600..0000000 --- a/part_4.py +++ /dev/null @@ -1 +0,0 @@ -# From 734afc63ffae4e3d446163e052096bb7d1c1d501 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Wed, 15 Nov 2017 12:37:47 -0600 Subject: [PATCH 23/47] completed chapter 6 worksheet --- Worksheets/worksheet_06.txt | 17 +++++++++++++++-- Worksheets/worksheet_06_codeTester.py | 15 +++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 Worksheets/worksheet_06_codeTester.py diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index 81b38fa..c043bb8 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -57,7 +57,10 @@ while x <= 0: print("Too small. Enter a number greater than zero: ") - + x = float(input("Enter a number greater than zero: ")) + +while x <= 0: + x = int(input("Too small. Enter a number greater than zero: ")) 6. Fix the following code: @@ -69,6 +72,14 @@ print("Blast-off") + x = 10 + +while x > 0: + print(x) + x = 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) @@ -77,6 +88,8 @@ print(i) i += 1 + The line of code "i += 1" is not needed due to the fact that the for loop and print statement alone will do the same. + 8. Explain why the values printed for x are so different. (2 pts) # Sample 1 @@ -95,4 +108,4 @@ x += 1 print(x) - + Because Sample 1 both for loops are at the same indentation, which means that for loop i will execute, then for loop j will execute. On Sample 2 for loop j is indented into for loop i, so the loop in total will run 10 times more than Sample 1. diff --git a/Worksheets/worksheet_06_codeTester.py b/Worksheets/worksheet_06_codeTester.py new file mode 100644 index 0000000..cd609df --- /dev/null +++ b/Worksheets/worksheet_06_codeTester.py @@ -0,0 +1,15 @@ +# 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) \ No newline at end of file From 3d9d3058ca2725109a38f12a244307d93a0a1838 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Wed, 15 Nov 2017 13:27:54 -0600 Subject: [PATCH 24/47] Forgot to save and commit through process of this part, finished Lab 06 part 1 --- .../{part_4#10.py => Chapter_06#10.py} | 0 .../{part_4#11.py => Chapter_06#11.py} | 0 .../{part_4#12.py => Chapter_06#12.py} | 0 .../{part_4#13.py => Chapter_06#13.py} | 0 Lab 06 - Loopy Lab/Chapter_06#7.py | 11 +++++++++++ Lab 06 - Loopy Lab/Chapter_06#8.py | 14 ++++++++++++++ Lab 06 - Loopy Lab/Chapter_06#9.py | 18 ++++++++++++++++++ Lab 06 - Loopy Lab/part_1.py | 16 ++++++++++++---- 8 files changed, 55 insertions(+), 4 deletions(-) rename Lab 06 - Loopy Lab/{part_4#10.py => Chapter_06#10.py} (100%) rename Lab 06 - Loopy Lab/{part_4#11.py => Chapter_06#11.py} (100%) rename Lab 06 - Loopy Lab/{part_4#12.py => Chapter_06#12.py} (100%) rename Lab 06 - Loopy Lab/{part_4#13.py => Chapter_06#13.py} (100%) create mode 100644 Lab 06 - Loopy Lab/Chapter_06#7.py create mode 100644 Lab 06 - Loopy Lab/Chapter_06#8.py create mode 100644 Lab 06 - Loopy Lab/Chapter_06#9.py diff --git a/Lab 06 - Loopy Lab/part_4#10.py b/Lab 06 - Loopy Lab/Chapter_06#10.py similarity index 100% rename from Lab 06 - Loopy Lab/part_4#10.py rename to Lab 06 - Loopy Lab/Chapter_06#10.py diff --git a/Lab 06 - Loopy Lab/part_4#11.py b/Lab 06 - Loopy Lab/Chapter_06#11.py similarity index 100% rename from Lab 06 - Loopy Lab/part_4#11.py rename to Lab 06 - Loopy Lab/Chapter_06#11.py diff --git a/Lab 06 - Loopy Lab/part_4#12.py b/Lab 06 - Loopy Lab/Chapter_06#12.py similarity index 100% rename from Lab 06 - Loopy Lab/part_4#12.py rename to Lab 06 - Loopy Lab/Chapter_06#12.py diff --git a/Lab 06 - Loopy Lab/part_4#13.py b/Lab 06 - Loopy Lab/Chapter_06#13.py similarity index 100% rename from Lab 06 - Loopy Lab/part_4#13.py rename to Lab 06 - Loopy Lab/Chapter_06#13.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#7.py b/Lab 06 - Loopy Lab/Chapter_06#7.py new file mode 100644 index 0000000..3f0b962 --- /dev/null +++ b/Lab 06 - Loopy Lab/Chapter_06#7.py @@ -0,0 +1,11 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do 10 times +for i in range(10): + #print an * and a space + print('*', end=' ') diff --git a/Lab 06 - Loopy Lab/Chapter_06#8.py b/Lab 06 - Loopy Lab/Chapter_06#8.py new file mode 100644 index 0000000..7f17482 --- /dev/null +++ b/Lab 06 - Loopy Lab/Chapter_06#8.py @@ -0,0 +1,14 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do this 10 times +for i in range(10): + #print 10 *'s on 1 line + for j in range(10): + print('*',end=' ') + #print a new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/Chapter_06#9.py b/Lab 06 - Loopy Lab/Chapter_06#9.py new file mode 100644 index 0000000..6a6c72f --- /dev/null +++ b/Lab 06 - Loopy Lab/Chapter_06#9.py @@ -0,0 +1,18 @@ +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/13/2017 + +"""Lab 06 programs""" + +#Do this 10 times + +for i in range(10): + #print leading spaces + #print the digits + for j in range(i): + print(' ',end=' ') + for j in range(10-i): + print(j,end=' ') + #print a new line + print() \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index 3f0b962..f340248 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -5,7 +5,15 @@ """Lab 06 programs""" -#Do 10 times -for i in range(10): - #print an * and a space - print('*', end=' ') +# Starting Value at 10 +start = 10 + +# Do 9 times +for i in range(9): + # Loop to print digits + for j in range(i + 1): + # Prints starting variable and then adds 1 to it. + print(start, end = ' ') + start += 1 + # Prints new line + print() \ No newline at end of file From 2b9662198aa1f55dcd1db08c54a1128d6f3f9a14 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Wed, 15 Nov 2017 13:37:02 -0600 Subject: [PATCH 25/47] Fixed the date and description of Lab 06 part 1 --- Lab 06 - Loopy Lab/part_1.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index f340248..135b816 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -1,9 +1,9 @@ #!/usr/bin/env python3 # Lab 06 Loopy Lab # Conner Walkenhorst -# 11/13/2017 +# 11/15/2017 -"""Lab 06 programs""" +"""Lab 06 part 1""" # Starting Value at 10 start = 10 From 7c7ed46802e07c45f26d102659d2429e55d254d7 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Wed, 15 Nov 2017 13:44:34 -0600 Subject: [PATCH 26/47] Started getting the base outline of code for Lab 06 part 2 --- Lab 06 - Loopy Lab/part_2.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 792d600..6e65ba0 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -1 +1,9 @@ -# +#!/usr/bin/env python3 +# Lab 06 Loopy Lab +# Conner Walkenhorst +# 11/15/2017 + +"""Lab 06 part 2""" + +#input for user to say how many o's to print +# \ No newline at end of file From 8e45c4038729d8d4136bd07af9b3f2f9be2f4b1e Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Thu, 16 Nov 2017 12:33:07 -0600 Subject: [PATCH 27/47] finished Lab 6 part 2, overcame struggles with code through lyles's help. --- Lab 06 - Loopy Lab/part_2.py | 13 ++++++++++++- Lab 06 - Loopy Lab/part_4.py | 14 +++----------- 2 files changed, 15 insertions(+), 12 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 6e65ba0..aec3fb2 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -6,4 +6,15 @@ """Lab 06 part 2""" #input for user to say how many o's to print -# \ No newline at end of file +numberOs = int(input("How many o's do you want? ")) +spaces = ((numberOs*2) - 2) +#loop for o's on top corresponding to user's input +for i in range(numberOs): + print('o'*2, end = '') +print() +#loop for o's on left side corresponding to user's input +for j in range(1, numberOs - 1): + print('o' + (' ' * spaces) +'o') +#loop for o's on bottom corresponding to user's input +for row in range(numberOs): + print('o'*2, end = '') \ No newline at end of file diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index 6a6c72f..76d526f 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -5,14 +5,6 @@ """Lab 06 programs""" -#Do this 10 times - -for i in range(10): - #print leading spaces - #print the digits - for j in range(i): - print(' ',end=' ') - for j in range(10-i): - print(j,end=' ') - #print a new line - print() \ No newline at end of file +for y in range(0, 200, 20): + for x in range(0, 400, 20): + \ No newline at end of file From 5d1cf1e369f71a841969930d3efc7ac316aaf76a Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Thu, 16 Nov 2017 12:48:54 -0600 Subject: [PATCH 28/47] Lab 6 part 4, so far I have gotten the window to open. --- Lab 06 - Loopy Lab/part_4.py | 67 ++++++++++++++++++++++++++++++++++-- 1 file changed, 64 insertions(+), 3 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index 76d526f..cdfffdf 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -5,6 +5,67 @@ """Lab 06 programs""" -for y in range(0, 200, 20): - for x in range(0, 400, 20): - \ No newline at end of file +""" + 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 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 Game") + +# 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(BLACK) + + # --- 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) + +for y in range(0, 500, 20): + for x in range(0, 700, 20): + +# Close the window and quit. + pygame.quit() \ No newline at end of file From 34d83bc33a9f83f909f993f7bc8db0a7bd0444c8 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Thu, 16 Nov 2017 13:13:05 -0600 Subject: [PATCH 29/47] I completed Lab 6 part 4. --- Lab 06 - Loopy Lab/part_4.py | 40 +++++++++++++++++++++++++++++++----- 1 file changed, 35 insertions(+), 5 deletions(-) diff --git a/Lab 06 - Loopy Lab/part_4.py b/Lab 06 - Loopy Lab/part_4.py index cdfffdf..317d758 100644 --- a/Lab 06 - Loopy Lab/part_4.py +++ b/Lab 06 - Loopy Lab/part_4.py @@ -4,7 +4,6 @@ # 11/13/2017 """Lab 06 programs""" - """ Pygame base template for opening a window @@ -32,6 +31,36 @@ pygame.display.set_caption("My Game") +# Loop until the user clicks the close button. +done = False +""" +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 pygame + +# Define some colors +BLACK = (0, 0, 0) +WHITE = (255, 255, 255) +GREEN = (0, 255, 0) +RED = (255, 0, 0) +BLUE = (31, 244, 255) + +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 Game") + # Loop until the user clicks the close button. done = False @@ -57,6 +86,9 @@ screen.fill(BLACK) # --- Drawing code should go here + for y in range(0, 500, 20): + for x in range(0, 700, 20): + pygame.draw.rect(screen, BLUE, (x, y, 10, 10)) # --- Go ahead and update the screen with what we've drawn. pygame.display.flip() @@ -64,8 +96,6 @@ # --- Limit to 60 frames per second clock.tick(60) -for y in range(0, 500, 20): - for x in range(0, 700, 20): - # Close the window and quit. - pygame.quit() \ No newline at end of file +pygame.quit() + From 92d452d407ad81fea4ac909ae2493476b78d5aef Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:18:39 -0600 Subject: [PATCH 30/47] Delete Chapter_06#10.py --- Lab 06 - Loopy Lab/Chapter_06#10.py | 15 --------------- 1 file changed, 15 deletions(-) delete mode 100644 Lab 06 - Loopy Lab/Chapter_06#10.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#10.py b/Lab 06 - Loopy Lab/Chapter_06#10.py deleted file mode 100644 index 0b63434..0000000 --- a/Lab 06 - Loopy Lab/Chapter_06#10.py +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/env python3 -# Lab 06 Loopy Lab -# Conner Walkenhorst -# 11/13/2017 - -"""Lab 06 programs""" - -#Do 9 times starting at 1 (row) -for row in range(1,10): - - #Loop to print multiples - for i in range(1,10): - print(repr(row*i).rjust(2),end=' ') - #print a new line - print() \ No newline at end of file From 8fd8106b00d4090c9f96911cb7865bf1679b02b0 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:18:50 -0600 Subject: [PATCH 31/47] Delete Chapter_06#11.py --- Lab 06 - Loopy Lab/Chapter_06#11.py | 24 ------------------------ 1 file changed, 24 deletions(-) delete mode 100644 Lab 06 - Loopy Lab/Chapter_06#11.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#11.py b/Lab 06 - Loopy Lab/Chapter_06#11.py deleted file mode 100644 index 90d2156..0000000 --- a/Lab 06 - Loopy Lab/Chapter_06#11.py +++ /dev/null @@ -1,24 +0,0 @@ -#!/usr/bin/env python3 -# Lab 06 Loopy Lab -# Conner Walkenhorst -# 11/13/2017 - -"""Lab 06 programs""" - -#Do 9 times starting at 1 (row) -for row in range(1,10): - - #Loop to print spaces - for space in range(9 - row): - print(' ', end=' ') - - #Loop to print digits - for digit in range(1, row + 1): - print(digit,end=' ') - - #Loop to print digits2 - for digit2 in range(row - 1,0,-1): - print(digit2, end=' ') - - #print a new line - print() \ No newline at end of file From daf9ca4e5f2539020d9b7afcca3edabafe219cef Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:18:58 -0600 Subject: [PATCH 32/47] Delete Chapter_06#12.py --- Lab 06 - Loopy Lab/Chapter_06#12.py | 37 ----------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Lab 06 - Loopy Lab/Chapter_06#12.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#12.py b/Lab 06 - Loopy Lab/Chapter_06#12.py deleted file mode 100644 index 68bf4f2..0000000 --- a/Lab 06 - Loopy Lab/Chapter_06#12.py +++ /dev/null @@ -1,37 +0,0 @@ -#!/usr/bin/env python3 -# Lab 06 Loopy Lab -# Conner Walkenhorst -# 11/13/2017 - -"""Lab 06 programs""" - -#Do 9 times starting at 1 (row) -for row in range(1,10): - - #Loop to print spaces - for space in range(9 - row): - print(' ', end=' ') - - #Loop to print digits - for digit in range(1, row + 1): - print(digit,end=' ') - - #Loop to print digits2 - for digit2 in range(row - 1,0,-1): - print(digit2, end=' ') - - #print a new line - print() - -#Do 8 times starting at 8 down to 1 -for row2 in range(8,0,-1): - - #Loop to print spaces - for space in range(9 - row2): - print(' ',end=' ') - - #Loop to print digits - for digit3 in range(1,row2 + 1): - print(digit3,end=' ') - #print new line - print() \ No newline at end of file From 6989da217b715b34eb4d78a228aaade1e43d330e Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:19:07 -0600 Subject: [PATCH 33/47] Delete Chapter_06#13.py --- Lab 06 - Loopy Lab/Chapter_06#13.py | 42 ----------------------------- 1 file changed, 42 deletions(-) delete mode 100644 Lab 06 - Loopy Lab/Chapter_06#13.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#13.py b/Lab 06 - Loopy Lab/Chapter_06#13.py deleted file mode 100644 index 4714699..0000000 --- a/Lab 06 - Loopy Lab/Chapter_06#13.py +++ /dev/null @@ -1,42 +0,0 @@ -#!/usr/bin/env python3 -# Lab 06 Loopy Lab -# Conner Walkenhorst -# 11/13/2017 - -"""Lab 06 programs""" - -#Do 9 times starting at 1 (row) -for row in range(1,10): - - #Loop to print spaces - for space in range(9 - row): - print(' ', end=' ') - - #Loop to print digits - for digit in range(1, row + 1): - print(digit,end=' ') - - #Loop to print digits2 - for digit2 in range(row - 1,0,-1): - print(digit2, end=' ') - - #print a new line - print() - -#Do 8 times starting at 8 down to 1 -for row2 in range(8,0,-1): - - #Loop to print spaces - for space in range(9 - row2): - print(' ',end=' ') - - #Loop to print digits3 - for digit3 in range(1,row2 + 1): - print(digit3,end=' ') - - #Loop to print digits3 - for digit4 in range(row2 - 1, 0, -1): - print(digit4,end=' ') - - #print new line - print() \ No newline at end of file From 5c0b2ae223f7d6cf6ab215d847b237d6e2b2cfb4 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:19:13 -0600 Subject: [PATCH 34/47] Delete Chapter_06#7.py --- Lab 06 - Loopy Lab/Chapter_06#7.py | 11 ----------- 1 file changed, 11 deletions(-) delete mode 100644 Lab 06 - Loopy Lab/Chapter_06#7.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#7.py b/Lab 06 - Loopy Lab/Chapter_06#7.py deleted file mode 100644 index 3f0b962..0000000 --- a/Lab 06 - Loopy Lab/Chapter_06#7.py +++ /dev/null @@ -1,11 +0,0 @@ -#!/usr/bin/env python3 -# Lab 06 Loopy Lab -# Conner Walkenhorst -# 11/13/2017 - -"""Lab 06 programs""" - -#Do 10 times -for i in range(10): - #print an * and a space - print('*', end=' ') From d15eb524fd09046741a364e6a37f3446d816a055 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:19:20 -0600 Subject: [PATCH 35/47] Delete Chapter_06#8.py --- Lab 06 - Loopy Lab/Chapter_06#8.py | 14 -------------- 1 file changed, 14 deletions(-) delete mode 100644 Lab 06 - Loopy Lab/Chapter_06#8.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#8.py b/Lab 06 - Loopy Lab/Chapter_06#8.py deleted file mode 100644 index 7f17482..0000000 --- a/Lab 06 - Loopy Lab/Chapter_06#8.py +++ /dev/null @@ -1,14 +0,0 @@ -#!/usr/bin/env python3 -# Lab 06 Loopy Lab -# Conner Walkenhorst -# 11/13/2017 - -"""Lab 06 programs""" - -#Do this 10 times -for i in range(10): - #print 10 *'s on 1 line - for j in range(10): - print('*',end=' ') - #print a new line - print() \ No newline at end of file From 5daf7fe00cd82dd8667c307c80d26391f8e9ae93 Mon Sep 17 00:00:00 2001 From: Conner Walkenhorst <33132628+ConnerW1719@users.noreply.github.com> Date: Thu, 16 Nov 2017 13:19:26 -0600 Subject: [PATCH 36/47] Delete Chapter_06#9.py --- Lab 06 - Loopy Lab/Chapter_06#9.py | 18 ------------------ 1 file changed, 18 deletions(-) delete mode 100644 Lab 06 - Loopy Lab/Chapter_06#9.py diff --git a/Lab 06 - Loopy Lab/Chapter_06#9.py b/Lab 06 - Loopy Lab/Chapter_06#9.py deleted file mode 100644 index 6a6c72f..0000000 --- a/Lab 06 - Loopy Lab/Chapter_06#9.py +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env python3 -# Lab 06 Loopy Lab -# Conner Walkenhorst -# 11/13/2017 - -"""Lab 06 programs""" - -#Do this 10 times - -for i in range(10): - #print leading spaces - #print the digits - for j in range(i): - print(' ',end=' ') - for j in range(10-i): - print(j,end=' ') - #print a new line - print() \ No newline at end of file From e9c857a8408e6daac17f869d8014863ae423a87b Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Mon, 20 Nov 2017 12:02:48 -0600 Subject: [PATCH 37/47] Finished number 5 on worksheet 7 --- Lab 07 - Adventure/main_program.py | 2 +- Worksheets/worksheet_07.txt | 12 ++++++++++++ 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 792d600..4287ca8 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1 +1 @@ -# +# \ No newline at end of file diff --git a/Worksheets/worksheet_07.txt b/Worksheets/worksheet_07.txt index a87ff3f..6b12c59 100644 --- a/Worksheets/worksheet_07.txt +++ b/Worksheets/worksheet_07.txt @@ -9,6 +9,8 @@ 1. List the four types of data we've covered, and give an example of each: + String, Ex: "hello". Integer, Ex: 1. Floating point, 3.145. 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, but if you don't understand why, make sure to ask. @@ -19,12 +21,16 @@ print(my_list[4]) print(my_list[5]) + 2, 101, and IndexError: list index out of range + 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? my_list1 = [5, 2, 6, 8, 101] @@ -34,6 +40,8 @@ my_list2[2] = 10 print(my_list2) + [5, 2, 6, 10, 101], and TypeError: 'tuple' object does not support item assignment + 5. What does this code print out? my_list = [3 * 5] @@ -41,6 +49,8 @@ my_list = [3] * 5 print(my_list) + [15], and [3, 3, 3, 3, 3]. + 6. What does this code print out? my_list = [5] @@ -48,6 +58,8 @@ my_list.append(i) print(my_list) + + 7. What does this code print out? print(len("Hi")) From 6929e7fb46106fabfd4a36a2b9e8535f2ffda85a Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Mon, 20 Nov 2017 12:20:49 -0600 Subject: [PATCH 38/47] Finished numbers through 11 on worksheet 7 --- Worksheets/worksheet_07.txt | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/Worksheets/worksheet_07.txt b/Worksheets/worksheet_07.txt index 6b12c59..ecedc76 100644 --- a/Worksheets/worksheet_07.txt +++ b/Worksheets/worksheet_07.txt @@ -58,7 +58,7 @@ my_list.append(i) print(my_list) - + [5, 0, 1, 2, 3, 4] 7. What does this code print out? @@ -68,18 +68,24 @@ print(len("2")) print(len(2)) + 2, 9, 8, 1, and 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, and i + 9. What does this code print out? word = "Simpson" for letter in word: print(letter) + S, i, m, p, s, o, n all on their own lines + 10. What does this code print out? word = "Simpson" @@ -87,17 +93,23 @@ 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]) + + 13. What does this code print out? s = "0123456789" From 88e8d179b6bb66a7e843806344f111fac4d8ed41 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Mon, 20 Nov 2017 13:19:58 -0600 Subject: [PATCH 39/47] Finished worksheet 7, numbers 1 through 15 --- Worksheets/worksheet_07.txt | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/Worksheets/worksheet_07.txt b/Worksheets/worksheet_07.txt index ecedc76..6ca034e 100644 --- a/Worksheets/worksheet_07.txt +++ b/Worksheets/worksheet_07.txt @@ -108,7 +108,7 @@ print("The 3rd spot is: " + my_text[3]) print("The -1 spot is: " + my_text[-1]) - + The 3rd spot is:, and The -1 spot is: . both on separate lines. 13. What does this code print out? @@ -117,10 +117,18 @@ print(s[:3]) print(s[3:]) + 1, 012, 3456789 all on separate lines. + 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. + myList = [] +userList = input('Enter 5 numbers: ') +for items in userList: + myList.append(int(items)) +print(myList) + 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. @@ -129,4 +137,8 @@ my_list = [3,12,3,5,3,4,6,8,5,3,5,6,3,2,4] - + myList = [3,12,3,5,3,4,6,8,5,3,5,6,3,2,4] +ListSum = sum(myList) +ListLength = len(myList) +ListAverage = ListSum/ListLength +print(ListAverage) From db3570f4547289333438b36a07c10904c4eb7394 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Mon, 20 Nov 2017 13:23:35 -0600 Subject: [PATCH 40/47] started on lab 7, got the base code that should be on every program done. --- Lab 07 - Adventure/main_program.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 4287ca8..58358e5 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1 +1,7 @@ -# \ No newline at end of file +#!/usr/bin/env python3 +# Lab 7: Adventure +# Conner Walkenhorst +# 11/20/2017 + +"""Create a text adventure game using python""" + From 06a304543af00678fd3d035aead63cdfb823f35f Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Tue, 28 Nov 2017 11:30:32 -0600 Subject: [PATCH 41/47] test 1 for lab 7 text adventure. --- Lab 07 - Adventure/main_program.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 58358e5..695c5ba 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -5,3 +5,22 @@ """Create a text adventure game using python""" +room_list = [] +room = ["The Entryway", None, None, 3, None] +room_list.append(room) +room = ["Office Room", None, None, 4, None] +room_list.append(room) +room = ["Ballpit Room", None, None, 5, None] +room_list.append(room) +room = ["West Hall", 0, 4, 6, None] +room_list.append(room) +room = ["Center Hall", 1, 5, 7, 3] +room_list.append(room) +room = ["East Hall", 2, None, 8, 4] +room_list.append(room) +room = ["Weight Room", 2, None, None, None] +room_list.append(room) +room = ["Knive Room", 4, None, None, None] +room_list.append(room) +room = ["Balloon Room", 5, None, None, None] +room_list.append(room) From 3334cdb0504381ac9eacc629d8eb01a96cadc267 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Tue, 28 Nov 2017 12:13:38 -0600 Subject: [PATCH 42/47] got map and direction north initailized and user input for them working. --- Lab 07 - Adventure/main_program.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 695c5ba..b0b08a2 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -5,6 +5,7 @@ """Create a text adventure game using python""" +current_room = 0 room_list = [] room = ["The Entryway", None, None, 3, None] room_list.append(room) @@ -20,7 +21,8 @@ room_list.append(room) room = ["Weight Room", 2, None, None, None] room_list.append(room) -room = ["Knive Room", 4, None, None, None] +room = ["Blade Room", 4, None, None, None] room_list.append(room) room = ["Balloon Room", 5, None, None, None] room_list.append(room) +print(current_room) From c77d9c03ded0365ba5920d19ccf2c2eea5cb942b Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Tue, 28 Nov 2017 12:27:16 -0600 Subject: [PATCH 43/47] got all 4 directions for the user initiated. --- Lab 07 - Adventure/main_program.py | 37 +++++++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index b0b08a2..b218e63 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -6,6 +6,7 @@ """Create a text adventure game using python""" current_room = 0 + room_list = [] room = ["The Entryway", None, None, 3, None] room_list.append(room) @@ -25,4 +26,38 @@ room_list.append(room) room = ["Balloon Room", 5, None, None, None] room_list.append(room) -print(current_room) + +done = False + +while done == False: + print() + print(room_list[current_room][0]) + user_choice = input("Where would you like to go? ") + + if user_choice == "North": + next_room = room_list[current_room][1] + if next_room == None: + print("You can't go that way.") + else: + next_room = current_room + + if user_choice == "East": + next_room = room_list[current_room][2] + if next_room == None: + print("You can't go that way.") + else: + next_room = current_room + + if user_choice == "South": + next_room = room_list[current_room][3] + if next_room == None: + print("You can't go that way.") + else: + next_room = current_room + + if user_choice == "West": + next_room = room_list[current_room][4] + if next_room == None: + print("You can't go that way.") + else: + next_room = current_room From d7eb91f86156bfbf88ef39c1044d0545bbe874b9 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Tue, 28 Nov 2017 12:40:23 -0600 Subject: [PATCH 44/47] finished lab 7 into a working text adventure game. --- Lab 07 - Adventure/main_program.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index b218e63..73b3456 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -5,8 +5,6 @@ """Create a text adventure game using python""" -current_room = 0 - room_list = [] room = ["The Entryway", None, None, 3, None] room_list.append(room) @@ -20,7 +18,7 @@ room_list.append(room) room = ["East Hall", 2, None, 8, 4] room_list.append(room) -room = ["Weight Room", 2, None, None, None] +room = ["Weight Room", 3, None, None, None] room_list.append(room) room = ["Blade Room", 4, None, None, None] room_list.append(room) @@ -28,6 +26,7 @@ room_list.append(room) done = False +current_room = 0 while done == False: print() @@ -39,25 +38,28 @@ if next_room == None: print("You can't go that way.") else: - next_room = current_room + current_room = next_room - if user_choice == "East": + elif user_choice == "East": next_room = room_list[current_room][2] if next_room == None: print("You can't go that way.") else: - next_room = current_room + current_room = next_room - if user_choice == "South": + elif user_choice == "South": next_room = room_list[current_room][3] if next_room == None: print("You can't go that way.") else: - next_room = current_room + current_room = next_room - if user_choice == "West": + elif user_choice == "West": next_room = room_list[current_room][4] if next_room == None: print("You can't go that way.") else: - next_room = current_room + current_room = next_room + + else: + print("say again? ") From 5f9ef99e13957752f66b0add0ac3084139bd8f9e Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Wed, 29 Nov 2017 11:34:30 -0600 Subject: [PATCH 45/47] put in and fixed up the code on the front board that tells the user where their are exits. --- Lab 07 - Adventure/main_program.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 73b3456..4f00299 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -31,6 +31,16 @@ while done == False: print() print(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_choice = input("Where would you like to go? ") if user_choice == "North": @@ -62,4 +72,4 @@ current_room = next_room else: - print("say again? ") + print("say again?") From e9bcc0cdfe7509e9f87418e2719ddf7382df4178 Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Wed, 29 Nov 2017 11:57:54 -0600 Subject: [PATCH 46/47] finished lab 7, added code that makes the program still function as long as the user's input starts with one of the directional letters. --- Lab 07 - Adventure/main_program.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 4f00299..6d1b4cd 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -43,28 +43,28 @@ user_choice = input("Where would you like to go? ") - if user_choice == "North": + if user_choice.lower()[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 - elif user_choice == "East": + elif user_choice.lower()[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 - elif user_choice == "South": + elif user_choice.lower()[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 - elif user_choice == "West": + elif user_choice.lower()[0] == "w": next_room = room_list[current_room][4] if next_room == None: print("You can't go that way.") From 32b8f6a844af63bed1ca10c1e92342455d9f89cc Mon Sep 17 00:00:00 2001 From: ConnerW1719 Date: Thu, 30 Nov 2017 11:10:06 -0600 Subject: [PATCH 47/47] Attempting to push --- 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 6d1b4cd..4cf14b6 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -40,7 +40,7 @@ print("\tThere is an exit to the South.") if room_list[current_room][4] != None: print("\tThere is an exit to the West.") - + f user_choice = input("Where would you like to go? ") if user_choice.lower()[0] == "n":