[go: up one dir, main page]

0% found this document useful (0 votes)
3 views4 pages

DFI Python Beginners Slides_111226

This document outlines a Python assignment focused on variables, data types, and lists. It includes tasks for creating and manipulating variables, performing basic arithmetic and string operations, and working with lists. The assignment aims to reinforce foundational programming concepts in Python before progressing to more advanced topics.

Uploaded by

Somebody's Bae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views4 pages

DFI Python Beginners Slides_111226

This document outlines a Python assignment focused on variables, data types, and lists. It includes tasks for creating and manipulating variables, performing basic arithmetic and string operations, and working with lists. The assignment aims to reinforce foundational programming concepts in Python before progressing to more advanced topics.

Uploaded by

Somebody's Bae
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Python Assignment: Variables, Data Types, and

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.

Task 1: Variables and Data Types

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.

2. Print the variables:


- Print each variable and its type.

Output:

Task 2: Basic Operations

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

1. Create and Manipulate Lists:


- Create a list of 5 favorite foods.
- Print the first and last item in the list.
- Add a new food to the list.
- Remove the third food item from the list.
- Print the updated list.

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

- Save your Python script as assignment_variables_lists.py.


- Ensure the script runs without errors.
- Submit the script as instructed.

---

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.

You might also like