Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
0 views

Python_Assignment

This Python programming assignment focuses on practicing basic concepts including variables, loops, conditionals, functions, and file handling. It consists of five parts, each requiring the completion of specific tasks, such as creating a greeting message, determining if a number is even or odd, printing numbers with a loop, defining a function for area calculation, and handling a text file. There is also an optional bonus challenge to filter even numbers from a list, with submission guidelines provided for code organization and commenting.

Uploaded by

Maliyat Haidari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Python_Assignment

This Python programming assignment focuses on practicing basic concepts including variables, loops, conditionals, functions, and file handling. It consists of five parts, each requiring the completion of specific tasks, such as creating a greeting message, determining if a number is even or odd, printing numbers with a loop, defining a function for area calculation, and handling a text file. There is also an optional bonus challenge to filter even numbers from a list, with submission guidelines provided for code organization and commenting.

Uploaded by

Maliyat Haidari
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

Python Programming Assignment

### Python Programming Assignment

#### Objective:

This assignment is designed to help you practice basic Python programming concepts such as

variables, loops, conditionals, functions, and file handling.

### Part 1: Basic Python Syntax

1. Write a Python script that asks the user for their name and age, then prints a message saying

"Hello, [name]! You are [age] years old."

### Part 2: Conditional Statements

2. Write a Python program that takes an integer as input and prints whether the number is even or

odd.

### Part 3: Loops

3. Write a Python program that prints the numbers from 1 to 10 using a for loop.

### Part 4: Functions

4. Define a function called `calculate_area` that takes two parameters (length and width) and returns

the area of a rectangle.

### Part 5: File Handling

5. Write a Python program that creates a text file called "sample.txt", writes "Hello, Python!" to it, and

then reads and prints the content.

Page 1
Python Programming Assignment

### Bonus Challenge (Optional):

6. Write a Python program that takes a list of numbers and returns a new list with only the even

numbers.

#### Submission Guidelines:

- Save all your code in a single Python script (.py file).

- Ensure your script is well-commented.

- Submit the script as a .zip file.

Happy Coding!

Page 2

You might also like