Python-Programming-Assignment-02
Python-Programming-Assignment-02
Solution of Question # 1
# Question 1 Solution
#This program is about taking input of differenet types
Output:
Enter a String: amd
Enter a Integer: 9
Enter a Float: 2.5
Enter True or False: True
String Variable: amd
Integer Variable: 9
Float Variable: 2.5
Boolean Variable: True
String Variable in uppercase: AMD
Integer Variable is odd: 9
Float 2.5 after multiplying with 2 is 5.0
Question 2: Operators
Problem: Write a Python program that:
# Question 2 Solution
# Airthmetic and Logical Operators
#Arithmetic Operations
print(f"Addition of {number1} + {number2} = {number1+number2}")
print(f"Substraction of {number1} - {number2} = {number1-number2}")
print(f"Multipltion of {number1} * {number2} = {number1*number2}")
print(f"Division of {number1} / {number2} = {number1/number2}")
print(f"Modulus of {number1} % {number2} = {number1%number2}")
print(f"Flow Division of {number1} // {number2} = {number1//number2}")
#Checking that number1 is greater than number2 and second number is less that
10 or not.
#Comparing two numbes
if number1 > number2 and number2 < 10:
print(f"{number1} is greater than {number2} and {number2} is less than 10")
elif number2 > number1 and number2 >=10:
print(f"{number1} is greater than {number2} and {number2} is equal or
greater than 10")
elif number1 < number2 and number2 < 10:
print(f"{number1} is less than {number2} and {number2} is less than 10")
elif number2 < number1 and number2 >=10:
print(f"{number1} is less than {number2} and {number2} is equal or greater
than 10")
else:
print(f"Invalid Operation!")
Output:
Enter a Number1: 3
Enter a Number2: 4
Addition of 3 + 4 = 7
Substraction of 3 - 4 = -1
Multipltion of 3 * 4 = 12
Division of 3 / 4 = 0.75
Modulus of 3 % 4 = 3
Flow Division of 3 // 4 = 0
4 is greater than 3
3 is less than 4 and 4 is less than 10
Question 3: Loops
Solution of Question # 3
# Question 3 Solution
# List Operations
Output:
Enter number separted by spaces: 10 5 20 5 6 5 1 2 3
10
5
Breaking at 20 Loops end