0% found this document useful (0 votes)
20 views6 pages

Python Program Record Arranged

The document contains a series of Python programs demonstrating various programming concepts such as data types, arithmetic operators, area and circumference of a circle, value swapping, distance calculation, and conditional statements. Each section includes a program followed by its expected output. The programs cover basic functionalities like checking odd/even numbers, finding the greatest number, leap year determination, a simple calculator, and a student grading system.

Uploaded by

ronaldoannsnows
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)
20 views6 pages

Python Program Record Arranged

The document contains a series of Python programs demonstrating various programming concepts such as data types, arithmetic operators, area and circumference of a circle, value swapping, distance calculation, and conditional statements. Each section includes a program followed by its expected output. The programs cover basic functionalities like checking odd/even numbers, finding the greatest number, leap year determination, a simple calculator, and a student grading system.

Uploaded by

ronaldoannsnows
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

PANIMALAR ENGINEERING COLLEGE

Department of Artificial Intelligence & Data Science

1(A) Demonstration of Data Types


PROGRAM:

a = 10
print("Integer value:", a)
print("Type:", type(a))

b = 10.5
print("\nFloat value:", b)
print("Type:", type(b))

c = 2 + 3j
print("\nComplex value:", c)
print("Type:", type(c))

d = "Hello"
print("\nString value:", d)
print("Type:", type(d))

e = [1, 2, 3]
print("\nList value:", e)
print("Type:", type(e))

f = (4, 5, 6)
print("\nTuple value:", f)
print("Type:", type(f))

OUTPUT:

1(B) Demonstration of Arithmetic Operators


PROGRAM:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
print("\nResults:")
print("Addition:", a + b)
print("Subtraction:", a - b)
print("Multiplication:", a * b)
print("Division:", a / b)
print("Floor Division:", a // b)
print("Modulus:", a % b)
print("Power:", a ** b)

OUTPUT:

1(C) Area and Circumference of a Circle


PROGRAM:

import math

r = float(input("Enter the radius of the circle: "))

area = [Link] * r * r
circumference = 2 * [Link] * r

print("Area of the circle:", area)


print("Circumference of the circle:", circumference)

OUTPUT:

1(D) Swapping of Two Values


PROGRAM:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

print("Before swapping:")
print("a =", a)
print("b =", b)
temp = a
a=b
b = temp

print("After swapping:")
print("a =", a)
print("b =", b)

OUTPUT:

1(E) Distance Between Two Points


PROGRAM:

import math

x1 = float(input("Enter x1: "))


y1 = float(input("Enter y1: "))
x2 = float(input("Enter x2: "))
y2 = float(input("Enter y2: "))

distance = [Link]((x2 - x1)**2 + (y2 - y1)**2)

print("Distance between two points:", distance)

OUTPUT:

2(A)(i) Check Whether the Given Number is Odd or Even


PROGRAM:

n = int(input("Enter a number: "))

if n % 2 == 0:
print("Even number")
else:
print("Odd number")
OUTPUT:

2(A)(ii) Greatest of Two Numbers


PROGRAM:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))

if a > b:
print("Greatest number is", a)
else:
print("Greatest number is", b)

OUTPUT:

2(B)(i) Greatest of Three Numbers (Nested If)


PROGRAM:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
c = int(input("Enter third number: "))

if a > b:
if a > c:
print("Greatest number is", a)
else:
print("Greatest number is", c)
else:
if b > c:
print("Greatest number is", b)
else:
print("Greatest number is", c)

OUTPUT:
2(B)(ii) Check Whether the Given Year is Leap Year
PROGRAM:

year = int(input("Enter a year: "))

if year % 4 == 0:
if year % 100 == 0:
if year % 400 == 0:
print("Leap Year")
else:
print("Not a Leap Year")
else:
print("Leap Year")
else:
print("Not a Leap Year")

OUTPUT:

2(C)(i) Calculator
PROGRAM:

a = int(input("Enter first number: "))


b = int(input("Enter second number: "))
op = input("Enter operator (+, -, *, /, //): ")

if op == '+':
print("Result =", a + b)
elif op == '-':
print("Result =", a - b)
elif op == '*':
print("Result =", a * b)
elif op == '/':
print("Result =", a / b)
elif op == '//':
print("Result =", a // b)
else:
print("Invalid operator")
OUTPUT:

2(C)(ii) Student Grade System


PROGRAM:

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

if marks >= 90:


print("Grade A")
elif marks >= 75:
print("Grade B")
elif marks >= 50:
print("Grade C")
else:
print("Fail")

OUTPUT:

You might also like