Python Programs Flashcards

1
Q

How many seconds are there in 42 minutes 42 seconds?

A
# Converts Minutes to Seconds
minutes = int(input("Entern Minutes : "))
seconds = int(input("Enter Seconds : "))
print(f"Total Seconds are : {(minutes * 60)+seconds}")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How many miles are there in 10 kilometers? Hint: there are 1.61 kilometers in a
mile.

A

Converts Kilometers to Miles

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

The volume of a sphere with radius r is 4
3πr3. What is the volume of a sphere with
radius 5?

A
radius = int(input("Enter Radius : ")) 
cubeOfradius = radius ** 3
pie = 3.14
v = 4/3 * (cubeOfradius * pie)
print(f"Volume of Sphere is : {v:,.2f}")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How many miles are there in 10 kilometers? Hint: there are 1.61 kilometers in a mile.

A

kms = int(input(“Enter Kilometers : “))
oneMile = 1.61
totalMiles = kms / oneMile
print(f”There is {totalMiles:,.2f} Miles in {kms} Kilometers”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The volume of a sphere with radius r is 4
3πr3. What is the volume of a sphere with
radius 5?

A
radius = int(input("Enter Radius : ")) 
cubeOfradius = radius ** 3
pie = 3.14
v = 4/3 * (cubeOfradius * pie)
print(f"Volume of Sphere is : {v:,.2f}")
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If you run a 10 kilometer race in 42 minutes 42 seconds, what is your average
pace (time per mile in minutes and seconds)? What is your average speed in
miles per hour?

A

42minute+42sec=2580 second

2580 socond /3600=0.7166 hr

0.7166 hr me 10km

So 1 hr me - 10/0.7166= 13.95km

13.95 km/1.61= 8.66 mile

#python Code
seconds =  (42 * 60) + 42
print("Seconds = ",seconds)
hours = seconds / 3600
print(f"Hours = {hours:,.2f}")

kms_in_OneHour = 10 / hours
print(f”Average Speed in Kms Per Hour is : {kms_in_OneHour:,.2f}”)

miles_in_oneHour = kms_in_OneHour / 1.61
print(f”Average Speed in Miles Per Hour is : {miles_in_oneHour:,.2f}”)

#output
Seconds =  2562
Hours = 0.71
Average Speed in Kms Per Hour is : 14.05
Average Speed in Miles Per Hour is : 8.73
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to print value of pie twice using a function .

A
import math
def printTwice(value):
    print(value)
    print(value)
printTwice(math.pi)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Program for Divide,Modulus & Floor Division

A

x,y = 9,2
print(f”{x} dvided by {y} = {x/y:,.2f}”)
print(f”{x} Modulas {y} = {x%y}”)
print(f”{x} Floor Division {y} = {x//y}”)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

if we multiply a list to 3 ,then what would happen ?

A
list contents are concatinated by three times.
list1 = [1,2,3,4]
list1 = list1*3
print(list1)
Outupt - [1,2,3,4,1,2,3,4,1,2,3,4]
How well did you know this?
1
Not at all
2
3
4
5
Perfectly