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

Pythonjournal1 Pages

The document contains two programs: the first program accepts two numbers and performs addition, subtraction, multiplication, division, and modulus operations, displaying the results. The second program calculates the factorial of a given number, handling negative inputs and zero appropriately. Both programs utilize user input and basic control structures 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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views2 pages

Pythonjournal1 Pages

The document contains two programs: the first program accepts two numbers and performs addition, subtraction, multiplication, division, and modulus operations, displaying the results. The second program calculates the factorial of a given number, handling negative inputs and zero appropriately. Both programs utilize user input and basic control structures 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 PDF, TXT or read online on Scribd

Que.2.

Program to accept two numbers and display addition , subtraction ,


multiplication ,division and modules .

Program : x=int(input(" Enter a number"))


y=int(input(" Enter a number"))
z=x+y
print("add",z)
z=x-y
print("sub",z)
z=x*
print("multiply",z)
z=x/y
print("divide",z)
z=x%y
print("modulus",z)
Output :
Que.3. Program to calculate factorial of given number.

Program : n=int(input("enter a no. "))


if n < 0:
print( "Factorial does not exist for negative numbers.")
elif n == 0:
Print("1")
else:
fact = 1
while n > 0:

fact *= n
n -= 1
print(" fact =", fact)
Output :

You might also like