Guessing Game Exercise

Create a guessing game where the computer creates a random number and the user tries to guess this number. The computer should also tell the user if they guessed too low or high and the user should be prompted to guess until they have done so correctly. A sample output is shown.


Set 5 Exercises

1) Create a for loop from 30 to 300, printing every other number 2) Create a for loop from 500 to 30, printing every number. 3) Create a for loop from 1000 to 1 printing every 3rd number. (I.E. - 1000, 997, 994...) 4) Create a for loop from 1 to 15 printing only multiples of 3. 5) Ask the user to input 5 decimal values. Add them to a list called values. Loop through the list and print a total count of how many items are within 10 of 100. 6) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and print the total sum of all the elements in the list. 7) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and print the result of multiplying all the numbers in the list. 8) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and if one of the numbers in the list is 10 AND the sum of the numbers in the list are equal to 10, print("10 is present in the list") Otherwise, print("10 is not present in the list") 9) Ask the user to input 5 decimal values. Add them to a list called vals. Loop through the list and if one of the numbers in the list is 10 OR the sum of the numbers in the list are equal to 10, print("10 is present in the list") Otherwise, print("10 is not present in the list") 10) Ask the user to input 5 decimal values. Add them to a list called vals. If the first number and the last element in the list are equal, print("The first and last items are equal to each other") otherwise, print("The first and last items are not equal") 11) Ask the user to input 5 decimal values. Add them to a list called values. Loop through the list and print a total count of how many items are within 10 of 100 or 200. 12) Ask the user to input 5 decimal values. Add them to a list called values. Loop through this list and add each item to a new list called reversed. The new list will have all the same items from the original list except reversed. I.E. - values = [1, 2, 3, 4, 5] reversed = [5, 4, 3, 2, 1] 13) Ask the user to input 5 decimal values. Add them to a list called values. If the values in the list added together is less than 50, print("The total sum is less than 50") otherwise, print("The total sum is greater than 50") 14) Create a program which will ask for your recent exam score out of 80 and tell you what grade you got and how many more points you would have needed to get the next grade up. A - 90% and above B- 80% to 89.9% C- 70% to 79.99%

Finding the sum of the values in a list/average value

This post will show more list operations. Specifically how to find the sum and average values of a list of numbers.

Adding total value to an existing variable

When we have an existing variable for an integer or float, we can add value to it by taking the existing value and increasing it. Example below: x = 5 x = x + 5 print(x) y = 10 y = y * 10 print(y) When running this code, we would see that x equals 10 and y = 100.

Creating Random Numbers

We will go through how to create a random number. First we should import the random package in python, then we use the randint function to generate a random number between the specified parameters. Run the code sample below to see a random number between 1 and 100. from random import randint number = randint(1, 100) print(number)

While Loops

Introduction to the structure of while loops and where they can effectively be used.

Appending (Adding an item) to a List

This code will show you how you can add an item to a list. If we wrote the following code below: numbers = [] numbers.append(10) print(numbers) ---Output: [10] values = ["hello"] values.append("Hi") print(values) ---Output: ["hello", "Hi"]

Looping through a List

This shows how to loop through a list

Length of a List Python - Important for loops

How to use the len() function and how to reference the last item of a list

Printing Specific Values from a List

This will show how to print out specific items in a list

List Positons (Indeces)

This video introduces the concept of list indeces which will be very important going forward.

Creating Lists With Predefined Variables

This shows how to create lists with predefined variables. Example: x = 10 y = 20 z = 30 numbers = [x, y, z] print(numbers)

1 2 ... 4