DEPARTMENTOF
COMPUTERSCIENCE&ENGINEERING
Experiment No.- 1.1
Student Name: Yash Chaudhary UID: 21BCS5522
Branch: BE CSE Section/Group: 810 B
Semester: 4th Date of Performance:14-02-23
Subject Name: Programming with Python Lab
Aim of the practical: Writing python programs in various modes and
printing and assigning values assigned to the variables.
1. Source Code:
Question 1 – Write a program to enter two numbers and perform all arithmetic
operations.
print(" Yash, UID: 21BCS5522")num1 =
int(input('Enter first number: ')) num2 =
int(input('Enter second number: '))
print("All Arithmetic Operations ")
print("Addition: ",num1 + num2)
print("Subtraction: ",num1 - num2)
print("Multiplication: ",num1 * num2)
print("Division: ",num1 / num2)
print("Modulus: ", num1 % num2)
Question 2 – Write a program to enter marks of five subjects and
a) Calculate Total
b) Calculate Average
c) Calculate Percentage
print("Yash, UID: 21BCS5522")
First = float(input("Enter the marks of 1st subject: "))
Madhav Sharma 21BCS5438
DEPARTMENTOF
COMPUTERSCIENCE&ENGINEERING
Second = float(input("Enter the marks of 2nd subject: "))
Third = float(input("Enter the marks of 3rd subject: "))
Fourth = float(input("Enter the marks of 4th subject: "))
Fifth = float(input("Enter the marks of 5th subject: "))
total = First + Second + Third + Fourth + Fifth
average = total / 5
percentage = (total / 500) * 100
print("\nTotal Marks = %.2f" %total)
print("Average Marks = %.2f" %average)
print("Marks Percentage = %.2f" %percentage)
Question 3 – Write a program to enter length in Centimetres, Convert it into
Meter and Kilometer and Display Original and converted
Values.
print("Yash, UID: 21BCS5522")length =
float(input("Enter length: "))
unit = input("Enter unit (cm,m,km): ")
if unit == "km": length_cm = length * 10000
elif unit == "m": length_cm = length * 100
else: length_cm = length
length_m = length_cm / 100
length_km = length_m / 1000
print("Length in cm:", length_cm)
print("Length in m:", length_m)
print("Length in kilometers:", length_km)
Madhav Sharma 21BCS5438
DEPARTMENTOF
COMPUTERSCIENCE&ENGINEERING
3.Screenshot of Outputs:
Output: 1
Output:2
Output:3
Madhav Sharma 21BCS5438
DEPARTMENTOF
COMPUTERSCIENCE&ENGINEERING
Codechef problem:
Question- In a coding contest, there are prizes for the top rankers. The prize scheme is
as follows:
Top 10 participants receive rupees X each.
Participants with rank 11 to 100 (both inclusive) receive rupees Y each.
Find the total prize money over all the contestants.
t = int(input())
for i in range(t):
x, y = map(int,input().split())
print((x*10)+(y*90))
Output:
Madhav Sharma 21BCS5438