Adobe Scan 13-May-2024
Adobe Scan 13-May-2024
string2)
print ("Captilized words String",
string and checks whether it is a palindrone string or not.
8. Write aprogram that reads a
V Solution. :")
string = input ("Enter a string
length = len(string)
mid = length/2
rev = 1
else : palindrome")
print(string, "is not a
break
#l0op else
apalindrome")
else:
print (string, "is
when both are sequences ?
different from strings XAinã WaVS:
DATE:
CREATING APYTHONPROGRAM TO DISPLAY FIBONACCL SERIES
AIM:
To write a Python Program to display Fibonacci Series up to 'n' numbers.
SOURCE CODE:
First=0
Second=1
no=int (input("How many Fibonacci numbers you want to display?"))
if no<=0:
print ("Please Enter Positive Integer")
else:
print (First)
print (Second)
for i in range (2, no) :
Third=First+Second
First=Second
Second=Third
print (Third)
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE QUTPUT:
Python Executed Program Qutput:
8
13
EXNO:6
DATE:
CREATING APYTHON PROGRAM TO GENERATE RANDOM NUMBER
BETWEEN 1 TO 6
AIM:
between 1 to 6 to simulate
To write a Python program to generate random number
the dice.
SQURCE CODE:
import random
while True:
Choice=input ("\nDo you want to roll the dice (y/n) : ")
no=random. randint (1,6)
if Choice=='y':
print ("\nYour Number is:",no)
else:
break
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE QUTPUT:
Python ExecutedOutput Program:
Do you want tO roll the dice (y/n) :y
Your Number is: 5
11)
Q5.Write a program to input a character and to print
whether a given character is an alphabet, digit or any
other character.
Ans:
Spyder (ython 3.7)
File Edit Search Source Run Debug Consoles Projects Toos View Help
Editor - C:Usersladmin\Desktoplalpha.py
ortant.py 3 connectivity.py prime number.py compound interest.py asci.py algha.py X 4
1 char=input ("Enter a character:")
2 if char.isalpha():
print (" Entered character is alphabet")
4 elif char. isdigit():
5 print ("Entered character is digit")
6 else:
7 print (" Entered character is a special character")
8
Output:
In [12]: runfile('C:/Users/admin/Desktop/alpha. py'.
wdir='c:/Users/a dmin/Desktop')
Enter a character:r
Entered character is alphabet
EX.NO: 3
DATE:
AIM:
To write a menu driven Python Program to find Factorial and sum of list of numbers
using function.
SOURCE CODE:
elif opt=-2:
n=int (input ("Enter how many elements you want to store in List?: "))
for i in range (n) :
ele=int (input (0)
L.append (ele)
Sum List (L)
Result:
Thus, the above Python program has been executed and the output is verified
successfully.
SAMPLE OUTPUT:
Python Executed Program Qutput:
1. To Find Factorial
2. To Find sun of List elements
Enter your choice:1
Enter a number to find Factorial:5
The Factorial of 5 is: 120