Python_Homework
Python_Homework
Homework Tasks
This homework will help you practice the topics we covered in the last lesson:
- Variables and their types: int, float, bool, string, and list.
- List methods.
Tasks:
1. Create variables of each type (int, float, bool, string, list). Print their types using the type() function.
2. Write a program that asks the user to input their age using input(). Convert the input to an integer using
int() and print a message: 'You are X years old!', where X is the user's age.
3. Practice string formatting: Create a variable with your name and age. Print the sentence: 'My name is
4. Write a program to demonstrate at least three string methods (e.g., upper(), lower(), replace()).
5. Create a list of your favorite fruits and print the list. Add a new fruit to the list, remove one, and print the
updated list.
6. Create a program that accepts a list of numbers (as input, comma-separated) from the user, and then
converts it into a list. Print the largest and smallest number in the list.
7. Explore the slicing of strings and lists: Print the first 3 characters of a string and the last 2 elements of a
list.
Additional Resources:
For more information about variables and their types, you can refer to the following article:
Page 1
Python Homework
https://realpython.com/python-variables/
https://docs.python.org/3/tutorial/datastructures.html
https://realpython.com/python-strings/
Page 2