« All Events
7 PM – Intro to Python – Joshua Widjanarko (Joel-sub)
November 21, 2024 @ 7:00 pm - 8:00 pm
Homework:
- Make sure to review the following topics:
- Variable
- If-Elif-Else, Input
- List (accessing from a list, adding to the list, getting the length of the list)
- For loops (For loop for a list, for loop using range())
- While loops
- The exercises below are optional if you want to practice for the quiz.
- Create a new file called Nov21_1stQuizReview and do the following exercises:
- #1
- Make a variable called first_name and set it to your name.
- Make a variable called favorite_number and set it to your favorite number.
- Make a variable called likes_pizza and set to True or False depending on whether you like pizza or not.
- print the following statement: <first_name> loves the number <favorite_number> and it’s <likes_pizza> that they like pizza.
- #2
- Ask the user: “What is the current temperature?”
- If the temperature is less than 0, print “It’s freezing outside!”
- If the temperature is between 0 and 20, print “It’s quite chilly, wear a jacket. “
- If it is greater than 20, print “It’s warm outside, enjoy the sunshine!”
- #3
- Make a new list called hobbies with at least 3 of your hobbies.
- Access and print the second hobby in the list.
- Add a new hobby to the list using .append()
- Print the total amount of hobbies using len()
- #4
- Create a list ‘fruits’ that has 5 fruits. Loop through the list and for each fruit, print “<fruit> is delicious!”
- #5
- Using a for loop, print “Hello” 10 times.
- #6
- Make a program that keeps asking the user: “Enter a positive number (or 0 to quit)”
- If the user enters negative number, print “Negative numbers are not allowed!” and continue asking.
- If the user enters 0, print “Goodbye!” and stop the loop
- Otherwise, print “You entered: <number>”