🐍 Python 🐍

🍁 Happy November 🍡

View the Project on GitHub riverdaleGithub/intro_python_23

Topics in CS: Ο€-thon

Building A Trivia Game

Q1 2023

In this project, you will have an opportunity to create a trivia game in a topic of your choice. For this project, you must create 4️⃣ four trivia questions 4️⃣ with some type of response for 😡 incorrect 😡 or πŸŽ‰ correct answers πŸŽ‰. You will decide on the πŸͺ© theme πŸͺ©

πŸ“– 0: Goals & Review πŸ“–

This lesson has three main goals. Please turn in the following:

  1. βš’οΈ Triva game with 4 questions (repl.it) βš’οΈ
  2. ↔️ 3 Peer reviews: to & from (you make doc) ↔️
  3. πŸ—οΈ 5 descriptive ideas for final project (you make doc) πŸ—οΈ
πŸŒͺ️ Coding Review πŸŒͺ️ In our previous sessions, we have examined how we can use conditional statements to check for true or false. Here is an example:

city = input("What city is Riverdale located in?")
if city == "New York City" or city == "NYC":
   print("correct")
else:
   print("wrong")
We used the β€œor” & "and" statements to allow for as many possible correct solutions as possible. In the example above either New York City or NYC would work as correct answers. All other answers would be incorrect and fall into the else clause. πŸ€”

city = input("What city is Riverdale located in?")
name = input("What is your name?")
if city == "New York City" or city == "NYC" or city == "Bronx":
   print("correct")
elif city == "NYC" and name == "Lila":
   print("You must be cool")
else:
   print("wrong")


πŸ”­ 1: Learn πŸ”­

First, create a new project called trivia_game. Next, research and try to use the .lower(), .strip(), and .find() to help you learn how to control text input. πŸ› οΈ Have an example of each in your script. Make sure you know Methods and Arguments. This is a huge part of the course.

The Actual Lesson
Methods & Arguments
πŸ› οΈ Method πŸ› οΈ Imagine you have a toy robot πŸ€–. This robot can do different things like walk 🚢, dance πŸ’ƒ, and sing 🎀. Each of these actions is like a "method" for the robot. In Python, objects (like our robot) can have methods that allow them to do specific tasks. In Python, you can chain methods together

   # Calling a Method
   robot.dance()
   # Chaining methods
   robot.dance().backfilp()
   answer = input("what is the answer?")
   anwser.find(string.upper())
Here, `dance` is a method that makes the robot dance.

🎁 Argument 🎁 Now, let's say your robot can also paint 🎨, but it needs to know which color to use. You tell the robot the color by giving it a small box 🎁 with the paint inside. This box is like an "argument" you give to the method.
robot.paint("blue")
Here, `"blue"` is the argument you're giving to the `paint` method to tell the robot which color to use.

So, in simple terms: - A πŸ› οΈ method πŸ› οΈ is an action or task that something can do.
- An 🎁 argument 🎁 is extra information you give to help the method do its job. I hope that helps! 🌟

Learn New Methods
The lower() method returns a string where all characters are lower case. πŸ“

            city = "New York City"
            print(city.lower()) #prints new york city
        
The strip() method removes any leading (spaces at the beginning) and trailing (spaces at the end) characters (space is the default leading character to remove) 🚫

city = "    New York City    "
print(city.strip()) 
# removes the spaces on either side of the string 
The find() method finds the first occurrence of the specified value. The find() method returns -1 if the value is not found. πŸ” python

    city = "New York City"
    print(city.find("York")) #prints 4-> the index in which it found York
    # You can even combine these methods. πŸ”„


⛏️ 2: Build ⛏️

Project πŸš€ When creating your πŸͺ© Trivia game πŸͺ©, you want to make it as accurate as possible for the users to play the game. Using β€œor” statements will help you add correct answers.
Employing methods such as .lower(), .strip(), and .find() to help us and developers to anticipate users' responses by ignoring case, extra spaces on the ends of the string, or finding a specific term in the string. 🎲
We also added some cool tricksπŸŽ‰
Time

    time.sleep(0.5) #pause the program for 0.5 seconds
ASCII Art Use ASCII characters to create drawings or designs in your game!

print("""
+----------------+
|    WELCOME    |
+----------------+
""")
Try to chain together .find(), .strip(), and .lower()


πŸ’‘ 3: Peer Review πŸ’‘

Peer-review is the crux of all science
First, gain and give 3 Peer reviews. In this class, peer-review is simple. Give a 🌟 glow 🌟, 🌿 grow 🌿, and an πŸ”¬ insight πŸ”¬ as a comment. Less than a paragraph is not helpful, more than a few paragraphs is scary.

Code Review Example

   def circle_area(radius):
    pi = 3.14
    return pi * radius * radius
Peer Review:
🌟 Glow 🌟: Great job on keeping the function concise and to the point! The function name circle_area is descriptive, and it's clear what the function is intended to do. Using a clear variable name like radius also makes the code easy to understand.
🌿 Grow 🌿: Consider using the built-in math.pi instead of hardcoding the value of pi to 3.14. This would make the calculation more accurate and also show that you're utilizing Python's built-in libraries effectively.
πŸ”¬ Insight πŸ”¬: Did you know that the formula you used is derived from the integral of r with respect to ΞΈ from 0 to 2Ο€ in polar coordinates? It's fascinating how math and programming often intersect in such ways!


πŸ”¬ 4: Research Guide πŸ”¬

This guide will help you explore different areas of Python to inspire your final project. Today, you will pick βš„ five βš„ potential project ideas you would want to follow up on. This should include the main topic (all listed below ), and a description of the project.

Example Main Topic: Raspberry Pi and Python
Description:
I will turn a Raspberry Pi into a live webcam using Python! This project will involve connecting a USB webcam or Pi Camera to a Raspberry Pi and setting up a Python script to stream video over the internet. I can further enhance this by adding features like motion detection, time-lapse photography, or even facial recognition using libraries like OpenCV!
Main Topics
1. Basics of Python - Python Official Documentation - Real Python - Basics - Python Crash Course
2. Game Development - Pygame Tutorials - Making Games with Python & Pygame (Book)
3. Web Development - Flask: Micro Web Framework - Django: High-level Web Framework
4. Data Visualization - Matplotlib Tutorials - Seaborn: Statistical Data Visualization
5. Robotics and Hardware - Python with Raspberry Pi - MicroPython: Python for Microcontrollers
6. Music and Sound - PyDub: Audio Manipulation with Python - Sonic Pi: Code Music


🐝 5 Turning In Work 🐝

🌟 Try a Stretch goal(s) 🌟 πŸ’― Can you add a score to the game? 1 point if the user get the correct answer. 0 or -1 points if the user does not get the correct answer. πŸ“Š
If you add a score to the game, 🐝 buzz feed quiz 🐝 it: depending on the score, print a specific phrase. For instance, if the user gets all four questions correct, print
β€œYou are amazing! You got all 4 correct!” πŸ†
How To Turn IN πŸ”„ Once done with your code & peer-reviews, email the replit link which will have your other links inside of it as a comments

   # www.peer_review_doc.com
   # www.my_project_ideas.com
   print("this is my repl.it code")
   print("I turn in the repl.it link")
The peer_review.doc should contain the reviews you gave & recieved. I'd suggest using a table to organize this data. - You have the entire session and homework to work on the project. It is due for homework by next class. - Test your project with a classmate to verify that the trivia game works effectively and that you have anticipated the various answers from the user. - Remember to copy the Academic Honesty statement into your work and submit your project. πŸ“€


Bee Who You Want to Bee

Academic Honesty Statement for Computer Science Department πŸ“œ Please submit this assignment with your name and a copy of this text.

   I have neither given nor received improper aid in the preparation of this computer science assignment or in the completion of this code. Unless properly attributed to others, the work is exclusively my own.

Signed: (type your name here acknowledging this statement) ✍️