Python Code Library (Manual) For Beginner's by DR Kiransing Paradeshi
Python Code Library (Manual) For Beginner's by DR Kiransing Paradeshi
For Beginners
Python Practical, S.Y (B.tech)
A Code Library On
Faculty In charge
Dr K.P.Paradeshi
Python Practical, S.Y (B.tech)
INDEX
Practical no 1
Outcomes-
Step2: Click on the download button and check for the compatibility of your system.
1
Python Practical, S.Y (B.tech)
2
Python Practical, S.Y (B.tech)
3
Python Practical, S.Y (B.tech)
4
Python Practical, S.Y (B.tech)
Anaconda Navigator
5
Python Practical, S.Y (B.tech)
Spyder
Jupyter Notebook
6
Python Practical, S.Y (B.tech)
7
Python Practical, S.Y (B.tech)
8
Python Practical, S.Y (B.tech)
Install Pycharm
9
Python Practical, S.Y (B.tech)
10
Python Practical, S.Y (B.tech)
11
Python Practical, S.Y (B.tech)
Step7: After you click on “Finish” button the following screen will appear
12
Python Practical, S.Y (B.tech)
Practical no 2
Title-To study operators using python programming
Programs-
2.1 – A program in python using operators
2.2- A program in python to get area and perimeter of circle, rectangle,
square and triangle
13
Python Practical, S.Y (B.tech)
Practical no 2.1
Program-Basic operators
Num1=int(input("Enter the first number ="))
Num2=int(input("Enter the second number ="))
print("Addition is=",Num1+Num2)
print("Substraction is=",Num1-Num2)
print("Division is=",Num1/Num2)
print("Multiplication is=",Num1*Num2)
print("Modulus is=",Num1%Num2)
print("Floor division is=",Num1//Num2)
print("{a}raise to {b} is=",Num1**Num2)
Output-
14
Python Practical, S.Y (B.tech)
Practical no 2.2
Program-Area and perimeter of circle, triangle, square and rectangle
Output-
15
Python Practical, S.Y (B.tech)
Practical no 2.3
Program-Conversion of temperature
Output-
16
Python Practical, S.Y (B.tech)
Practical no 3
Aim – To study control structure and loop using python programming
Programs -
3.1-To input marks of the student and output the grades
3.2-Finding out the factorial of given number
3.3-Python program to add first 100 numbers
3.4-Python program to add first 50 odd and even numbers
3.5-Python program to get addition of a given number
3.6-Finding out the largest and smallest among three numbers
17
Python Practical, S.Y (B.tech)
Practical no 3.1
Program- To input marks of the student and output the grades
Output-
18
Python Practical, S.Y (B.tech)
Practical no 3.2
Program- Finding out the factorial of given number
Output-
19
Python Practical, S.Y (B.tech)
Practical no 3.3
Program- Python program to add first 100 numbers
Output-
20
Python Practical, S.Y (B.tech)
Practical no 3.4
Program- Python program to add first 50 odd and even numbers
Output-
21
Python Practical, S.Y (B.tech)
Practical no 3.5
Program- Python program to get addition of a given number
Output-
22
Python Practical, S.Y (B.tech)
Practical no 3.6
Program- Finding out the largest and smallest among three numbers
Output-
23
Python Practical, S.Y (B.tech)
Practical no 4
Title- To learn string operations and methods using python programming
Program-
4.1-To study string operation and method using python program
4.2-A program in python to find out number of vowels and other special character
in string
24
Python Practical, S.Y (B.tech)
Practical no 4.1
Program- To study string operation and method using python programming
25
Python Practical, S.Y (B.tech)
Output-
26
Python Practical, S.Y (B.tech)
Practical no 4.2
Program-A program in python to find out no of vowels and other special
character in string
str=input("Enter the string =")
count_a=0
count_e=0
count_i=0
count_o=0
count_u=0
count_s=0
count_c=0
count_sc=0
count_f=0
27
Python Practical, S.Y (B.tech)
Practical no 4.3
Program- A program in python to find out distance between character of strings
str1=(input(“Enter the first string”))
str2=(input("Enter the second string "))
print(str1)
print(str2)
count=0
l1=len(str1)
l2=len(str2)
if(l1==l2):
for i in range (l1):
dist=ord(str1[i])-ord(str2[i])
count=count+abs(dist)
print(count)
else:
print("Enter the string of equal length")
28
Python Practical, S.Y (B.tech)
Practical no 5
Title-To learn list operations using python programming
Program-
5.1- Enter the list with heterogeneous elements. Carry out all operations such as
concatenation. Indexing, accessing list, reversing list, appending, pop (), insert (),
remove (), etc.
5.2- A python program to generate and store 20 random numbers in a list in the
range 10 to 100. Print the list delete the numbers in between 20 to 50 from a given
list.
5.3- A python program to create a list of random integers using import random
library. Finding out odd, even and prime numbers from the given list.
5.4- A python program to add, subtract, transpose, multiply two matrix using list
29
Python Practical, S.Y (B.tech)
Practical no 5.1
Program- Enter the list with heterogeneous elements. Carry out all operations
such as concatenation. Indexing, accessing list, reversing list, appending, pop (),
insert (), remove (), etc.
30
Python Practical, S.Y (B.tech)
Output-
31
Python Practical, S.Y (B.tech)
Practical no 5.2
Program- A python program to generate and store 20 random numbers in a list in
the range 10 to 100. Print the list delete the numbers in between 20 to 50 from a
given list.
Output-
32
Python Practical, S.Y (B.tech)
Practical 5.3
Program- A python program to create a list of random integers using import
random library. Finding out odd, even and prime numbers from the given list.
Output-
33
Python Practical, S.Y (B.tech)
Practical 5.4
Program- A python program to add, subtract, transpose, multiply two matrix
using list
34
Python Practical, S.Y (B.tech)
4) Transpose of a matrix
35
Python Practical, S.Y (B.tech)
Practical no 6
Title- To learn tuple operation using python programming
Program-
6.1- A python program to create a tuple, mixed tuple and empty tuple and
performing operations such as :-
6.3- Store the data about shares hold by the users as tuples containing the
following information about shares:-
-share name, date of purchase, cost price, no. Of shares, selling price
Write a program to determine:-
- Total cost of portfolio
- Total amount gained / lost
- Percentage profit made or loss included
36
Python Practical, S.Y (B.tech)
Practical no 6.1
Program- A python program to create a tuple, mixed tuple and empty tuple.
Carry out operations such as:-
Output-
37
Python Practical, S.Y (B.tech)
Practical no 6.2
Program- A python program to perform following:-
- create a tuple and add elements in it.
-operations such as concatenation, repeat operations, etc.
38
Python Practical, S.Y (B.tech)
Output-
39
Python Practical, S.Y (B.tech)
Practical no 6.3
Program- Store the data about shares hold by the users as tuples containing the
following information about shares:-
-share name, date of purchase, cost price, no. Of shares, selling price
Write a program to determine:-
- Total cost of portfolio
- Total amount gained / lost
-percentage profit made or loss included
40
Python Practical, S.Y (B.tech)
Output-
41
Python Practical, S.Y (B.tech)
Practical no 7
Title- To learn dictionary operations using python programming
Program-
7.1- A python program to carry out dictionary operations such as creating
dictionary, accessing, values, mixed dictionary, adding key/ value in dictionary,
modifying values, remove element from dictionary, looping/traversing through
dictionary, using value method, using value/key method or items method, copy
method, get method, update method.
7.2- A program in python to create a dictionary of students to get input name, roll
no, course, semester marks obtained in five subjects, total marks, percentage, etc.
Create a record of five students and print the records using dictionary.
7.3- A program in python to create a dictionary containing grocery items and their
prices. Also create another dictionary containing grocery item and their quantity.
By using values from these two dictionaries compute the bill.
42
Python Practical, S.Y (B.tech)
Practical no 7.1
Program- A python program to carry out dictionary operations such as creating
dictionary, accessing, values, mixed dictionary, adding key/ value in dictionary,
modifying values, remove element from dictionary, looping/traversing through
dictionary, using value method, using value/key method or items method, copy
method, get method, update method.
43
Python Practical, S.Y (B.tech)
44
Python Practical, S.Y (B.tech)
Output-
45
Python Practical, S.Y (B.tech)
Practical no 7.2
Program- A program in python to create a dictionary of students to get input
name, roll no, course, semester marks obtained in five subjects, total marks,
percentage, etc. Create a record of five students and print the records using
dictionary.
46
Python Practical, S.Y (B.tech)
Practical no 7.3
Program- A program in python to create a dictionary containing grocery items
and their prices. Also create another dictionary containing grocery item and their
quantity. By using values from these two dictionaries compute the bill.
47
Python Practical, S.Y (B.tech)
Output-
48
Python Practical, S.Y (B.tech)
Practical no 8
Title- To learn function operation using python programming
Program-
8.1- A python program based on types of arguments in functions
-program using required arguments
-program using keyword arguments
-program using default arguments
-program using variable length arguments
8.4- A python program using function to pass number to a function and shift the
list elements to right as many times the given number.
49
Python Practical, S.Y (B.tech)
Practical no 8.1
Program-A python program based on following arguments in functions
-program using required arguments
-program using keyword arguments
-program using default arguments
-program using variable length arguments
1) Required argument
2) Keyword argument
50
Python Practical, S.Y (B.tech)
3) Default argument
51
Python Practical, S.Y (B.tech)
Practical no 8.2
Program-A python program to find factorial of a given number using
-iterative function
-recursive function
Output-
52
Python Practical, S.Y (B.tech)
Practical no 8.3
Program-A python program using function to create Fibonacci number series.
Output-
53
Python Practical, S.Y (B.tech)
Practical no 8.4
Program- A python program using function to pass a number to a function and
shift the list elements to right as many times the given number.
Output-
54
Python Practical, S.Y (B.tech)
Practical no 9
Title- To learn to create module using the python programming
Program-write a module containing function f1 (), f2 (), f3 () use this as module
F1 () =factorial of given no
55
Python Practical, S.Y (B.tech)
def add(s):
sum=0
for i in range(0,s+1):
sum=sum+i
return(sum)
Output-
56
Python Practical, S.Y (B.tech)
Practical no 10
Title- To learn creating file data structure using python programming
Program-
10.1- Create a file in python and write string and list contents into the file.
1) Write the contents into the file
2) Append the contents into the file
3) Read the file using appropriate methods
10.2- Create a text file and write the string “abcdefghijklmnopqrstuvwxyz” into it.
Read the string and print it in reverse order.
57
Python Practical, S.Y (B.tech)
Practical 10.1
Program- Create a file in python and write string and list contents into the file.
1) Write the contents into the file
2) Append the contents into the file
3) Read the file using appropriate methods
string = "Hello, how are you?"
58
Python Practical, S.Y (B.tech)
Output-
59
Python Practical, S.Y (B.tech)
Practical no 10.2
Program- Create a text file and write the string “abcdefghijklmnopqrstuvwxyz”
into it. Read the string and print it in reverse order.
string = "abcdefghijklmnopqrstuvwxyz"
# Read the contents of the file, reverse them, and print as a list
with open("file2.txt", "r") as file:
output = list(file.read())
output.reverse()
output = "".join(output)
print(output)
output-
60
Python Practical, S.Y (B.tech)
Practical no 11
Title- To learn python programming using turtle
Program-
11.1- A python program to draw a rectangle using turtle.
11.2- A python program to draw a parallelogram using turtle.
61
Python Practical, S.Y (B.tech)
Practical 11.1
Program- Write a python program to draw a rectangle using turtle.
import turtle
screen = turtle.Screen()
screen.setup(width=750, height=400)
for i in range(2):
pen.forward(200)
pen.right(90)
pen.forward(100)
pen.right(90)
turtle.done()
screen.title("rectangle")
pen = turtle.Turtle()
Output-
62
Python Practical, S.Y (B.tech)
Practical 11.2
Program- Write a python code to draw a parallelogram using turtle.
import turtle
screen = turtle.Screen()
screen.setup(width=750, height=400)
screen.title("rectangle")
pen = turtle.Turtle()
for i in range(2):
pen.forward(200)
pen.right(60)
pen.forward(100)
pen.right(120)
turtle.done()
Output-
63
Python Practical, S.Y (B.tech)
64