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

Untitled Document

Uploaded by

asthagoswami77
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)
6 views2 pages

Untitled Document

Uploaded by

asthagoswami77
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
You are on page 1/ 2

CHAPTER:4:-

(EXAMPLES AND PRACTICAL IMPLEMENTATIONS)


Example 1: Write a python script to input two numbers and find their
sum and product.
Solution:
n1= input(“Enter first number:”)
n1= eval(n1)
n2= input(“Enter second number:”)
n2= eval(n2)
sum =n1+n2
print(“Sum of the numbers=”,sum)
prod =n1*n2
print(“Product of the numbers=”,prod)
******Output******

Example 2: A student has to travel a distance of 450 km by car at a


certain average speed. Write python script to find the total time
taken to cover the distance.
Solution:
Distance=450
Speed=eval (input(“Enter average speed:”))
#to input speed from the user
Time=Distance/Speed #Calculate time taken
print(“Distance is:”,Distance)
print(“Time taken:”,Time,”hr”)
******Output******

Example 3: Write a python code to calculate simple interest by


inputting the value of principal amount and rate from the user for a
time of 5 years.
Solution:
Principal=eval(input(“Enter the value of principal:”))
Rate=eval(input(“Enter the annual rate of interest:”))
Time=5
Simple_Int = (Principal*Rate*Time)/100
Amount = Principal+Simple_Int
print(“Simple Interest = Rs.”,Simple_Int)
print(“Amount payable =Rs.”,Amount)
******Output******

You might also like