0% found this document useful (0 votes)
23 views2 pages

Python Programming Tasks and Solutions

Uploaded by

Faizan ali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views2 pages

Python Programming Tasks and Solutions

Uploaded by

Faizan ali
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

Python tasks

# Task 0
print(1 + (2 * 3))
print((1 + 2) * 3)
print(((2 * 4) * (4 + 2)))
print(((2 * 4) * 4) + 2)
print((2 * (4 * 4)) + 2)

# Task 1
y=2
x1 = (5 / 7) * (y - 1)
x2 = ((5 / 7) * y) - 1
print(x1)
print(x2)

# Task 2
string1 = input("Enter first string: ")
string2 = input("Enter second string: ")
concatenated_string = string1 + string2
print("Concatenated string:", concatenated_string)

# Task 3
values = [2.2, 4.4, 2.51, 18.5, 101.5]
rounded_values = [round(val) for val in values]
print("Rounded values:", rounded_values)

# Task 4
a = float(input("Enter the first float value: "))
b = float(input("Enter the second float value: "))
c = float(input("Enter the third float value: "))
x1 = round(a - b + c + 1, 2)
Python tasks

x2 = round(a + b * (c + 1), 2)
x3 = int((a ** 2) + (b ** 2))
print("Result 1:", x1)
print("Result 2:", x2)
print("Result 3:", x3)

# Task 5
text = input("Enter the text you want to repeat: ")
num_times = int(input("Enter the number of times to repeat: "))
print(text * num_times)

# Task 6
num1 = float(input("Enter num1: "))
num2 = float(input("Enter num2: "))
num3 = float(input("Enter num3: "))
fun = num1 + (num2 * num1) + num3
fun1 = int(fun // num3)
fun2 = int((fun + 1) // num3)
print("fun1:", fun1)
print("fun2:", fun2)

You might also like