0% found this document useful (0 votes)
3 views

two program in python

The document outlines two Python programs: one for calculating the area of a circle using a constant for pi and user input for the radius, and another for performing various arithmetic, comparison, logical, and assignment operations on two user-input numbers. Both programs include detailed algorithms and coding examples, demonstrating successful execution and output verification. The first program calculates the area, while the second showcases multiple operations with user inputs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

two program in python

The document outlines two Python programs: one for calculating the area of a circle using a constant for pi and user input for the radius, and another for performing various arithmetic, comparison, logical, and assignment operations on two user-input numbers. Both programs include detailed algorithms and coding examples, demonstrating successful execution and output verification. The first program calculates the area, while the second showcases multiple operations with user inputs.
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 6

Date: PROGRAM USING VARIABLES, CONSTANTS, I/O

EX.No: 01 STATEMENTS IN PYTHON.

Aim:

To write a program is to calculate the area of a circle using a constant


value for piand user input for the radius.

ALGORITHM:

Step 1: Start the program

Step 2: Initialize a constant variable PI with the value 3.14159.

Step 3: Prompt the user to enter the radius of the circle.

Step 4: Read the input value and store it in a variable radius.

Step 5: Calculate the area of the circle using the formula area = PI * radius * *2

Step 6: Display the calculated area of the circle.

Step 7: Stop the Program.


CODING:

PI = 3.14159

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

area = PI * radius ** 2

print("The area of the circle with radius is:",area)

Output:

Result:

Thus, the given Program has been executed successfully and output
verified.
Date: PROGRAM USING OPERATORS IN PYTHON.
EX.No: 02

Aim:

To write a program is to perform various operations using python

ALGORITHM:

Step 1: Start the program

Step 2: Get the user to input from num1 and num2

Step 3: Perform arithmetic operations using num1 and num2

Step 4: Perform Comparison operations using num1 and num2

Step 5: Perform Logical operations using num1 and num2

Step 6: Perform Assignment operations using num1 and num2

Step 7: Display the Output.

Step 7: Stop the Program.


CODING:

print("Operators in python")
num1 = float(input("Enter the first number: "))
num2 = float(input("Enter the second number: "))
print("**** Arithmetic Operator****")
addition = num1 + num2
subtraction = num1 - num2
multiplication = num1 * num2
division = num1 / num2
modulus = num1 % num2
exponent = num1 ** num2
print("Addition:",addition)
print("Subtraction:",subtraction)
print("Multiplication:",multiplication )
print("Division:",division)
print("Modulus:",modulus )
print("Exponentiation:",exponent)
print("*****Comparison Operations*****")
is_equal = num1 == num2
is_not_equal = num1 != num2
is_greater = num1 > num2
is_less = num1 < num2
is_greater_equal = num1 >= num2
is_less_equal = num1 <= num2
print("Equal to:",is_equal)
print("Not equal to:",is_not_equal)
print("Greater than:",is_greater)
print("Less than:",is_less)
print("Greater than or equal to:",is_greater_equal)
print("Less than or equal to:",is_less_equal)
print("*****Logical Operations*****")
and_operation = (num1 > 0) and (num2 > 0)
or_operation = (num1 > 0) or (num2 > 0)
not_operation = not(num1 > 0)
print("Logical AND (both > 0):",and_operation)
print("Logical OR (either > 0):",or_operation)
print("Logical NOT (not num1 > 0):",not_operation)
print("*****Assignment Operation*****")
num1 += 5
num2 *= 2
print("After num1 += 5:", num1)
print("After num2 *= 2:", num2)
Output:

Result:

Thus, the given Program has been executed successfully and output
verified.

You might also like