Instructions:
Prepare a Practical File.
Write all programs in right side lined page
write sample input and output in left hand side blank page
write programs serially as per list of practicals
Instructions:
Prepare a Practical File.
Write all programs in right side lined page
write sample input and output in left hand side blank page
write programs serially as per list of practicals
Important Python code to import and export dataframe to CSV file for Project Class XII CBSE
writing DataFrame to CSV File
data = {
"name": ['RAM', 'SHYAM', 'SITA'],
"calories": [420, 380, 390],
"duration": [50, 40, 45]
}
df = pd.DataFrame(data)
print(df)
df.to_csv("devendra_test.csv")
Output of print(df) statement
This is how file will look like in CSV File
Reading CSV File into Python DataFrame
df = pd.read_csv("devendra_test.csv")
print(df)
Output of print(df) statement
Reading CSV File into Python DataFrame with no Extra Columns Added
df = pd.read_csv("devendra_test.csv",\
usecols=["name", "calories","duration"],\
dtype={"name": str, "calories":np.int32, "duration": np.float32})
print(df)
Again Output of print(df) statement
YouTube links for MySQL Basics
Click below links to watch video lectures on MySQL
CLASS XI-IP
Answer Key - UT-1 exam - 2020-21
NOTE – Theory answers can be searched in book.
Q. Convert 2.5GB into bytes
(2.5 x 1024 x 1024 x 1024) Bytes
GB -> MB -> KB -> Byte
Q. Write output of following
i. print(“kv\nnepa”)
kv
nepa
ii. x, x=12,15
y, y=x+10,x+20
print(x, y)
x = 15, y = 35
iii. print(4/2)
2.0
Q. write name of function to find datatype of a variable x.
type()
Q. write a program to input a number form user and find its square.
num = int(input(“Enter a Number”))
sqr = num*num
print(“Square of “, num, ” is “, sqr)
Q. Q. Convert into python expression
Q - A
(B+P)8
Q – A/((B+P)**8)
or
Q - A/math.pow((B+P),8)
Q. Write a
program to obtain x, y, z from user and calculate 4x2 + 3y3 + 9z + 18
import math
x = int(input(“Enter value of x”))
y = int(input(“Enter value of y”))
z = int(input(“Enter value of z”))
res = 4*(x**2) + 3*(y**3) + 9*z + 18*math.pi
print(res)
Q. Given a list iterate it and display numbers which are divisible by 5 and if you find number greater than 150 stop the loop iteration
list1 = [12, 15, 32, 42, 55, 75, 122, 132, 150, 180, 200]
Expected output:
15
55
75
150
list1 = [12, 15, 32, 42, 55, 75, 122, 132, 150, 180, 200]
for i in list1:
if(i>150):
break
if(i%5 == 0):
print(i)
Q. Q. Write a program to Reverse the following list using for loop
list1 = [10, 20, 30, 40, 50]
Expected output:
50
40
30
20
10
list1 = [10, 20, 30, 40, 50]
for i in range(len(list1)-1, -1 , -1):
print(list1[i])
Q. Q. Write a program to Accept number from user and calculate the sum of all number between 1 and given number
For example user given 10 so the output should be 55
num = int(input(“Enter a NUmber”))
sum = 0
for i in range(1,num+1):
sum = sum + i
print(sum)
XII-IP Practical List 2020-21
click here to download XII-IP Practical List 2020-21
Instructions:
Prepare a Practical File.
Write all programs in right side lined page
write sample input and output in left hand side blank page
write programs serially as per list of practicals
UT-1 (IP)
Class XII
August 2020
Answers -
# -*- coding: utf-8 -*-
"""
Created on Mon Aug 31 07:44:55 2020
@author: devendra
"""
import pandas as pd
import numpy as np
#-------------------------------------Ans1
D1={'Rollno':[1,2,3,4,5], 'Name':['Arun','mohit', 'karan','lalit', 'ravi'], 'age':[18, 14,13,16,14], 'Marks':[68, 47,78,87,60]}
D2=pd.DataFrame(D1)
print(D2)
#-------------------------------------Ans2
print(D2["Name"])
#-------------------------------------Ans3
print(D2.Name[1],D2.Marks[1],D2.Rollno[1],D2.age[1])
# OR
print(D2[D2.Rollno==2])
#-------------------------------------Ans4
print(D2[["Rollno","Name","Marks"]])
#-------------------------------------Ans5
D2["city"] = "Nepanagar"
#print(D2)
#-------------------------------------Ans6
D2.age[2] = 15
#-------------------------------------Ans7
del D2["Marks"]
#-------------------------------------Ans9
'''
i.Training Compound because it has largest number of computers, so according to 80:20 rule, it will be most suitable place.
ii.a) repeater should be connected between-
*Main compound to resource compound
*main compound to training compound
*resource compound to finance compound
*training compound to finance compound
This is because repeater should be connected where the distance between two locations is more than 70m
ii b) Hub/Switch should be placed in every building where there are more than one computers.
So it should be placed in every building.
iii.Optical fibre because it is gives bery high speed but it is very expensive,
if we want cheap alternative then answer will be telephone analog line.
'''
#-------------------------------------Ans10
D1=[200, 500,200,100]
S1=pd.Series(D1, index=['a', 'b', 'c', 'd'])
print(S1)
#-------------------------------------Ans11
print(S1.min())
#-------------------------------------Ans12
print(S1[0::2])
'''
a 200
c 200
'''
#-------------------------------------Ans13
print(S1[::-1])
'''
d 100
c 200
b 500
a 200
'''
#-------------------------------------Ans14
import matplotlib.pyplot as pl
bookno=[30, 32,36,42,41,57,60,62,70]
pl.hist(bookno, orientation='horizontal', histtype='step')
pl.show()
#-------------------------------------Ans15
import matplotlib.pyplot as pl
Year = [1920,1930,1940,1950,1960,1970,1980,1990,2000,2010]
Unemp_india = [9.8,12,8,7.2,6.9,7,6.5,6.2,5.5,6.3]
Unemp_pak = [3,4,5,6,7,8,9,10,11,12]
pl.plot(Year, Unemp_india, 'r', label='india')
pl.legend("lower right")
pl.plot(Year, Unemp_pak, 'g', label='Pakistan')
pl.legend("lower right")
pl.xlabel("Year")
pl.ylabel("Unemployment rate")
pl.xlim(1920, 2000)
pl.title("Unemployment rate Vs Year")
pl.show()