0% found this document useful (0 votes)
12 views3 pages

Python Test

The document contains a series of Python exercises aimed at beginners, covering topics such as basic programs, data types, operators, input/output, and control statements. Each exercise includes specific tasks for the user to complete, such as displaying messages, performing calculations, and implementing loops and conditionals. The exercises are designed to provide practical experience with fundamental Python programming concepts.

Uploaded by

Sivavedathri
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)
12 views3 pages

Python Test

The document contains a series of Python exercises aimed at beginners, covering topics such as basic programs, data types, operators, input/output, and control statements. Each exercise includes specific tasks for the user to complete, such as displaying messages, performing calculations, and implementing loops and conditionals. The exercises are designed to provide practical experience with fundamental Python programming concepts.

Uploaded by

Sivavedathri
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

### Exercise 1: Python Introduction and Basic Programs

1. Write a Python program to display the message "Welcome to Python


Programming".
2. Write a Python program to perform addition of two numbers (input the
numbers from the user).
3. Write a Python program that calculates the area of a rectangle. (Take
the length and width as input from the user).
4. Write a Python program that prints the result of `9**3`.
5. Write a Python program to swap two variables without using a third
variable.

---

### Exercise 2: Data Types in Python

1. Write a Python program to check the data type of the following


variables:
```python
a = 10
b = "Hello"
c = 3.14
d = True
```
2. Write a Python program that converts a given integer to a string and
prints its data type before and after conversion.
3. Write a Python program to add an integer and a float, and print the
result along with its data type.
4. Write a Python program to create a list of five elements, then display
the list and its type.
5. Write a Python program that converts a string `"123"` into an integer
and adds 5 to it. Print the result.
---

### Exercise 3: Operators in Python

1. Write a Python program to perform addition, subtraction,


multiplication, and division on two input numbers.
2. Write a Python program to check if a number is even or odd using the
modulus operator.
3. Write a Python program to compare two input numbers and print
whether the first is greater than, less than, or equal to the second
number.
4. Write a Python program to increment a variable by 10 using an
assignment operator.
5. Write a Python program that checks whether both input numbers are
positive using the logical AND operator.

---

### Exercise 4: Input and Output in Python

1. Write a Python program that takes your name as input and prints a
welcome message.
2. Write a Python program to accept two numbers from the user and print
their product.
3. Write a Python program to accept a string input and display the
number of characters in the string.
4. Write a Python program that accepts an integer input from the user
and prints whether it's positive, negative, or zero.
5. Write a Python program that reads a sentence and prints each word on
a new line.

---
### Exercise 5: Control Statements in Python

1. Write a Python program to check if a given number is positive,


negative, or zero using an `if-elif-else` statement.
2. Write a Python program that prints all even numbers between 1 and 50
using a `for` loop.
3. Write a Python program that sums all numbers from 1 to 100 using a
`while` loop.
4. Write a Python program that asks the user for a password and keeps
prompting them until they enter the correct password using a `while`
loop.
5. Write a Python program to check if a given year is a leap year using
nested `if` statements.

---

These exercises should give you practical experience with Python basics.

You might also like