0% found this document useful (0 votes)
2 views3 pages

lab2

The document outlines a series of Python programming assignments that cover various topics such as distance conversion, calculating marks and percentages, simple interest, BMI calculation, and more. Each assignment includes specific tasks that require the implementation of different programming concepts, including conditionals, loops, and mathematical calculations. The assignments aim to enhance programming skills through practical applications and problem-solving.

Uploaded by

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

lab2

The document outlines a series of Python programming assignments that cover various topics such as distance conversion, calculating marks and percentages, simple interest, BMI calculation, and more. Each assignment includes specific tasks that require the implementation of different programming concepts, including conditionals, loops, and mathematical calculations. The assignments aim to enhance programming skills through practical applications and problem-solving.

Uploaded by

noobesports54
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Assignment 2

1. Write a python program to Input distance (in km) and convert in meter,
centimetre, and inches.
2. Write a python program to Input 5 subject marks of a student and find total
marks and percentage obtained by the student.
3. Write a python program to input principal, rate, time and calculate Simple
Interest. Simple Interest=Principal*Rate*Time/100
4. Body Mass Index (BMI) is a measure of health on weight. It can be
calculated by taking your weight in kilograms and dividing by the square of
your height in meters. Write a python program that prompts the user to enter
a weight in pounds and height in inches and displays the BMI. Note that one
pound is 0.45359237 kilograms and one inch is 0.0254 meters.
Here is a sample run:
Enter weight in pounds: 95.5
Enter height in inches: 50
BMI is 26.8573
5. Write a python program that reads an integer between 100 and 999 and adds
all the digits in the integer. For example, if an integer is 672, the sum of all
its digits is 15.
6. Write a python program that prompts the user to enter base and height of a
right angled triangle and displays its area. The formula for computing the
area of a triangle is : ½*base*height
7. Write a Python program to find the largest of three numbers.
8. Write a Python program to check given number is odd or even.
9. Write a python program that takes two positive integers from command line
and prints true if either evenly divides the other
10. Write a Python program to calculate the root of the given quadratic equation
𝑎𝑥2 + 𝑏𝑥 + 𝑐 = 0 for different values of a, b, c. if the discriminant is
greater than zero it should print 2 real roots, if it is equal to 0 it should print
1 root and if it is less than zero it should print the message that there is no
real roots for the given equation.
11. Write a Python program to assign a grade on the basis of marks obtained by
the student using an if-elif-else statement.

Range Grade
[90-100] O
[80-89] A
[70-79] B
[60,69] C
[50,59] D
[40,49] E
[<40] F
12. Write a program that checks whether a given 3 digit number is an
Armstrong number or not. A 3 digit number is an Armstrong number whose
sum of the cubes of the digits is equal to the number itself. For Example,
370 =33 + 73 + 03

Sample executions
Enter a number : 370
Yes it is an Armstrong number
Enter a number :450
No it is not an Armstrong number

13. Write a Python program to input four integers in the command line and
display the sum of the first two numbers and the product of last
twonumbers.
14. Write a python program that takes two integer values m and d from the
command line and prints true if day d of month m is between 3/20 and 6/20,
false otherwise
15. Write a program to print the number of 20 rupee notes, 10 rupee notes, 5
rupee and 1 rupee notes a person has if the total amount of money with that
person is given (assuming that only the given denominations are there with
the person).
16. Write a python program that takes the x – y coordinates of a point in
theCartesian plane and prints a message telling either an axis on which
thepoint lies or the quadrant in which it is found.

Sample lines of output:


(-1.0, -2.5) is in quadrant III
(0.0, 4.8) is on the y-axis

17. Write a python program that prompts the user to enter an integer for
today’sday of the week (Sunday is 0, Monday is 1... and Saturday is 6). Also
promptthe user to enter the number of days after today for a future day and
displaythe future day of the week.

Here are some sample runs:


Enter today's day: 1
Enter the number of days elapsed since today: 3
Today is Monday and the future day is
ThursdayEnter today's day: 0
Enter the number of days elapsed since today: 31
Today is Sunday and the future day is
Wednesday

18. Write a python program which displays an appropriate name for a person,
using a combination of nested ifs and compound conditions. Ask the user for
a gender, first name, last name and age. If the person is female and 20 or
over, ask if she is married. If so, display "Mrs." in front of her name. Ifnot, display "Ms." in
front of her name. If the female is under 20, display herfirst and last name. If the person is male
and 20 or over, display "Mr." infront of his name. Otherwise, display his first and last name.
Note thatasking a person if they are married should only be done if they are femaleand 20 or
older, which means you will have a single if and else nested insideone of your if statements.
Sample runs

What is your gender (M or F): F


First name: Riya
Last name: Sen
Age: 32
Are you married, Riya (y or n)? y
Then I shall call you Mrs.Riya Sen.

What is your gender (M or F): F


First name: Anjali
Last name: Roy
Age: 48
Are you married, Anjali(y or n)? n
Then I shall call you Ms. Anjali Roy

What is your gender (M or F): M


First name: Dhruti
Last name: Mohanty
Age: 23
Then I shall call you Mr.DhrutiMohanty

What is your gender (M or F): M


First name: Rajat
Last name: Pati
Age: 15
Then I shall call you Rajat Pati

19. Write a python program that allows to enter an integer between 1 and
12from command line and displays the English month name January,
February... December for the number 1, 2... 12, accordingly.
20. Write a python program that displays the following table(use str(1)+ "\t" +
str(2)+…. in print function).

a b pow(a, b)
1 2 1
2 3 8
3 4 81
4 5 1024
5 6 15625

You might also like