0% found this document useful (0 votes)
29 views

Python

The document is an experiment report submitted by a student named Yash Chaudhary for their Programming with Python lab course. It details three programming questions answered by the student, including writing programs to perform arithmetic operations on two numbers, calculate total marks, average, and percentage of five subjects, and convert a length between centimeters, meters, and kilometers. It also includes screenshots of the output for each question and the code and output for a Codechef problem.

Uploaded by

YASH CHAUDHARY
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views

Python

The document is an experiment report submitted by a student named Yash Chaudhary for their Programming with Python lab course. It details three programming questions answered by the student, including writing programs to perform arithmetic operations on two numbers, calculate total marks, average, and percentage of five subjects, and convert a length between centimeters, meters, and kilometers. It also includes screenshots of the output for each question and the code and output for a Codechef problem.

Uploaded by

YASH CHAUDHARY
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

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

You might also like