You are on page 1of 4

Mini project with IOT Lab

Name: Sahi USN: 4SN21MC039

Program No: 01 Date: 06.12.2022

Program Statement: Run some python programs on Pi like:

A) Read your name and print Hello Message with name.


B) Read two numbers and print their Sum, Difference, Product, Division.
C) Calculate the number of Words and Character String.
D) Read two input numbers and calculate the area of a given (Rectangle, Triangle and
Circle) reading shape and appropriate values from standard output.
E) A program to print a name ‘n’ times where name & value has to be input from standard
input.
F) A program to handle Divide by Zero Exception.
G) A program to print current time with an interval of 10 seconds import time.
H) Read file line by line & print the word count of each line.

1A) Source Code:

name = input("Please Enter Your Name Here:\n")


print("Hello "+name)

Output:

Please Enter Your Name Here: Sahil


Hello Sahil

1B) Source Code:


num1 = int(input("Enter First Number: ")) num2 =
int(input("Enter Second Number: ")) print("Sum of the
Two Number", num1+num2) print("Difference of the
Two Numbers", num1-num2) print("Multiplication of the
Two Numbers",num1*num2) print("Division of the Two
Numbers", num1/num2)

Output:
Enter First Number: 10
Enter Second Number: 5
Sum of the Two Number 15
Difference of the Two Numbers 5
Multiplication of the Two Numbers 50
Division of the Two Numbers 2.0

Department Of MCA 1
Mini project with IOT Lab

1C) Source Code:

print("Enter a sentence")
sentence=input()
words=sentence.split()
word_count=0
character_count=0 for word in
words: word_count+=1
character_count+=len(word)
print("Total numbers of words in the sentence are:",word_count)
print("Total numbers of characters in the sentence excluding spaces are:",character_count)
print("Total numbers of characters in the sentence including spaces
are:",character_count+word_count-1)

Output:

Enter a sentence
Iam fine
Total numbers of words in the sentence are: 2
Total numbers of characters in the sentence excluding spaces are: 7
Total numbers of characters in the sentence including spaces are: 8

1D) Source Code:

while True: print("***************")


print("Select the Shape to calculate Area")
print("""1.Rectangle 2.Triangle
3.Circle 4.Exit""")
choice=input()
if(choice=='1'):
print("Enter the width of the rectangle in meters")
width=int(input())
print("Enter the height of the rectangle in meters")
height=int(input())
print("The area of a given rectangle is ",width*height,"square meters")
continue elif(choice=='2'): print("Enter the base width of the triangle
in meters") base=int(input())
print("Enter the height of the triangle in meters")
height=int(input())
print("The area of a given triangle is ",0.5*base*height,"square meters")
continue elif(choice=='3'): print("Enter the radius of the circle in
meters") radius=int(input())
print("the area of a given circle is ",3.14*radius*radius,"square meters ")

continue
elif(choice=='4'):

Department Of MCA 2
Mini project with IOT Lab

break
else:
print("please enter a valid number from the menu")
continue
print("Thank you")

Output:

***************
Select the Shape to calculate Area
1.Rectangle 2.Triangle
3.Circle 4.Exit
1
Enter the width of the rectangle in meters
20
Enter the height of the rectangle in meters
21
The area of a given rectangle is 420 square meters
***************
Select the Shape to calculate Area
1.Rectangle 2.Triangle
3.Circle 4.Exit
2
Enter the base width of the triangle in meters
12
Enter the height of the triangle in meters
5
The area of a given triangle is 30.0 square meters
***************
Select the Shape to calculate Area
1.Rectangle 2.Triangle
3.Circle 4.Exit
3
Enter the radius of the circle in meters
24
the area of a given circle is 1808.6399999999999 square meters
***************
Select the Shape to calculate Area
1.Rectangle 2.Triangle
3.Circle 4.Exit
10
please enter a valid number from the menu ***************
Select the Shape to calculate Area
1.Rectangle 2.Triangle
3.Circle 4.Exit

Department Of MCA 3
Mini project with IOT Lab

Department Of MCA 4

You might also like