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

Ritik Dabas Program

The document contains 20 programs written in Python with their source code and output. The programs cover basics concepts like remainder, exponent, area calculation for different shapes, functions, if-else conditions to check voting eligibility, even-odd numbers, gender etc.

Uploaded by

ritikdabas443
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)
10 views

Ritik Dabas Program

The document contains 20 programs written in Python with their source code and output. The programs cover basics concepts like remainder, exponent, area calculation for different shapes, functions, if-else conditions to check voting eligibility, even-odd numbers, gender etc.

Uploaded by

ritikdabas443
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
You are on page 1/ 20

PROGRAM 9

#WAP IN PYTHON TO GET REMAINDER OF TWO NUMBERS

SOURCE CODE :

print("This is a program which will help you\n to get remainder of two numbers-------")
x=input("ENTER NUMBER 1 HERE :-")
y=input("ENTER NUMBER 2 HERE :-") result=int(x)
%int(y) print("*********
RESULT **************") print(result)
print("*******************************")

OUTPUT:

This is a program which will help you

to get remainder of two numbers-------

ENTER NUMBER 1 HERE :-24

ENTER NUMBER 2 HERE :-4

********* RESULT **************

*******************************
PROGRAM 10

#WAP IN PYTHON TO FIND VALUE OF NUMBER WITH AN EXPONENT :-

SOURCE CODE :

print("This is a program which will help you\n to get value of a number with an exponent---------")
x=input("ENTER NUMBER 1 HERE :-")
y=input("ENTER THE EXPONENT OF NUMBER 1 :-")
result=int(x)**int(y)
print("********* RESULT **************")
print(result) print("*******************************")

OUTPUT:

This is a program which will help you

to get value of a number with an exponent---------

ENTER NUMBER 1 HERE :-5

ENTER THE EXPONENT OF NUMBER 1 :-3

********* RESULT **************

125

*******************************

PROGRAM 11
#WAP IN PYTHON TO FIND THE AREA OF THE CIRCLE

SOURCE CODE :

print("---------------------------------------------------|")
print("this program will help you to fid area of circle :-|")
print("---------------------------------------------------|\n")
print("VALUE OF PY WILL BE 3.14")
py=3.14
r=input("RADIOUS OF CIRCLE IS :-")
AREA=int(py)*int(r)*int(r)
print("----------- RESULT ---------------")
print("Area of the circle is :-",AREA)
print("----------------------------------")

OUTPUT:

---------------------------------------------------|

this program will help you to fid area of circle :-|

---------------------------------------------------|

VALUE OF PY WILL BE 3.14

RADIOUS OF CIRCLE IS :-12

----------- RESULT ---------------

Area of the circle is :- 432

----------------------------------

PROGRAM 12
#WAP IN PYTHON TO FIND THE AREA OF THE SQUARE

SOURCE CODE :

print("---------------------------------------------------|")
print("this program will help you to fid area of square :-|")
print("---------------------------------------------------|\n")
side=input("SIDE OF THE SQUARE IS :-")
AREA=int(side)**2
print("----------- RESULT ---------------")
print("Area of the squre is :-",AREA)
print("----------------------------------")

OUTPUT:

---------------------------------------------------|

this program will help you to fid area of square :-|

---------------------------------------------------|

SIDE OF THE SQUARE IS :-8

----------- RESULT ---------------

Area of the squreis :- 64

----------------------------------

PROGRAM 13
#WAP IN PYTHON TO FIND THE AREA OF THE RECTANGLE

SOURCE CODE :

print("---------------------------------------------------|") print("this program will help you to find area of


rectangle :-|") print("---------------------------------------------------|\n") l=input("LENGTH OF THE
RECTANGLE IS(in cm) :-") b=input("BREDTH OF THE RECTANGLE IS(in cm):-") AREA=int(l)*int(b)
print("----------- RESULT ---------------") print("Area of the rectangle is :-",AREA,"cm")
print("----------------------------------")

OUTPUT:

---------------------------------------------------|

this program will help you to find area of rectangle :-|

---------------------------------------------------|

LENGTH OF THE RECTANGLE IS(in cm) :-6

BREDTH OF THE RECTANGLE IS(in cm):-14

----------- RESULT ---------------

Area of the rectangle is :- 84 cm

----------------------------------

PROGRAM 14
#WAP IN PYTHON TO FIND THE AREA OF THE TRIANGLE

SOURCE CODE :

print("---------------------------------------------------|")
print("this program will help you to find area of triangle ")
print("---------------------------------------------------|\n")
l=input("LENGTH OF THE TRIANGLE IS(in cm) :-")
h=input("HEIGHT OF THE TRIANGLE IS(in cm):-")
AREA=1/5*int(l)*int(h)
print("----------- RESULT ---------------")
print("Area of the triangle is :-",AREA,"cm")
print("----------------------------------")

OUTPUT:

---------------------------------------------------|

this program will help you to find area of triangle

---------------------------------------------------|

LENGTH OF THE TRIANGLE IS(in cm) :-15

HEIGHT OF THE TRIANGLE IS(in cm):-8

----------- RESULT ---------------

Area of the triangle is :- 24.0 cm

----------------------------------

PROGRAM 15
#WAP IN PYTHON TO TYPE A MESSAGE USING USER DEFINED FUNCTION

SOURCE CODE :

#WAP IN PYTHON TO TYPE A MESSAGE USING USER DEFINED FUNCTION

def message():
print("____Hello World____")

print("My name is Python")

print("I was born in 1991")

print("I was discovered by GUIDO VAN ROSSUM")

print("Thank You :)")

message()

OUTPUT:

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/hjbhb.py
========================================================

____Hello World____

My name is Python

I was born in 1991

I was discovered by GUIDO VAN ROSSUM

Thank You :)

PROGRAM 16
#WAP IN PYTHON WHETHER USER CAN GIVE VOTE OR NOT

SOURCE CODE :

#WAP IN PYTHON WHETHER USER CAN GIVE VOTE OR NOT

print("---------VOTING------------")
age=int(input("Enter your age:-"))

if age>=18:

print("WELCOME , You are eligible to give vote-------- ")

else:

print("Sorry, You are under age or have chosen invalid number please try again")

OUTPUT:

===== RESTART: C:/Users/RITIK/AppData/Local/Programs/Python/Python421bhj.py =====

---------VOTING------------

Enter your age:-17

Sorry, You are under age or have chosen invalid number please try again

========================================================= RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/bhj.py
=========================================================

---------VOTING------------

Enter your age:-20

WELCOME , You are eligible to give vote--------

PROGRAM 17
#WAP IN PYTHON WHETHER THE TWO NUMBERS ARE GREATER OR NOT USING NESTING OF IF
AND ELSE

SOURCE CODE :
#WAP IN PYTHON WHETHER THE TWO NUMBERS ARE GREATER OR NOT USING NESTING OF IF AND
ELSE
print("-----------------------------")
num1=int(input("Enter number 1:-"))
num2=int(input("Enter number 2:-"))
if num1>num2:
print("Number 1 is GREAER than Number 2")
elif num2>num1:
print("Number 2 is GREAER than Number 1")
else:
print("BOTH NUMBERS ARE EQAL")

OUTPUT:

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/hjvhj.py
========================================================

-----------------------------

Enter number 1:-4

Enter number 2:-8

Number 2 is GREAER than Number 1

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/hjvhj.py
========================================================

-----------------------------

Enter number 1:-5

Enter number 2:-9

Number 2 is GREAER than Number 1

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/hjvhj.py
========================================================

-----------------------------

Enter number 1:-9

Enter number 2:-2

Number 1 is GREAER than Number 2


PROGRAM 18
#WAP IN PYTHON WHETHER THE NUMBER IS EVEN NUMBER OR NOT

SOURCE CODE :

print("--------------------------------------------")

num1=int(input("Enter number 1:-"))

if num1%2==0:
print("Yes, Number 1 is an Even number")

else:

print("No, Number 1 is an odd number")

OUTPUT:

========================================================= RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/hjbh.py
========================================================

--------------------------------------------

Enter number 1:-26

Yes, Number 1 is an Even number

========================================================= RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/hjbh.py
=======================================================

--------------------------------------------

Enter number 1:-87

No, Number 1 is an odd number

PROGRAM 19
#WAP IN PYTHON WHETHER THE USER GENDER IS MALE OR FEMALE

SOURCE CODE :

#WAP IN PYTHON WHETHER THE USER GENDER IS MALE OR FEMALE

print("----------------<< GENDER >>--------------)

print("What is your gender : MALE , FEMALE or OTHER")


gender=input("ENTER YOUR GENDER(CHOOSE FROM ABOVE)")

if gender=="MALE":

print("YOU ARE WELCOME, YOU ARE MALE")

elif gender=="FEMALE":

print("YOU ARE WELCOME, YOU ARE FEMALE")

elif gender=="OTHER":

print("YOU ARE WELCOME, YOU ARE TRANS GENDER")

else:

print("SORRY, you have chosen an invalid option")

OUTPUT:
======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/jbjhbh.py
=======================================================

-----------------<< GENDER >>--------------

What is your gender : MALE , FEMALE or OTHER

ENTER YOUR GENDER(CHOOSE FROM ABOVE)FEMALE

YOU ARE WELCOME, YOU ARE FEMALE

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/jbjhbh.py
=======================================================

-----------------<< GENDER >>--------------

What is your gender : MALE , FEMALE or OTHER

ENTER YOUR GENDER(CHOOSE FROM ABOVE)female

SORRY, you have chosen an invalid option

PROGRAM 20
#WAP IN PYTHON TO IDENTIFY DAYS OF WEEK USING IF, ELIF , ELSE

SOURCE CODE :

#WAP IN PYTHON TO IDENTIFY DAYS OF WEEK USING IF, ELIF , ELSE

print("----------- DAYS OF WEEK ---------------")

print("1: MONDAY\n2: TUESDAY\n3: WEDNESDAY\n4: THURSDAY\n5: FRIDAY\n6: SATURDAY\n7:


SUNDAY")
day=int(input("CHOSE A DAY FROM THE FOLLOWING(NUMBER):-"))

if day==1:

print("\nYOU HAVE SELECTED MONDAY :)")

elif day==2:

print("\nYOU HAVE SELECTED TUESDAY :)")

elif day==3:

print("\nYOU HAVE SELECTED WEDNESDAY :)")

elif day==4:

print("\nYOU HAVE SELECTED THURSDAY :)")

elif day==5:

print("\nYOU HAVE SELECTED FRIDAY :)")

elif day==6:

print("\nYOU HAVE SELECTED SATURDAY :)")

elif day==7:

print("\nYOU HAVE SELECTED SUNDAY :)")

else:

print("\nSorry, You have chosen invalid option ,please renter the number”)

“OUTPUT:

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/gjfjh.py
========================================================

----------- DAYS OF WEEK ---------------

1: MONDAY

2: TUESDAY

3: WEDNESDAY
4: THURSDAY

5: FRIDAY

6: SATURDAY

7: SUNDAY

CHOSE A DAY FROM THE FOLLOWING(NUMBER):-5

YOU HAVE SELECTED FRIDAY :)

PROGRAM 21
#WAP IN PYTHON USING FOR LOOP
SOURCE CODE :
#WAP IN PYTHON USING FOR LOOP
for letter in "PYTHON":
print(letter)

OUTPUT:

P
Y

SOURCE CODE :

num=[10,20,30,40,50,60]
for a in num :
print (num)
OUTPUT:

========================================================= RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/hjhj.py
========================================================
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]
[10, 20, 30, 40, 50, 60]

PROGRAM 22
#WAP IN PYTHON TO PRINT A TABLE USING FOR LOOP
SOURCE CODE :
a=[1,2,3,4,5,6,7,8,9,10]
table=int(input("ENTER ANY TABLE NUM THAT YOU WANT TO PRINT"))
for i in a :
print(table,"X",i,"=",table*i)

OUTPUT:
======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/jgyuh.py
========================================================
ENTER ANY TABLE NUM THAT YOU WANT TO PRINT6
6X1=6
6 X 2 = 12
6 X 3 = 18
6 X 4 = 24
6 X 5 = 30
6 X 6 = 36
6 X 7 = 42
6 X 8 = 48
6 X 9 = 54
6 X 10 = 60

PROGRAM 23
#WAP IN PYTHON TO FIND FACTORIAL OF A NUMBER USING FOR LOOP
SOURCE CODE :
num=int(input("ENTER A NON NEGATIVE NUMBER TO FIND FACTORIAL :"))
fact=1
for i in range(num):
fact*=(i+1)
print("Factorial of",num,"is",fact)
OUTPUT:

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Pytho421/jgyuh.py
========================================================
ENTER A NON NEGATIVE NUMBER TO FIND FACTORIAL :4
Factorial of 4 is 24

PROGRAM 24
#WAP IN PYTHON TO REVERSE THE NUMBERS USING FOR LOOP
SOURCE CODE :
num = int(input("Enter Number Limit :"))
print("Reverse the numbers are as follows:-")
for i in range(num,0,-1):
print(i)
OUTPUT:

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/jgyuh.py
========================================================
Enter Number Limit :10
Reverse the numbers are as follows:-
10
9
8
7
6
5
4
3
2
1

PROGRAM 25
#WAP IN PYTHON TO PRINT THE FOLLOWING PATTERN USING FOR LOOP :
*
**
***
****
*****
SOURCE CODE :
for i in range (1,6):
for j in range (1,i+1):
print("*",end='')
print("")
print("")

OUTPUT:

======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/jgyuh.py
========================================================
*
**
***
****
*****

PROGRAM 26
#WAP IN PYTHON TO PRINT YOUR NAME USING WHILE LOOP :
SOURCE CODE :
name=1
while name<6:
print("MY NAME IS RITIK DABAS")
name+=1
OUTPUT:
======================================================== RESTART:
C:/Users/RITIK/AppData/Local/Programs/Python/Python421/jgyuh.py
========================================================
MY NAME IS RITIK DABAS
MY NAME IS RITIK DABAS
MY NAME IS RITIK DABAS
MY NAME IS RITIK DABAS
MY NAME IS RITIK DABAS

You might also like