DFI Python Beginners Slides_111226
DFI Python Beginners Slides_111226
Lists
Instructions:
1. Complete each task in a Python script.
2. Use comments to explain what each part of your code does.
3. Ensure your code is well-formatted and follows good coding practices.
1. Create variables:
- Create a variable to store your name.
- Create a variable to store your age.
- Create a variable to store a floating-point number representing your height.
- Create a variable to store a boolean value indicating whether you are a student.
Output:
1. Arithmetic Operations:
- Create two integer variables a and b.
- Perform addition, subtraction, multiplication, division, and modulus operations on
these variables.
- Print the results of each operation.
2. String Operations:
- Create a string variable named sentence with the value "Python is awesome!"
- Print the length of the string.
- Convert the string to uppercase and print the result.
- Replace a word in the string with another word and print the result.
Example:
Output:
Task 3: Lists
2. List Operations:
- Create a list of numbers from 1 to 10.
- Calculate and print the sum of all numbers in the list.
- Find and print the maximum and minimum numbers in the list.
- Print the list in reverse order.
Example:
Output:
Submission
---
This assignment covers the basic concepts of variables, data types, and lists in Python.
It will help you understand how to work with these fundamental elements before moving
on to more advanced data structures.