Complete the following exercises using the code and concepts from workshop_3. All work should be committed to your GitHub repository.
- Create a Python script that implements a simple banking application:
- Define a variable for account balance
- Define a variable for withdrawal amount
- Use if-else statements to check if the withdrawal is possible
- If the withdrawal amount is less than or equal to the balance, print "Withdrawal successful" and show the remaining balance
- If the withdrawal amount exceeds the balance, print "Insufficient funds" and show the current balance
- Reference the approach shown in
conditionals.pyandconditionals_2.py
- Write a script that assigns letter grades based on a numeric score (0-100):
- 90-100: A
- 80-89: B
- 70-79: C
- 60-69: D
- Below 60: F
- Use elif chains similar to those in
chain.py - Include appropriate messages for each grade category
- Create a script that uses ternary operators for at least two different scenarios:
- Check if a number is even or odd
- Check if a person is eligible to vote (age >= 18)
- Determine if a temperature is above or below freezing
- Format your output clearly as shown in
ternary.py
- Write a script that calculates the squares of numbers from 1 to 10 using a for loop
- Print each number and its square in a readable format
- Reference the patterns in
for_loop_basics.py
- Create a script that demonstrates three different ways of using the range function:
- Print all numbers from 1 to 20
- Print all even numbers from 2 to 20
- Print all numbers from 20 to 1 (counting down)
- Use the techniques shown in
range.py
- Write a script that accepts a word from the user and:
- Prints each character on a separate line
- Counts the number of vowels (a, e, i, o, u) in the word
- Prints the word in reverse order
- Reference the approach in
strings.py(from the loops directory)
- Create a folder named
homework_3in your GitHub repository. - Create separate
.pyfiles for each exercise (7 files total). - Include meaningful comments in your code explaining your logic.
- Make sure to commit and push your changes to GitHub.
- Test all your scripts to ensure they work as expected.
- Proper use of conditional statements
- Effective implementation of loops and ranges
- Correct use of ternary operators
- Proper string manipulation and iteration
- Appropriate use of the enumerate function
- Code organization and readability
- Following the submission guidelines