From 7e6d8a517c4ba256bf9f7bb765a7ef813d025507 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Thu, 2 Nov 2017 08:47:53 -0500 Subject: [PATCH 01/17] Completed Chapter 1 --- Lab 01 - Calculator/lab_01_part_a.py | 5 ++- Lab 01 - Calculator/lab_01_part_b.py | 8 ++++- Lab 01 - Calculator/lab_01_part_c.py | 6 +++- .../.~lock.Chapter 2 report on video.docx# | 1 + Worksheets/worksheet_01.txt | 36 ++++++++++++++----- Worksheets/worksheet_02.txt | 15 +++++++- 6 files changed, 58 insertions(+), 13 deletions(-) create mode 100644 Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# diff --git a/Lab 01 - Calculator/lab_01_part_a.py b/Lab 01 - Calculator/lab_01_part_a.py index 792d600..3e97c51 100644 --- a/Lab 01 - Calculator/lab_01_part_a.py +++ b/Lab 01 - Calculator/lab_01_part_a.py @@ -1 +1,4 @@ -# +# 1.1 Part A +Fahrenheit= int(input("Enter temperature in Fahrenheit: ")) +Celsius= ((Fahrenheit-32)*(5/9)) +print("The temperature in Celsius:", Celsius) diff --git a/Lab 01 - Calculator/lab_01_part_b.py b/Lab 01 - Calculator/lab_01_part_b.py index 792d600..16fb163 100644 --- a/Lab 01 - Calculator/lab_01_part_b.py +++ b/Lab 01 - Calculator/lab_01_part_b.py @@ -1 +1,7 @@ -# +# 1.2 Part B +print("Area of a trapezoid") +height= int(input("Enter the height of the trapezoid: ")) +lengthBottom= int(input("Enter the length of the bottom base: ")) +lengthTop= int(input("Enter the length of the top base: ")) +area= ((1/2)*(lengthBottom+lengthTop)*height) +print("The area is:",area) diff --git a/Lab 01 - Calculator/lab_01_part_c.py b/Lab 01 - Calculator/lab_01_part_c.py index 792d600..3a3fdc5 100644 --- a/Lab 01 - Calculator/lab_01_part_c.py +++ b/Lab 01 - Calculator/lab_01_part_c.py @@ -1 +1,5 @@ -# +# 1.3 Part C +print('For the volume of a sphere.') +radius= int(input('Enter the radius: ')) +volume= ((4/3)*(3.14*(radius**3))) +print('The volume is about', volume, '.') diff --git a/Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# b/Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# new file mode 100644 index 0000000..015bd02 --- /dev/null +++ b/Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# @@ -0,0 +1 @@ +,mnelson,PC05.CIS.COM,02.11.2017 07:57,file:///home/mnelson/.config/libreoffice/4; \ No newline at end of file diff --git a/Worksheets/worksheet_01.txt b/Worksheets/worksheet_01.txt index 728ad02..b093071 100644 --- a/Worksheets/worksheet_01.txt +++ b/Worksheets/worksheet_01.txt @@ -6,22 +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('Evie Nelson') 2. How do you enter a comment in a program? - + #comment 3. What do the following lines of code output? ALSO: Why do they give a different answer? - print(2 / 3) - print(2 // 3) + print(2 / 3) outputs 0.66666666 + print(2 // 3) outputs 0 + They output different answers since they are different equations. 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) + The varaible is a capital a, so the print should be print(A). 6. All of the variable names below can be used. But which ONE of these is the better variable name to use? @@ -33,6 +35,7 @@ area area_of_rectangle Area_Of_Rectangle + The last one, Area_Of_Rectangle, is the best to use since it is the most specific. 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 @@ -60,15 +63,18 @@ x2x total% #left + The variables #left, account number, account.number, great.big.variable, 2x, 1Apple, total%, and account# are not valid variable names in python. 8. Why does this code not work? print(a) a = 45 + The variable a needs to be before the print line. 9. Explain the mistake in this code: pi = float(3.14) + There is no print function. 10. This program runs, but the code still could be better. Explain what is wrong with the code. @@ -78,6 +84,7 @@ pi = x area = pi * radius ** 2 print(area) + The varaible pi could be set to 3.14 instead of x. 11. Explain the mistake in the following code: @@ -85,6 +92,7 @@ y = 5 a = ((x) * (y)) print(a) + The a = ((x) * (y)) could be changed to a = (x*y). 12. Explain the mistake in the following code: @@ -92,23 +100,29 @@ y = 5 a = 3(x + y) print(a) + The a = 3(x + y) should be a = (3*(x+y)). 13. Explain the mistake in the following code: radius = input(float("Enter the radius:")) + It should be radius = float(input("Enter the radius:")). 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 ) + They all work but the first one is best to use since it is the easiest to read and understand. 15. What is a constant? + A variable that is set to one value and therefore is always that value. 16. How are variable names for constants different than other variable names? + They never change. 17. What is a single quote and what is a double quote? Give and label an example of both. + A single quote is ' and a double quote is " . 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 @@ -116,30 +130,34 @@ 19. Can a Python program print text to the screen using single quotes instead of double quotes? + Yes. 20. Why does this code not calculate the average? print(3 + 4 + 5 / 3) - + The 3, 4, and 5 added together need to be in () so they will be added together before being didveded by 3. 21. What is an ``operator'' in Python? + The symbols that allow math equations to be done in python. Such as <, >, +, -, *, **, and /. 22. What does the following program print out? x = 3 x + 1 print(x) - + It will print out 3. 23. Correct the following code: user_name = input("Enter your name: )" - + The correct code would be user_name = input("Enter your name: ") 24. Correct the following code: value = int(input(print("Enter your age"))) - + The code needs to be: + value = int(input("Enter your age")) + print(value) diff --git a/Worksheets/worksheet_02.txt b/Worksheets/worksheet_02.txt index abe4cd7..ac48ce5 100644 --- a/Worksheets/worksheet_02.txt +++ b/Worksheets/worksheet_02.txt @@ -6,32 +6,45 @@ 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.) + The decimal of 10 has a binary of 1010 and a hexadecimal of A. 2. Give an example of a decimal number. + 5 3. Give an example of a hexadecimal number. + 11 4. Convert the numbers 1, 10, 100, 1000, and 10000 from binary to decimal. + The decimals would be 1, 2, 4, 8, and 16. - 5. What is a compiler? + 5. What is a compiler? + A compiler changes the program entered by the user into machine code. 6. What is source code? + The code typed in by the user. 7. What is machine language? (Don't just say binary. That's not correct.) + Machine language and machine code are the only languages computers can understand, they use numbers to represent commands. 8. What is a first generation language? (Don't just say binary. That's not correct.) + The first programming language, it is the same thing as the machine's native language. 9. What is a second generation language? + The second generation language is an assembly language that uses a mnemonic, that is changed with a compiler to the machine's native language. 10. What is a third generation language? (Explain, don't just give one example.) + The third generation language is a type of source code typed in by the user that is changed into machine code by the compiler. 11. What is an interpreter and how does it differ from a compiler? + An interpreter translates the source code into machine code for any type of computer, while a compiler only works for some types. 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, and JavaScript are the five most popular programming languages according to inc.com. 13. Look at the job boards and see what languages people are looking for. List the languages and the job board you looked at. + 14. What is the difference between the ``syntax'' and ``semantics'' of a language? From 33b6ecea28fba78a725a93d8f8ce2b5790708658 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Thu, 2 Nov 2017 08:58:30 -0500 Subject: [PATCH 02/17] Completed Chapter 1 and Chapter 2 worksheet --- Worksheets/worksheet_02.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Worksheets/worksheet_02.txt b/Worksheets/worksheet_02.txt index ac48ce5..e42c602 100644 --- a/Worksheets/worksheet_02.txt +++ b/Worksheets/worksheet_02.txt @@ -48,8 +48,10 @@ 14. What is the difference between the ``syntax'' and ``semantics'' of a language? + Syntax is the structure or grammar of a language, while semantics is the meaning behind the language. 15. Pick a piece of technology, other than a computer you use regularly. Briefly describe the hardware and software that run on it. + From 8452f3b57b4214d1619647994337d9afdcc6dc9b Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Mon, 6 Nov 2017 08:08:56 -0600 Subject: [PATCH 03/17] Completed Chapter 3 --- .../.~lock.Chapter 2 report on video.docx# | 1 - Lab 03 - Create a Quiz/main_program.py | 54 ++++++++++- Worksheets/worksheet_03.txt | 97 ++++++++++++++++++- 3 files changed, 149 insertions(+), 3 deletions(-) delete mode 100644 Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# diff --git a/Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# b/Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# deleted file mode 100644 index 015bd02..0000000 --- a/Lab 02 - Computer History/.~lock.Chapter 2 report on video.docx# +++ /dev/null @@ -1 +0,0 @@ -,mnelson,PC05.CIS.COM,02.11.2017 07:57,file:///home/mnelson/.config/libreoffice/4; \ No newline at end of file diff --git a/Lab 03 - Create a Quiz/main_program.py b/Lab 03 - Create a Quiz/main_program.py index 792d600..75fe05f 100644 --- a/Lab 03 - Create a Quiz/main_program.py +++ b/Lab 03 - Create a Quiz/main_program.py @@ -1 +1,53 @@ -# +print("Time for a Quiz!") +print("") +total= 0 + +question_one = int(input("1. What is my favorite number? ")) +if question_one == 8: + total= total+1 + print("Correct!") +else: + print("Incorrect.") +print("") + +question_two = input("2. What did Jack break when he fell down? ") +if question_two == "his crown": + print("Correct!") + total= total+1 +else: + print("Incorrect.") +print("") +print("3. What do your eyes do?") +answer_one= "1. smell" +answer_two= "2. see" +answer_three= "3. hear" +print(answer_one) +print(answer_two) +print(answer_three) +question_three= input("? ") +if question_three == "see": + print("Correct!") + total= total+1 +else: + print("Incorrect!") +print("") + +question_four= input("4. Is this the fourth question? ") +if question_four == "yes": + print("Correct!") + total= total+1 +else: + print("Incorrect.") +print("") + +question_five= input("What is the radius of the sun in miles? ") +if question_five== "432,288": + print("Correct!") + total= total+1 +else: + print("Incorrect.") +print("") + +print("Wow! You got", total, "questions right!") +print("That means your total score is", (100*(total/5)),"percent!") +print("") diff --git a/Worksheets/worksheet_03.txt b/Worksheets/worksheet_03.txt index bc85b84..539c66b 100644 --- a/Worksheets/worksheet_03.txt +++ b/Worksheets/worksheet_03.txt @@ -10,13 +10,26 @@ print("It is hot outside.") else: print("It is not hot out.") + The first line should read temperature = float(input("Temperature: ")), ending with two ). 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("The number is positive.") + elif number < 0: + print("The number is negitive.") + elif number == 0: + print("The 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 number > -10 < 10: + print("Success") + else: + print("") 4. This runs, but there is something wrong. What is it? (1 pt) @@ -27,6 +40,9 @@ print("Correct!") else: print("Incorrect.") + The two print statements after the user_input line will only print + after the user hits enter. The print statements in line one and two + should be put before the user_input line. 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. @@ -38,12 +54,15 @@ print("x is positive.") else: print("x is not positive.") + The x variable should only have one equal sign and 6. What three things are wrong with the following code? (3 pts) x = input("Enter a number: ") if x = 3 print("You entered 3") + The x = input( should be x = int(input( , the secind line needs to + be if x = 3: , and there is no else: clause. 7. There are four things wrong with this code. Identify all four issues. (4 pts) @@ -52,12 +71,15 @@ print("Correct!") else print("Incorrect! It is Beaker.") + The second line needs two equal signs, in the forth line else needs + to be else: and needs to be inline with the if line. 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!") + It needs an else: line incase the input isn't Happy or Glad. 9. Look at the code below. Write you best guess here on what it will print. Next, run the code and see if you are correct. @@ -78,6 +100,18 @@ print("Fizz") if z: print("Buzz") + I guess the program will print: + x= 5 + y= 6 + z= 5 + Buzz + Fizz + Buzz + When tested, the program outputs: + 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) @@ -96,6 +130,29 @@ print(x == 5 and y == 10) print(x == 5 and y == 5) print(x == 5 or y == 5) + I guess the program will output: + True + False + True + True + False + False + False + True + False + True + When tested, the program outputs: + 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) @@ -109,8 +166,27 @@ print( (2 == 2) == "True" ) print( (2 == 2) == True ) print(3 < "3") + I guess the program will output: + True + False + True + True + False + False + False + True + False + When tested, the program outputs: + True + False + True + True + True + False + False + True + Error - 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) @@ -129,7 +205,26 @@ money = 70 else if user_input = C: money = 50 + + The program should look like: + print("Welcome to Oregon Trail!") + + A = "A. Banker" + B = "B. Carpente" + C = "C. Farmer" + + print(A) + print(B) + print(C) + + user_input = input("What is your occupation?") + if user_input == A: + money = 100 + elif user_input == B: + money = 70 + elif user_input == C: + money = 50 From ea4014e4795b163f8d2a5d8644b82afcff4d5113 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Thu, 9 Nov 2017 09:32:16 -0600 Subject: [PATCH 04/17] Completed Chapter 4 --- Lab 04 - Camel/main_program.py | 93 +++++++++++++++++++++++++++++++++- Worksheets/worksheet_04.txt | 77 ++++++++++++++++++++++++++++ 2 files changed, 169 insertions(+), 1 deletion(-) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index 792d600..a379117 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -1 +1,92 @@ -# +# Completed Lab 4 +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! Survive your desert trek and out run the natives.") +print("Hint: all capitals.") +print() + +A = "A. Drink from your canteen." +B = "B. Ahead moderate speed." +C = "C. Ahead full speed." +D = "D. Stop for the night." +E = "E. Status check." +Q = "Q. Quit." +done = False +miles_traveled = 0 +thirst = 0 +camel_tiredness = 0 +natives_distance = -20 +canteen_drinks = 5 + +while not done: + print(A) + print(B) + print(C) + print(D) + print(E) + print(Q) + user_choice= input("Your choice: ") + if user_choice == "Q": + done=True + + elif user_choice == "E": + print() + print("Miles traveled:", miles_traveled) + print("Drinks in canteen:", canteen_drinks) + print("The natives are", natives_distance, "miles behind you.") + print() + elif user_choice == "D": + camel_tiredness= 0 + natives_distance+= random.randrange(7,14) + print() + print("Your camel is fully rested.") + print() + elif user_choice == "C": + miles_traveled+= random.randrange(10,21) + thirst= thirst+1 + camel_tiredness+= random.randrange(1,4) + natives_distance+= random.randrange(7,14) + print() + print("Your miles traveled are:", miles_traveled) + print() + elif user_choice == "B": + miles_traveled+= random.randrange(5,12) + thirst+= 1 + camel_tiredness+= 1 + natives_distance+= random.randrange(7,14) + print() + print("Your miles traveled are:", miles_traveled) + print() + elif user_choice == "A": + thirst= 0 + canteen_drinks-= 1 + print() + print("Your thrist is:", thirst) + print() + + if miles_traveled >= 200 and not done: + print("You've won the game!") + done= True + if thirst > 4 and thirst <= 6 and not done: + print("You are thirsty!") + print() + if thirst > 6: + print("You died of thirst.") + print("You lose.") + print() + done=True + if camel_tiredness > 5 and camel_tiredness <= 8 and not done: + print("Your camel is getting tired.") + print() + if camel_tiredness > 8: + print("Your camel is dead.") + print("You lose.") + done= True + if natives_distance >= miles_traveled: + print("The natives have caught up to you.") + print("You lose.") + done= True + if natives_distance > miles_traveled+15: + print("The natives are getting close!") + print() diff --git a/Worksheets/worksheet_04.txt b/Worksheets/worksheet_04.txt index 341b2fa..9a2c8f3 100644 --- a/Worksheets/worksheet_04.txt +++ b/Worksheets/worksheet_04.txt @@ -13,17 +13,30 @@ 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 i in range(10): + print("Evie Nelson") + 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(10): + 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, 102, 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. + i = 10 + while i > 0: + print(i) + i= i-1 + print("Blast off!") 5. There are three things wrong with this program. List each. (3 pts) @@ -34,12 +47,21 @@ x = input("Enter a number: ") total = total + i print("The total is:", x) + The x variable should be an i, the input statment should have an int + function before it, and in the print statement it should be the total + variable, not the x variable. 6. Write a program that prints a random integer from 1 to 10 (inclusive). + import random + my_number = random.randrange(1, 11) + print(my_number) 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 + my_number = random.random()*10+1 + print(my_number) 8. Write a Python program that will: (3 pts) @@ -48,6 +70,23 @@ * 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. + total= 0 + posnumber= 0 + zero= 0 + negnumber= 0 + for i in range(7): + usernumber= int(input("Enter a number: ")) + total+= usernumber + if usernumber > 0: + posnumber+= 1 + elif usernumber== 0: + zero+= 1 + elif usernumber < 0: + negnumber+= 1 + print("The sum of all the numbers entered is:", total) + print("The number of positive entries is:", posnumber) + print("The number of negitive entries is:", negnumber) + print("The number of entries that were the number zero is:", zero) 9. Coin flip tosser: (4 pts) @@ -56,6 +95,19 @@ 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. + totalHeads= 0 + totalTails= 0 + for i in range(50): + import random + coinflip= random.randrange(0,2) + if coinflip== 1: + print("heads") + totalHeads= totalHeads+1 + elif coinflip== 0: + print("tails") + totalTails= totalTails+1 + print("Total number of heads:", totalHeads) + print("Total number of tails:", totalTails) 10. Write a program that plays rock, paper, scissors: (4 pts) @@ -65,5 +117,30 @@ * 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. +print("I want to play rock, paper, scissors.") +useroutcome= input("What do you pick? ") +import random +outcome= random.randrange(0,3) +if useroutcome== "rock": + if outcome== 0: + print("Draw") + elif outcome== 1: + print("You lose.") + elif outcome== 2: + print("You win!") +elif useroutcome== "paper": + if outcome== 0: + print("You win!") + elif outcome== 1: + print("Draw") + elif outcome== 2: + print("You lose.") +elif useroutcome== "scissors": + if outcome== 0: + print("You lose.") + elif outcome== 1: + print("You win!") + elif outcome== 2: + print("Draw") From 9523a04ace8a01fad81d6453ea69a86203666dba Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Thu, 9 Nov 2017 09:49:16 -0600 Subject: [PATCH 05/17] Completed Lab 4 --- Lab 04 - Camel/main_program.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Lab 04 - Camel/main_program.py b/Lab 04 - Camel/main_program.py index a379117..ec2890c 100644 --- a/Lab 04 - Camel/main_program.py +++ b/Lab 04 - Camel/main_program.py @@ -47,6 +47,7 @@ thirst= thirst+1 camel_tiredness+= random.randrange(1,4) natives_distance+= random.randrange(7,14) + oasis= random.randrange(1,21) print() print("Your miles traveled are:", miles_traveled) print() @@ -65,6 +66,11 @@ print("Your thrist is:", thirst) print() + if oasis == 20: + camel_tiredness= 0 + thirst= 0 + canteen += 3 + print("You found an oasis! You are no longer thirsty, you filled your canteen and your camel has rested.") if miles_traveled >= 200 and not done: print("You've won the game!") done= True From 12aafa9b93b0aeafa148f57d7195e8f609289670 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Mon, 13 Nov 2017 07:55:04 -0600 Subject: [PATCH 06/17] Worked on worksheet five --- Worksheets/.worksheet_05.txt.kate-swp | Bin 0 -> 2451 bytes 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 Worksheets/.worksheet_05.txt.kate-swp diff --git a/Worksheets/.worksheet_05.txt.kate-swp b/Worksheets/.worksheet_05.txt.kate-swp new file mode 100644 index 0000000000000000000000000000000000000000..3aa50012a27071aaf15053509370797bb2611894 GIT binary patch literal 2451 zcmZ9O+fI`~5Xal3Xc3PE6&1A}0Ton44xT|l5fQZri5F_6<&Yo{M2Yb&d;;U058;is z`V!uI=>xdG>3*5NyGhgjc4lX0|GVEe&E;~X$?9gkT-mCwm&cb^>gB%POSxRGt@B0u z*T0|sd};pm{m0L5pF8@07uG9t!BPyL(Xq-z_-YOxMpK#Lb4_6`KjXX&UUJ?J*PRKO zm-WQWuep5(yy4seFFWsq7oB${_TBKR+xNhdZ*StiFZw?V-_!z^e7Tw5IhSykaILVE z*9J@a{fYkpc+=w@ghj4)SmZjCtUsKrKLU$<9q_uxKMMCaAA?2SNx{1c>c4Ae!}69dRFWB-)@O$p(_#65Dc1?Uq|= zvE1T69Kz|@T!ZCouEV0`4OrISgg<&cw-Wnp_=DT;z*64`yyEsz_`UO8Sn}V4Wj|xE z)H4ptUB3^@v-$v*yE6gH-FXO0zDZc>eFRJXsl@*=EcHyoa`&IWqVH2!@^L40eFc_! zXJC2up2MO3>@LBxE}xmjeKv6?{2UtaS_E3=*VZ;_%d4S>gk5@|m%*lWy@KDm{WUC! zs<52<8(8)^4~tGUSe~gmEb$iLEzh?I%egMWy<^tV*voXol}^LRI$9=^&1L%riq`V1 z>&*qE<4iR|&}=D?E_*QfZSr(^ bJd>xp!KGklh$2j>B5+f~yA{_kq9XqQ6j19O literal 0 HcmV?d00001 From c22b3913b00c30905a08f0b3b3b8a35587c07d18 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Tue, 14 Nov 2017 08:19:23 -0600 Subject: [PATCH 07/17] Edited worksheet 5 --- Worksheets/.worksheet_05.txt.kate-swp | Bin 2451 -> 0 bytes Worksheets/worksheet_05.txt | 7 ++++++- 2 files changed, 6 insertions(+), 1 deletion(-) delete mode 100644 Worksheets/.worksheet_05.txt.kate-swp diff --git a/Worksheets/.worksheet_05.txt.kate-swp b/Worksheets/.worksheet_05.txt.kate-swp deleted file mode 100644 index 3aa50012a27071aaf15053509370797bb2611894..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2451 zcmZ9O+fI`~5Xal3Xc3PE6&1A}0Ton44xT|l5fQZri5F_6<&Yo{M2Yb&d;;U058;is z`V!uI=>xdG>3*5NyGhgjc4lX0|GVEe&E;~X$?9gkT-mCwm&cb^>gB%POSxRGt@B0u z*T0|sd};pm{m0L5pF8@07uG9t!BPyL(Xq-z_-YOxMpK#Lb4_6`KjXX&UUJ?J*PRKO zm-WQWuep5(yy4seFFWsq7oB${_TBKR+xNhdZ*StiFZw?V-_!z^e7Tw5IhSykaILVE z*9J@a{fYkpc+=w@ghj4)SmZjCtUsKrKLU$<9q_uxKMMCaAA?2SNx{1c>c4Ae!}69dRFWB-)@O$p(_#65Dc1?Uq|= zvE1T69Kz|@T!ZCouEV0`4OrISgg<&cw-Wnp_=DT;z*64`yyEsz_`UO8Sn}V4Wj|xE z)H4ptUB3^@v-$v*yE6gH-FXO0zDZc>eFRJXsl@*=EcHyoa`&IWqVH2!@^L40eFc_! zXJC2up2MO3>@LBxE}xmjeKv6?{2UtaS_E3=*VZ;_%d4S>gk5@|m%*lWy@KDm{WUC! zs<52<8(8)^4~tGUSe~gmEb$iLEzh?I%egMWy<^tV*voXol}^LRI$9=^&1L%riq`V1 z>&*qE<4iR|&}=D?E_*QfZSr(^ bJd>xp!KGklh$2j>B5+f~yA{_kq9XqQ6j19O diff --git a/Worksheets/worksheet_05.txt b/Worksheets/worksheet_05.txt index 275a18a..d3cf948 100644 --- a/Worksheets/worksheet_05.txt +++ b/Worksheets/worksheet_05.txt @@ -7,12 +7,17 @@ 1. Explain how the computer coordinate system differs from the standard Cartesian coordinate system. There are two main differences. List both. + The origin is in the top-right of the screen and as the y values increase + the coordinates move down. 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 + pygame.init() 3. Explain how WHITE = (255, 255, 255) represents a 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.) From 61eb8aee25cf378958a70ca19ecafa325e021135 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Tue, 14 Nov 2017 10:10:42 -0600 Subject: [PATCH 08/17] Edited worksheet 6 --- Worksheets/worksheet_06.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index 35e5f13..d3812db 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -17,6 +17,8 @@ while x < 10: print(x) x = x + 2 + My guess: 0,2,4,6,8 on seperate lines + Output: 0,2,4,6,8 on seperate lines 2. What does this program print out? @@ -24,6 +26,8 @@ while x < 64: print(x) x = x * 2 + My guess: 1,2,4,8,16,32 on seperate lines + Output: 1,2,4,8,16,32 om seperate lines 3. Why is the and x >= 0 not needed? @@ -31,6 +35,7 @@ while x < 10 and x >= 0: print(x) x = x + 2 + You need to check for things that can never be false, ie x=0. 4. What does this program print out? (0 pts) Explain. (1 pt) @@ -40,6 +45,8 @@ if x == "1": print("Blast off!") x = x - 1 + This will print a countdown from 5 to 0, but will not print blastoff. + The print("Blast off!") will not print because it is the wrong part of the code. 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) From 6b1891e74c44e69420c5a3b69f9163310aad4455 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Wed, 15 Nov 2017 08:09:13 -0600 Subject: [PATCH 09/17] Almost completed chapter 6 worksheet --- Worksheets/worksheet_06.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index d3812db..812d7d5 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -55,6 +55,12 @@ while x <= 0: print("Too small. Enter a number greater than zero: ") + + The program should look like: +x = float(input("Enter a number greater than zero: ")) + +while x <= 0: + x = float(input("Too small. Enter a number greater than zero: ")) 6. Fix the following code: @@ -73,6 +79,9 @@ for i in range(10): print(i) i += 1 + The i = 0 part of the code is unneeded since the range function will + always start at 0. The i += 1 is also unnecessary since the code will + go by 1's until finished without it. 8. Explain why the values printed for x are so different. (2 pts) @@ -92,4 +101,6 @@ x += 1 print(x) - + For sample 1 the output is 20 since x is 10 plus 10, while for + sample 2 the code is in a loop so ten is added together 10 times, + and after looped 10 times the outside code adds 10. From b2ed41d91a8a412f6f8de39ddf7e0f92890b1f93 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Wed, 15 Nov 2017 08:16:29 -0600 Subject: [PATCH 10/17] Completed Worksheet 6 --- Worksheets/worksheet_06.txt | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Worksheets/worksheet_06.txt b/Worksheets/worksheet_06.txt index 812d7d5..1902f4e 100644 --- a/Worksheets/worksheet_06.txt +++ b/Worksheets/worksheet_06.txt @@ -72,6 +72,16 @@ while x <= 0: print("Blast-off") + If the code is trying to print 1-10 backwards before printing Blast-off, + the program should look like this: +x = 10 + +while x > 0: + print(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) From 26224b2989ba866db41bf980f331f230ddfa4580 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Wed, 15 Nov 2017 09:11:01 -0600 Subject: [PATCH 11/17] Completed chapter 6 lab 1 --- Lab 06 - Loopy Lab/part_1.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/Lab 06 - Loopy Lab/part_1.py b/Lab 06 - Loopy Lab/part_1.py index 8b13789..5733418 100644 --- a/Lab 06 - Loopy Lab/part_1.py +++ b/Lab 06 - Loopy Lab/part_1.py @@ -1 +1,7 @@ - +# Lab 1 chapter 6 +x = 10 +for i in range(9): + for number in range(i+1): + print(x, end=" ") + x+= 1 + print() From 0263677538a0fd7e4dd721e2b297071c54adddbb Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Thu, 16 Nov 2017 08:23:47 -0600 Subject: [PATCH 12/17] Modified chapter 6 lab 2, not complete --- Lab 06 - Loopy Lab/part_2.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Lab 06 - Loopy Lab/part_2.py b/Lab 06 - Loopy Lab/part_2.py index 792d600..a6c86c2 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -1 +1,11 @@ -# +#Chapter 6 Lab 2 +number = int(input("Number = ")) +letter = "o" +for row in range(number): + print(letter*2, end="") +print() +for row in range(number-2): + print(letter) +for row in range(number): + print(letter*2, end="") +print() From 0cf8e2dd199e680dde59771e48547f245f548901 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Thu, 16 Nov 2017 08:38:17 -0600 Subject: [PATCH 13/17] Completed lab 2 of chapter 6 --- 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 a6c86c2..b0614fc 100644 --- a/Lab 06 - Loopy Lab/part_2.py +++ b/Lab 06 - Loopy Lab/part_2.py @@ -1,11 +1,13 @@ #Chapter 6 Lab 2 number = int(input("Number = ")) letter = "o" +spaces = " " * ((number * 2) - 3) for row in range(number): print(letter*2, end="") print() for row in range(number-2): - print(letter) + print(letter, spaces, end="") + print(letter) for row in range(number): print(letter*2, end="") print() From 831e7e3c8fc2c73d53bd634a3c16e0891d2b8a9e Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Mon, 20 Nov 2017 08:33:57 -0600 Subject: [PATCH 14/17] Completed Chapter 6 Worksheet --- Worksheets/worksheet_07.txt | 59 +++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) diff --git a/Worksheets/worksheet_07.txt b/Worksheets/worksheet_07.txt index a87ff3f..7e7b5ea 100644 --- a/Worksheets/worksheet_07.txt +++ b/Worksheets/worksheet_07.txt @@ -8,6 +8,7 @@ 1. List the four types of data we've covered, and give an example of each: + The four types of data are int (3), bool (True), str ("string"), and float (2.76). 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 +19,22 @@ print(my_list[1]) print(my_list[4]) print(my_list[5]) + This code will print out: + 2 + 101 + error 3. What does this code print out? my_list=[5, 2, 6, 8, 101] for my_item in my_list: print(my_item) + This code will print out: + 5 + 2 + 6 + 8 + 101 4. What does this code print out? @@ -33,6 +44,9 @@ print(my_list1) my_list2[2] = 10 print(my_list2) + The code will print: + [5, 2, 6, 8, 101] + error 5. What does this code print out? @@ -40,6 +54,9 @@ print(my_list) my_list = [3] * 5 print(my_list) + This code will print out: + [15] + [3, 3, 3, 3, 3] 6. What does this code print out? @@ -47,6 +64,8 @@ for i in range(5): my_list.append(i) print(my_list) + This program will output: + [5, 0, 1, 2, 3, 4] 7. What does this code print out? @@ -55,18 +74,35 @@ print(len("Hi") + len("there.")) print(len("2")) print(len(2)) + This code will output: + 2 + 9 + 8 + 1 + error 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) + This code will print out: + S + i + m + p + s + o + n 10. What does this code print out? @@ -74,17 +110,24 @@ for i in range(3): word += "College" print(word) + This program will output: + SimpsonCollegeCollegeCollege 11. What does this code print out? word = "Hi" * 3 print(word) + This code will print out: + 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]) + This code will print out: + The 3rd spot is: + The -1 spot is: . 13. What does this code print out? @@ -92,10 +135,20 @@ print(s[1]) print(s[:3]) print(s[3:]) + This code will print out: + 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. + +userList = [] +for number in range(5): + number = int(input("Enter a number for a list: ")) + userList.append(number) +print(userList) 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 @@ -105,4 +158,10 @@ my_list = [3,12,3,5,3,4,6,8,5,3,5,6,3,2,4] +my_list = [3, 12, 3, 5, 3, 4] +list_total= 0 +for i in range(len(my_list)): + list_total += my_list[i] +list_total = list_total/len(my_list) +print(list_total) From 1c53fc0269a0eb2fa80390ad6ffa036b92872687 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Tue, 28 Nov 2017 07:33:15 -0600 Subject: [PATCH 15/17] Modified worksheet 5 and lab 7 --- Lab 07 - Adventure/main_program.py | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index 792d600..a413280 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1 +1,15 @@ -# +#Lab 7: Adventure +#First, sketch the layout of the dungeon +roomList = [roomZero, roomOne, roomTwo, roomThree, roomFour, roomFive, roomSix, roomSeven, roomEight] +#All of the rooms: +roomZero = ["Main hall", 3, 2, None, 1] +roomOne = ["Ballroom", None, 0, None, None] +roomTwo = ["Study", 4, None, None, 0] +roomThree = ["West Hall", None, 4, 0, 5] +roomFour = ["East Hall", 6, 5, 2, 3] +roomFive = ["Weapon Room", None, None, None, 4] +roomSix = ["Meeting Room", None, None, 4, None] +roomSeven = ["Bedroom", 8, 3, None, None] +roomEight = ["Secret Room", None, None, 7, None] +currentRoom = 0 +print(roomList) From 39aa6445622ab4be23f9987a465b4e6f462ac0f0 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Tue, 28 Nov 2017 10:11:41 -0600 Subject: [PATCH 16/17] Modified Chapter 7 lab --- Lab 07 - Adventure/main_program.py | 50 +++++++++++++++++++++++------- Worksheets/worksheet_05.txt | 9 +++++- 2 files changed, 46 insertions(+), 13 deletions(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index a413280..af98311 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1,15 +1,41 @@ +#! +# Evie Nelson +# 11/20/17 +# First class #Lab 7: Adventure #First, sketch the layout of the dungeon -roomList = [roomZero, roomOne, roomTwo, roomThree, roomFour, roomFive, roomSix, roomSeven, roomEight] #All of the rooms: -roomZero = ["Main hall", 3, 2, None, 1] -roomOne = ["Ballroom", None, 0, None, None] -roomTwo = ["Study", 4, None, None, 0] -roomThree = ["West Hall", None, 4, 0, 5] -roomFour = ["East Hall", 6, 5, 2, 3] -roomFive = ["Weapon Room", None, None, None, 4] -roomSix = ["Meeting Room", None, None, 4, None] -roomSeven = ["Bedroom", 8, 3, None, None] -roomEight = ["Secret Room", None, None, 7, None] -currentRoom = 0 -print(roomList) +roomZero = ["You are in the main hall. There is a room to the north, to the east, and to the west.", 3, 2, None, 1] +roomOne = ["You are in the ballroom. There is a room to the east.", None, 0, None, None] +roomTwo = ["You are in the study. There is a room to the north and to the west.", 4, None, None, 0] +roomThree = ["You are in the west hall. There is a room to the east, to the south , and to the west.", None, 4, 0, 5] +roomFour = ["You are in the east hall. There is a room to the north, to the east, to the south, and to the west.", 6, 5, 2, 3] +roomFive = ["You are in the weapon room. There is a room to the west.", None, None, None, 4] +roomSix = ["You are in the meeting room. There is a room to the south.", None, None, 4, None] +roomSeven = ["You are in the bedroom. There is a large tapestry to the north and a room to the east."] +roomEight = ["You are in the secret room. There is a room to the south.", None, None, 7, None, 8, 3, None, None] +roomList = [roomZero, roomOne, roomTwo, roomThree, roomFour, roomFive, roomSix, roomSeven, roomEight] +currentRoom= 0 +#print(roomList) +currentRoom= 0 +done = False +while done != True: + print() + print(roomList[currentRoom][0]) + userInput = input("What direction? ") +#north + if userInput == "n": + nextRoom = roomList[currentRoom][1] + elif userInput == "e": + nextroom = roomList[currentRoom][2] + elif userInput == "s": + nextroom = roomList[currentRoom][3] + elif userInput == "w": + nextRoom = roomList[currentRoom][4] + elif userInput == "q": + break + + if nextRoom == None: + print("You can't go that way.") + else: + currentRoom = nextRoom diff --git a/Worksheets/worksheet_05.txt b/Worksheets/worksheet_05.txt index d3cf948..f84e03f 100644 --- a/Worksheets/worksheet_05.txt +++ b/Worksheets/worksheet_05.txt @@ -16,17 +16,23 @@ pygame.init() 3. Explain how WHITE = (255, 255, 255) represents a color. - + The three 255 represtent the amount of red, green, and blue. Having all of the colors + at full intensity means the color is 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.) + Variables in all upper-case are constants, meaning they don't change. If the + color is meant to change, the variable name should be in lower-case. 5. What does the pygame.display.set_mode() function do? + It will open a display window to print the picture created by the code. 6. What does this for event in pygame.event.get() loop do? + It will allow the user to interact with the display window. 7. What is pygame.time.Clock used for? + It controls how fast the screen updates. 8. For this line of code: (3 pts) @@ -39,6 +45,7 @@ 9. What is the best way to repeat something over and over in a drawing? + 10. When drawing a rectangle, what happens if the specified line width is zero? From e39aeb765a0213b9c3065a79f4e1e3b5bb7386e8 Mon Sep 17 00:00:00 2001 From: EvieNelson Date: Wed, 29 Nov 2017 08:13:58 -0600 Subject: [PATCH 17/17] Completed Lab 7 --- Lab 07 - Adventure/main_program.py | 33 +++++++++++++++--------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/Lab 07 - Adventure/main_program.py b/Lab 07 - Adventure/main_program.py index af98311..bee13f7 100644 --- a/Lab 07 - Adventure/main_program.py +++ b/Lab 07 - Adventure/main_program.py @@ -1,19 +1,19 @@ -#! -# Evie Nelson -# 11/20/17 -# First class +#!/usr/bin/env #Lab 7: Adventure +#Evie Nelson +#11/20/17 +''' An adventure game where the user can move through different rooms using north, east, south, and west. ''' #First, sketch the layout of the dungeon #All of the rooms: roomZero = ["You are in the main hall. There is a room to the north, to the east, and to the west.", 3, 2, None, 1] roomOne = ["You are in the ballroom. There is a room to the east.", None, 0, None, None] roomTwo = ["You are in the study. There is a room to the north and to the west.", 4, None, None, 0] -roomThree = ["You are in the west hall. There is a room to the east, to the south , and to the west.", None, 4, 0, 5] +roomThree = ["You are in the west hall. There is a room to the east, to the south , and to the west.", None, 4, 0, 7] roomFour = ["You are in the east hall. There is a room to the north, to the east, to the south, and to the west.", 6, 5, 2, 3] roomFive = ["You are in the weapon room. There is a room to the west.", None, None, None, 4] roomSix = ["You are in the meeting room. There is a room to the south.", None, None, 4, None] -roomSeven = ["You are in the bedroom. There is a large tapestry to the north and a room to the east."] -roomEight = ["You are in the secret room. There is a room to the south.", None, None, 7, None, 8, 3, None, None] +roomSeven = ["You are in the bedroom. There is a large tapestry to the north and a room to the east.", 8, 3, None, None] +roomEight = ["You are in the secret room. There is a room to the south.", None, None, 7, None] roomList = [roomZero, roomOne, roomTwo, roomThree, roomFour, roomFive, roomSix, roomSeven, roomEight] currentRoom= 0 #print(roomList) @@ -23,19 +23,20 @@ print() print(roomList[currentRoom][0]) userInput = input("What direction? ") -#north - if userInput == "n": +#directions + if userInput.lower()[0] == "n": nextRoom = roomList[currentRoom][1] - elif userInput == "e": - nextroom = roomList[currentRoom][2] - elif userInput == "s": - nextroom = roomList[currentRoom][3] - elif userInput == "w": + elif userInput.lower()[0] == "e": + nextRoom = roomList[currentRoom][2] + elif userInput.lower()[0] == "s": + nextRoom = roomList[currentRoom][3] + elif userInput.lower()[0] == "w": nextRoom = roomList[currentRoom][4] - elif userInput == "q": + elif userInput.lower()[0] == "q": break - +#if there isn't a room if nextRoom == None: + print() print("You can't go that way.") else: currentRoom = nextRoom