1.
PROGRAM USING VARIABLES, CONSTANTS, I/O STATEMENTSIN PYTHON
AIM:
The aim of the program is to calculate the area of a circle using a constant value for pi and
user input for the radius.
ALGORITHM:
Step 1: Initialize a constant variable PI with the value 3.14159.
Step 2: Prompt the user to enter the radius of the circle.
Step 3: Read the input value and store it in a variable radius.
Step 4: Calculate the area of the circle using the formula area = PI * radius * radius.
Step 5: Display the calculated area of the circle.
CODING:
PI = 3.14159
radius = float(input("Enter the radius of the circle: "))
area = PI * radius * radius
print("The area of the circle is:", area)
OUTPUT:
Enter the radius of the circle: 5
The area of the circle is: 78.53975
2. PROGRAM USING OPERATORS IN PYTHON
AIM:
The aim of the program is to perform basic arithmetic operations using operators in
Python.
ALGORITHM:
Step 1: Prompt the user to enter two numbers.
Step 2: Read the input values and store them in variables num1 and num2.
Step 3:Perform the following operations:
Addition: result = num1 + num2
Subtraction: result = num1 - num2
Multiplication: result = num1 * num2
Division: result = num1 / num2
Modulo: result = num1 % num2
Exponentiation: result = num1 ** num2
Step 4: Display the results of each operation
CODING:
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
result = num1 + num2
print("Addition:", result)
result = num1 - num2
print("Subtraction:", result)
result = num1 * num2
print("Multiplication:", result)
result = num1 / num2
print("Division:", result)
result = num1 % num2
print("Modulo:", result)
result = num1 ** num2
print("Exponentiation:", result)
OUTPUT:
Enter the first number: 10
Enter the second number: 3
Addition: 13.0
Subtraction: 7.0
Multiplication: 30.0
Division: 3.3333333333333335
Modulo: 1.0
Exponentiation: 1000.0
3. PROGRAM USING CONDITIONAL STATEMENTS.
AIM:
The aim of the program is to determine whether a given number is positive, negative, or zero
using conditional statements in Python.
ALGORITHM:
Step 1: Prompt the user to enter a number.
Step 2: Read the input value and store it in a variable number.
Step 3: Use conditional statements to check the value of number.
Step 4: If num is greater than or equal to 0, display "Number is Positive".
Step 5: If num is equal to 0, display "Number is 0".
Step 6: Otherwise display "Number is Negative".
Step 7: End the program.
CODING:
number= int(input("Enter a number: "))
if number > 0:
if number==0:
print(‘Number is 0’)
else:
print(‘Number is Positive’)
else:
print(‘Number is Negative’)
OUTPUT:
Enter a number: 5
Number is Positive
Enter a number: -2
Number is Negative
Enter a number: 0
Number is 0
4. PROGRAM USING LOOPS.
AIM:
The aim of the program is to display the factorial of given number using loop in Python.
ALGORITHM:
Step 1: Prompt the user to enter a number.
Step 2: Read the input value and store it in a variable number.
Step 3: Use looping statement to check the value of number.
Step 4:Calculate the factorial of the number.
Step 5: Print the value.
CODING:
n= int(input("Enter a Number: "))
factorial=1
for i in range(1,n+1):
factorial*=i
print(f”factorial of {n}is {factorial}”)
OUTPUT:
Enter a Number:5
Factorial of 5 is 120
5. PROGRAM USING JUMP STATEMENTS.
AIM:
The aim of the program is to demonstrate the use of jumping statements in Python.
ALGORITHM:
Step 1: Define the values in variable.
Step 2: Inside the loop, check if the number is greater than 500.
Step 3: If the number is greater than 500,break the statement.
Step 4: If the number greater than 150, continue the statement.
Step 5: Check the value is divided by 5,print the value.
CODING:
number=[1,2,3,4,5,6,7]
for num in number:
if num == 6:
print("found6, breaking loop")
break
Print(number)
OUTPUT:
75
145
150