Professional Documents
Culture Documents
COURSE: _________________________________
ROLL NO.: _______________________________
SUBMITTED TO: ___________________________
COLLEGE: _______________________________
SIGNATURE: _____________________________
24/06/2023
ACKNOWLEDGEMENT
Apart from the efforts of me, the success of any project depends largely
on the encouragement and guidelines of many others. I take this
opportunity to express my gratitude to the people who have been
instrumental in the successful completion of this project.
The guidance and support received from all my friends and classmates
who contributed and who are contributing to this project, was vital for the
success of the project. I am grateful for their constant support and help.
SAATVIKA MAULIHAR
INTRODUCTION TO PYTHON
numbers
DATA TYPES
strings
lists
tuples
dictionary
1.NUMBERS: number data type contains only numeric
value in python. There are types:
• Integers (whole numbers)
• Floating point numbers (decimal numbers)
• Complex numbers (real and imaginary part)
PROGRAM CODE:
OUTPUT:
2. Write a program in python to multiply string value
with integer value.
PROGRAM CODE:
OUTPUT:
3. Write a program in python to add two string values.
PROGRAM CODE:
OUTPUT:
4. Write a program in python for the division of integer
value.
PROGRAM CODE:
OUTPUT:
5. Write a program in python to apply Boolean condition.
PROGRAM CODE:
#boolean condition
n=int(input('enter the value of a : '))
m=int(input('enter the value of b : '))
o=int(input('enter the value of c : '))
p=int(input('enter the value of d : '))
x=n<m
y=o<p
print('the boolean condition in x and y is' , x or y)
print('the boolean condition in x and y is',x and y)
print('the value if a is greater that the value of b ;',x,'\n the
value of c is greater or less than the value of d :', y)
OUTPUT:
6. Write a program in python to understand string
indexing.
PROGRAM CODE:
str='hello my world'
print (str)
str1=str.replace('world','friends')
print (str1)
OUTPUT:
7. Write a program in python for string indexing and
replacing strings with user given set of strings.
PROGRAM CODE:
string=input('enter the string:')
print(string)
x=int(input('enter index value of string :'))
print('the index value of string:',string[x])
a=int(input("enter start value:"))
b=int(input('enter stop value;'))
c=int(input('enter step value:'))
print(string[a:b:c])
y=input('enter the replacing value;')
print(string.replace(string[5:10],y))
OUTPUT:
8. Write a program in python that equivalent to
1/2,1/4,1/3,1/10.
PROGRAM CODE:
OUTPUT:
9. Write a program in python to find the mean, median,
and mode for a given list of numbers in a list datatype.
PROGRAM CODE:
import statistics as s
print(" library imported succesfully")
list1=[1,2,2,3,4,5,8,4,5,7,4,3,5,4,3,4,5,7,9,6,5,8,7,9,6,3,2,2,4,5,6
,5,6]
print ('the mean of the list is:',s.mean(list1))
print('the mode of the list is:',s.mode(list1))
print('the median of the list is:',s.median(list1))
OUTPUT:
10. Write a program in python to compute distance
between two points.
PROGRAM CODE:
import math
a=float(input('enter a value of first side ;'))
b=float(input('enter a value of second side;'))
c=math.sqrt(a**2+b**2)
print ("the value of third side is", c)
OUTPUT:
11. write a program in python to check whether the
given number is odd or even number.
PROGRAM CODE:
x=int(input('enter a number:'))
if x%2==0:
print ("the given number is even")
else:
print("the given number is odd")
OUTPUT:
12. Write a program in python to show indentation
error purposefully.
PROGRAM CODE:
x=0
for i in range (1, 10):
x=x+i
OUTPUT:
13. Write a program in python to generate a random
number between 0 to 18.
PROGRAM CODE:
import random
print(random.randint(0,18))
OUTPUT:
14. Write a program in python to generate a random
number between user defined limit.
PROGRAM CODE:
Import random
L=int(input(“enter lower limit: “))
U=int(input(“enter upper limit : “))
Print(random.randint(L,U))
OUTPUT:
15. Write a program in python to generate a random
number between user defined limit and insert a loop
until a specific number comes.
PROGRAM CODE:
import random
i=0
L=int(input("enter lower limit: "))
U=int(input("enter upper limit : "))
F=int(input("enter the number you want: "))
while(i!=F):
i=random.randint(L,U)
print(i)
OUTPUT:
16. Write a program in python using while loop that
asks the user for number that prints a countdown from
that number to 0.
PROGRAM CODE;
OUTPUT:
17. write a program in python to test whether 2 strings
are nearly equal.
PROGRAM CODE:
#write a program to test whether 2 strings are nearly equal.
a=input("enter a string")
b=input("enter another string")
if a==b:
print ("matched")
else:
print ("unmatched")
OUTPUT:
18. write a program to display Fibonacci series.
PROGRAM CODE:
n=int(input("Enter the number of terms till which you want
to display fibonacci series:"))
n1=0
n2=1
count=0
if n<=0:
print("Invalid input")
elif n==1:
print("fibonacci series upto",n,"term:",n1)
else:
print("fibonacci series upto",n,"term:",n2)
while count<n:
print(n1,end=",")
nth=n1+n2
n1=n2
n2=nth
count=count+1
OUTPUT:
19. write a program in python to Solve the quadratic
equation ax**2+bx+c=0.
PROGRAM CODE:
OUTPUT:
20. Write a program in python to count vowels in a
user assigned string.
PROGRAM CODE:
def countVowels(string):
num_vowels=0
# to count the vowels
for char in string:
if char in "aeiouAEIOU":
num_vowels = num_vowels+1
return num_vowels
string = input('Enter any string: ')
print('No of vowels =',countVowels(string))
OUTPUT:
21. Write a program in python to print multiplication
table.
PROGRAM CODE:
num = int(input('Display multiplication table of: '))
# print multiplication table
for i in range(1, 11):
print ("%d * %d = %d" % (num, i, num * i))
OUTPUT:
22. Write a program to find factors of a user defined
integer.
PROGRAM CODE:
OUTPUT:
23. Write a program in python to convert binary into
decimal numbers.
PROGRAM CODE:
def BinaryDecimal(n): #user-defined function
num, dec, base = n, 0, 1
temp = num
while(temp):
digit = temp % 10
temp = int(temp / 10)
dec += digit * base
base = base * 2
return dec
num = int(input('Enter a binary number: '))
print('The decimal value is =', BinaryDecimal(num))
OUTPUT:
24. Write a program in python to multiply two lists in
python.
PROGRAM CODE:
list1 = [5,6,4,3]
list2 = [3,5,3,3]
print("List1:", str(list1))
print("List2:", str(list2))
result = []
for i in range(0, len(list1)):
result.append(list1[i] * list2[i])
print("Product:", str(result))
OUTPUT:
25. Write a program to convert list to string in python.
PROGRAM CODE:
OUTPUT:
BIBLIOGRAPHY
1. https://www.knowprogram.com