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

SL Unit-1 Python Programs

The document contains a series of Python programs demonstrating basic programming concepts such as printing output, performing arithmetic operations, and calculating areas and volumes of various geometric shapes. It includes examples for user input and data types, showcasing how to handle variables and functions in Python. The content is structured as a tutorial for students in a scripting language course.

Uploaded by

amimevada
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)
10 views2 pages

SL Unit-1 Python Programs

The document contains a series of Python programs demonstrating basic programming concepts such as printing output, performing arithmetic operations, and calculating areas and volumes of various geometric shapes. It includes examples for user input and data types, showcasing how to handle variables and functions in Python. The content is structured as a tutorial for students in a scripting language course.

Uploaded by

amimevada
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

KDP,PATAN Sem-2 (CE) Scripting Language

Unit -1 Introduction and Syntax of Python programming


PYTHON PROGRAMS
# Program to print Hello World

print("Hello, World")

# Program to add two numbers

a = 10
b = 20
sum = a + b
print("Sum =", sum)

# Program to print details like name, age, marks


name = "Ramesh"
age = 25
marks = 85.5

print("Name:", name)
print("Age:", age)
print("Marks:", marks)

# Program to read details like name, age, marks from user and print it

name = input("Enter your name: ")


age = int(input("Enter your age: "))
marks= int(input("Enter your marks: "))

print("Name:", name)
print("Age:", age)
print(“Marks:”,marks)

# Program to find Area of Rectangle


l = float(input("Enter length: "))
b = float(input("Enter breadth: "))
area = l * b
print("Area of Rectangle =", area)

# Program to find Area of Circle


r = float(input("Enter radius: "))
area = 3.14 * r * r
print("Area of Circle =", area)

# Program to find Area of Cuboid


l = float(input("Length: "))
b = float(input("Breadth: "))
h = float(input("Height: "))
area = 2*(l*b + b*h + h*l)
print("Surface Area of Cuboid =", area)
KDP,PATAN Sem-2 (CE) Scripting Language

# Program to find Area of Cube


a = float(input("Enter side: "))
area = 6 * a * a
print("Surface Area of Cube =", area)

# Program to find Volume of Cylinder


r = float(input("Radius: "))
h = float(input("Height: "))
vol = 3.14 * r * r * h
print("Volume =", vol)

# Program to find Volume of Cone


r = float(input("Radius: "))
h = float(input("Height: "))
vol = (1/3) * 3.14 * r * r * h
print("Volume =", vol)

# Program to find Volume of Sphere


r = float(input("Radius: "))
vol = (4/3) * 3.14 * r**3
print("Volume =", vol)

# Program to find Perimeter of Rectangle


l = float(input("Length: "))
b = float(input("Breadth: "))
print("Perimeter =", 2*(l+b))

# Program to find Area of Square


a = float(input("Side: "))
print("Area =", a*a)

# Program to find Area of Triangle


b = float(input("Base: "))
h = float(input("Height: "))
print("Area =", 0.5*b*h)

# Program to print datatype of variable.


a = 10 # int
b = 5.5 # float
c = 3 + 4j # complex

print(type(a))
print(type(b))
print(type(c))

You might also like