Practice Set 01
Practice Set 01
○ Write a Python program that asks the user for their name and prints a greeting
message.
Example:
Input: Enter your name: Alice
○
2. A sum of Two Numbers
○ Write a program that takes two numbers as input and prints their sum.
Example:
Input: 5, 8
Output: Sum = 13
○
3. Area of a Rectangle
○ Ask the user to enter the length and width of a rectangle and calculate its area.
Example:
Input: Length = 10, Width = 5
Output: Area = 50
○
4. Convert Celsius to Fahrenheit
○ Take temperature in Celsius from the user and convert it to Fahrenheit using the
formula:
F=(C×9/5)+32F = (C \times 9/5) + 32
Example:
Input: 0
○ Take principal amount, rate of interest, and time (years) from the user and
calculate simple interest.
○ Formula:
SI=(P×R×T)/100SI = (P \times R \times T) / 100
Example:
Input: P = 1000, R = 5, T = 2
○
6. Swap Two Numbers
○ Take two numbers as input and swap their values without using a third variable.
Example:
Input: A = 5, B = 10
Output: A = 10, B = 5
○
7. Check Even or Odd
Example:
Input: 7
○
8. Reverse a String
Example:
Input: Python
Output: nohtyP
9. Calculate the Square and Cube of a Number
Example:
Input: 4
○
10.Concatenate Two Strings
Example:
Input: "Hello", "World"
Output: "HelloWorld"