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

Practical Coding 6 Programs

The document contains several Python programs for various tasks including temperature conversion, student mark sheet calculation, area calculation for different shapes, factorial computation, turtle graphics, and solving the Tower of Hanoi problem. Each section provides user prompts for input and displays the corresponding results. The programs illustrate basic programming concepts and user interaction in Python.
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)
2 views11 pages

Practical Coding 6 Programs

The document contains several Python programs for various tasks including temperature conversion, student mark sheet calculation, area calculation for different shapes, factorial computation, turtle graphics, and solving the Tower of Hanoi problem. Each section provides user prompts for input and displays the corresponding results. The programs illustrate basic programming concepts and user interaction in Python.
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

1 .

py = "CONVERTION OF TEMPERATURE"

print([Link](60, '*'))

print("1. Celsius to

Fahrenheit") print("2.

Fahrenheit to Celsius")

user = int(input("Enter Your Choice

: ")) if user == 1:

c = float(input("Enter The Temperature in

Celsius : ")) f = (c * 1.8) + 32

print("Temperature in Fahrenheit =",

f) else:

f = float(input("Enter The Temperature in

Fahrenheit : ")) c = (f - 32) / 1.8

print("Temperature in Celsius =", c)


****************CONVERTION OF TEMPERATURE****************

1. Celsius to Fahrenheit

2. Fahrenheit to

Celsius Enter Your

Choice : 1

Enter The Temperature in Celsius :

37 Temperature in Fahrenheit =

98.6

****************CONVERTION OF TEMPERATURE****************

1. Celsius to Fahrenheit

2. Fahrenheit to

Celsius Enter Your

Choice : 2

Enter The Temperature in Fahrenheit : 98.6

Temperature in Celsius = 37
py = "STUDENT MARK SHEET"

print([Link](60, '*'))

s1 = int(input("Enter a First Subject Mark : "))

s2 = int(input("Enter a Second Subject Mark

: ")) s3 = int(input("Enter a Third Subject

Mark : ")) s4 = int(input("Enter a Fourth

Subject Mark : ")) s5 = int(input("Enter a

Fifth Subject Mark : ")) total = s1 + s2 + s3

+ s4 + s5

avg = total / 5

print(f"TOTAL MARK : {total}")

print(f"AVERAGE : {avg}")

if avg >= 80:

print("GRADE : A")

elif avg >= 70 and avg < 80:

print("GRADE : B")

elif avg >= 60 and avg < 70:

print("GRADE : C")

elif avg >= 40 and avg < 60:

print("GRADE : D")

else:

print("GRADE : E")
*******************STUDENT MARK SHEET********************

Enter a First Subject Mark :

90 Enter a Second Subject

Mark : 85 Enter a Third

Subject Mark : 80 Enter a

Fourth Subject Mark : 95

Enter a Fifth Subject Mark :

88

TOTAL MARK : 438

AVERAGE : 87.6

GRADE : A
py = "AREA OF RECTANGLE SQUARE CIRCLE AND TRIANGLE"

print([Link](60, '*'))

print("\n1. Area of

Rectangle") print("2. Area

of Square") print("3. Area

of Circle") print("4. Area of

Triangle")

shape = int(input("Enter Your Choice : "))

a = int(input("Enter a Number of A : "))

b = int(input("Enter a Number of B : "))

if shape == 1:

area = a * b

print("Area of Rectangle =",

area) elif shape == 2:

area = a * a

print("Area of Square =",

area) elif shape == 3:

import math

area = [Link] * a * a

print("Area of Circle =",

area)
elif shape == 4:

area = 0.5 * a * b

print("Area of Triangle =",

area) else:

print("Invalid Value")

********AREA OF RECTANGLE SQUARE CIRCLE AND TRIANGLE*******

1. Area of Rectangle

2. Area of Square

3. Area of Circle

4. Area of

Triangle Enter Your

Choice : 1 Enter a

Number of A : 10

Enter a Number of B

: 5 Area of

Rectangle = 50

********AREA OF RECTANGLE SQUARE CIRCLE AND TRIANGLE*******

1. Area of Rectangle

2. Area of Square

3. Area of Circle

4. Area of

Triangle Enter

Your Choice : 2
Enter a Number of A

: 6 Enter a Number

of B : 0 Area of

Square = 36

********AREA OF RECTANGLE SQUARE CIRCLE AND TRIANGLE*******

1. Area of Rectangle

2. Area of Square

3. Area of Circle

4. Area of

Triangle Enter

Your Choice : 3

Enter a Number of A

: 7 Enter a Number

of B : 0

Area of Circle = 153.93804002589985

********AREA OF RECTANGLE SQUARE CIRCLE AND TRIANGLE*******

1. Area of Rectangle

2. Area of Square

3. Area of Circle

4. Area of

Triangle Enter Your

Choice : 4 Enter a

Number of A : 10

Enter a Number of B

: 8 Area of Triangle

= 40.0
py = "FACTORIAL"
print([Link](60, '*'))

num = int(input("Enter a Number : "))

if num == 0:
f=

else:

f=1
for i in range(1, num +

1): f = f * i

print(f"The Factorial of {num} is : {f}")

************************FACTORIAL************************

Enter a Number : 5
The Factorial of 5 is : 120
py = "TURTLE GRAPHICS"
print([Link](60,

'*')) import turtle

# Setup window

[Link](800,

600) window =

[Link]()

[Link]("My First Turtle Graphics

Program") # Create turtles

sk =

[Link]()

skk =

[Link]() #

Draw pattern

for i in range(4):
[Link](120) # draw circle of radius

120 [Link](180) # move

forward

[Link]()
py = "TOWER OF HANOI"

print([Link](60, '*'))

def Towerofhanoi(n, source, destination,

auxiliary): if n == 1:

print(f"Move Disk 1 From {source} To

{destination}") return

Towerofhanoi(n - 1, source, auxiliary,

destination) print(f"Move Disk {n} From

{source} To {destination}") Towerofhanoi(n - 1,

auxiliary, destination, source)

# Example: Solve for 4

disks n = 4

Towerofhanoi(n, 'A', 'C', 'B')


***********************TOWER OF HANOI***********************

Move Disk 1 From A To

C Move Disk 2 From A

To B Move Disk 1 From

C To B Move Disk 3

From A To C Move Disk

1 From B To A Move

Disk 2 From B To C

Move Disk 1 From A To

C Move Disk 4 From A

To B Move Disk 1 From

C To B Move Disk 2

From C To A Move Disk

1 From B To A Move

Disk 3 From C To B

Move Disk 1 From A To

C Move Disk 2 From A

To B Move Disk 1 From

C To B

You might also like