Challenge 8
This challenge is intended to be taken after the modules section.
Problem 1: Custom Module
- Create a new file called
greetings.py. - In
greetings.py, define a function calledsay_hello(name)that returns a string "Hello, {name}!". - In the editor below, import the
greetingsmodule and use thesay_hellofunction to greet a user.
# Assume greetings.py exists
# Your code here
Problem 2: Using the math module
- Ask the user to enter the radius of a circle.
- Use the
mathmodule to get the value of PI and to calculate the area of the circle (Area = π * r^2). - Print the calculated area.
Problem 3: Number Guessing Game
- Use the
randommodule to generate a random integer between 1 and 100. - Create a loop that asks the user to guess the number.
- After each guess, tell the user if their guess was too high or too low.
- The loop should end when the user guesses the correct number.