You are on page 1of 33

NAME: ___________________________________

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.

I gratefully acknowledge the contribution of the individuals who


contributed in bringing this project up to this level, who continues to look
after me despite my flaws.

I express gratefully acknowledge the deep sense of


thanks to Dr. Manoj Giri, A guide, Mentor, for his cordial support,
guidance and supervision as well as critically reviewing the project and
helped in solving each and every problem, occurred during
implementation of the 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

Python programming language is a general purpose


interpreted, interactive, object oriented and high-level
programming language. It was developed and designed
by Guido Van Rossum in February 1991 and developed by
python Software Foundation. Under GNU General Public
License(GPL), Python source code is available.

Python is based on or influenced with two programming


languages:

• ABC language, a teaching language created as a


replacement of BASIC, and
• Modula-3, supports interfaces, objects and generics.

Python was named after a famous BBC comedy show


namely, MONTY PYTHON’S FLYING CIRCUS. It is an easy to
learn yet powerful object oriented programming language
and is of high level. Python is dynamically typed and
garbage collected. It supports multiple programming
paradigms, including procedural object oriented and
functional programming.

Python uses English keywords frequently where as


languages use punctuations. It is fewer syntactical
constructions than other languages. Python uses
whitespace indentation rather than curly brackets to
delimit blocks.
ADVANTAGES OF PYTHON

1. Python is considered easy to learn and run almost


anywhere. It is useful for a number of applications,
including education, data analytics and web
development.

1. EASY TO USE: Python is an easy to use and easy


readability language, that helps you think clearly and
maintain the program.

2. OBJECT ORIENTED: Python supports both the procedural


and object-oriented programming.

3. PRODUCTIVITY AND SPEED: Python provide enhanced


process control capabilities and possess strong
integration, thus increasing speed and productivity.

4. PORTABILITY: Python can run on any platform without


changes, unlike, C++ or java.

5. FREE AND OPEN SOURCE: python is developed under an


OSI-approved open source license, which makes it free
to use and distribute, including for commercial purpose.

6. EXTENSIVE SUPPORT LIBRARIES: it provides large standard


libraries including the areas like string operations.
DISADVANTAGES OF PYTHON

1. SPEED LIMITATION: Python is interpreted language and


slow as compared to C/C++ or Java, because
interpreted languages are executed line by line.

2. WEAK IN MOBILE COMPUTING: python has made it


presence on many desktops and server platforms, but
is a weak language for mobile computing or smart
phone-based applications.

3. RUN TIME ERRORS: Python programmers face issues


with design. And thus python needs more testing to
rectify time to time errors, as it is dynamically typed.

4. UNDERDEVELOPED DATABASE ACCESS LAYERS:


compared to more widely used technologies like JDBC
and ODBC, python’s database access is weak.

5. MEMORY CONSUMPTION: python’s memory


consumption is very high, because datatypes of
python are flexible that required more memory.
DATA HANDLING IN PYTHON
Python provides a predefined set of data types for
handling the data it uses. Data can be stored in any of
these types.
“DATA TYPE is a term that is used show the kind of data
values or the type od data that is expected to be
handled.”

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)

2.STRINGS: they are sequence of character data,


delimited using single or double quotes.
3.LISTS: a list contains a series of values, are declared
using brackets [ ], where variable names are separated
by a comma(,). List are mutable, i.e., they can be
changes after creation.

4.TUPLES: tuples is an ordered sequence of items same as


list. The only difference is that tuples are immutable, i.e.,
once created cannot be modified. Tuples are defined by
parentheses ().

5.DICTIONARY: Python dictionaries are lists of key: value


pairs. This is a very powerful datatype to hold a lot of
information that can be associated through keys. Its use is
to extract a value based on key name. dictionaries are
created using braces {}, with pairs separated by comma
(,) and the key values associated using a colon (:). In
dictionaries, key must be unique.
PYTHON PROGRAMMING

1. Write a program in python to find the area and perimeter


of a rectangle whose sides are p and q.

PROGRAM CODE:

p=int(input("enter length of a rectangle: "))


q=int(input("enter breadth of a rectangle: "))
w=2*(p+q)
a=p*q
print("perimeter of the rectangle is",w)
print("area of the rectangle is",a)

OUTPUT:
2. Write a program in python to multiply string value
with integer value.

PROGRAM CODE:

a=input("enter a string value : ")


b=int(input("enter an integer value :"))
c=a*b
print("the output is", c )

OUTPUT:
3. Write a program in python to add two string values.

PROGRAM CODE:

x=input("enter 1st string: ")


y=input("enter 2nd string: ")
z=x+y
print("the sum of 2 strings given is",z)

OUTPUT:
4. Write a program in python for the division of integer
value.

PROGRAM CODE:

a=float(input("enter first integer value(dividend) : "))


b=float(input("enter second integer value(divisor) :"))
c= a/b
print('final result is ', c)

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:

x=int(input('write the range:'))


a=1
for b in range(2,x+1):
print(f'{a}/{b}:',a/b)

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;

x=int(input("enter the last limit number: "))


i=0
while x>i:
f=x-i
i=i+1
print(f)

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:

# import complex math module


import math
a=1
b=5
c=6
# calculate the discriminant
d = (b**2) - (4*a*c)
# find two solutions
sol1 = (-b-math.sqrt(d))/(2*a)
sol2 = (-b+math.sqrt(d))/(2*a)
print('The solution are {0} and {1}'.format (sol1, sol2))

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:

# Python program to find factors of a number


# take inputs
num = int(input('Enter number: '))
# find factor of number
print('The factors of', num, 'are:')
for i in range(1, num+1):
if(num % i) == 0:
print(i, end=' ')

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:

string = " "


s = ['Know', 'Program','helpful','saatvika']
print(string.join(s))

OUTPUT:
BIBLIOGRAPHY

1. https://www.knowprogram.com

2. Computer Science with Python for class 11 - SUMITA ARORA

3. Computer science class 11- all in one – ARIHANT

You might also like