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

PYTHON Lab File

Uploaded by

Jitendra Padwar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views

PYTHON Lab File

Uploaded by

Jitendra Padwar
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

PROGRAM-1 date –

Aim: -A) Create a list and perform the following methods


1) insert ()
2) remove ()
3) append ()
4) Len ()
5) pop ()
6) clear ()

Program: -
a= [1,3,5,6,7, [3,4,5],"hello"]
print(a)
a. insert (3,20)
print(a)
a. removes (7)
print(a)
a. appends ("hi")
print(a)
Len(a)
print(a)
a.pop (6)
print(a)
a. clear ()
print(a)

output: -

1|Page
2|Page
PROGRAM-2

Aim: -
A) Write a python program to add two numbers.

Program: -

a=int (input ("enter the value for a"))


b=int (input ("enter the value for b"))
c=a+b
print ("The sum of a and b is”, c)

output: -

3|Page
PR
PROGRAM-3 date -

Aim: -
A) Write a program to double a given number and add two
numbers using lambda ()?

Program: -
double = lambda x:2*x
print (double (5))
add = lambda x, y:x+y
print (add (5,4)

output: -

4|Page
PROGRAM-4
Aim: -
A) Demonstrate a python code to implement abnormal
termination?

Program: -

a=15
b=5
print(a/b)

output: -

date -
5|Page
PROGRAM-5

Aim: -

A) Write a python program to get python version.

Program: -

import sys

print ("System version is:")


print (sys. version)
print ("Version Information is:")
print (sys. version info)
output: -
System version is:

3.8.2 (default, mar 13 2020, 10:14:16)

[GCC 9.3.0]

Version information is:

Sys. Version _info (major=3, minor=8, micro=2, release level=’final’, serial=0)

G
System version is:
System version is:
System version is:
System version is:
3.8.2 (default, Mar 13 2020, 10:14:16)

date -
6|Page
PROGRAM-6

Aim: -

A) Write a python program to print date, time for today


and now.

Program: -

import datetime
a=datetime. datetime. today ()
b=datetime.datetime.now ()
print(a)
print(b)
output: -

7|Page
PROGRAM-7 date -

Aim: -

A) Write a python program to concatenate the data


frames with two different objects.
Program: -

import pandas as pd
one=pd. Data Frame ({'Name’:
['SAROJ','PREETI','SHASHI'],
'age’: [19,20,22]},
index= [1,2,3])
two=pd. Data Frame ({'Name’:
['KAJAL','VARSHA','DEEPIKA'],
'age’: [20,21,23]},
index= [4,5,6])
print (pd. concat ([one, two]))
output: -

8|Page
PROGRAM-8
Aim: -

A) Write a python code to set background color and pic and draw a circle
using turtle module
Program: -
1. #Python Program to draw a circle filled with colour in Turtle
2. import turtle
3. ttl = turtle. Turtle ()
4.
5. #Providing the colour to be filled
6. ttl. Color("green")
7.
8. #Instructing to "begin" and "end" filling the "circle"
9. ttl. begin fill ()
10. ttl. Circle (90)
11. ttl.end_fill ()
12.
13. #Hiding the turtle after completing the drawing
14. ttl. hide turtle ()
15. turtle. Done ()

output: -

date -

9|Page
PROGRAM-09
Aim: -

A)Write a python Program to display create four object of the student


class by using classes and objects.

Program: -
1. # Define a class
2. class student:
3. # Define an attribute
4. student_Rollno = 0

5. # Create two objects of the student class


6. student1= student ()
7. student2 = student ()
8. student3=student ()
9. student4=student ()
10. # Access attributes using student1
11. student1.studentRollno = 1020
12. print (f"Saroj Rollno: {student1.studentRollno}")

13. # Access attributes using student2


14. student2.studentRollno = 1007
15. print (f"Deepika Rollno: {student2.studentRollno}")

10 | P a g e
16. # Access attributes using student3
17. student3.studentRollno = 1012
18. print (f"varsha Rollno: {student3.studentRollno}")
19. # Access attributes using student4
20. student4.studentRollno = 1024
21. print (f"kajal Rollno: {student4.studentRollno}")

output: -

date -

11 | P a g e
PROGRAM-10
Aim: -
A) Using a numpy module create an array and check the
following:

1. Type of array
2. Axes of array
3. Shape of array
4. Type of elements in array

Program: -
import numpy as np
arr=np. array ([[1,2,3,4],[4,2,5,3]])
print ("Array is of type:”, type(arr))
print ("no. of dimensions: “arr. ndim)
print ("Shape of array: “arr. shape)
print ("Size of array:”, arr. size)
print ("Array stores elements of type:"), arr. dtype

output: -

date -

12 | P a g e

You might also like