Saturday, April 29, 2023

Function in Python Test 29 April 2023

 Function Chapter Test  Class - 12 A Computer Science

GBSSS Khajoori Khas

Date: 29/04/2023

 

1. What will be the output of the following code? 

def check(): 

global num 

num=1000 

print(num) 

num=100 

print(num) 

check()

 print(num)

 

2. Function can alter only Mutable data types? (True/False)

 


3. What will be the output of the following code? 

 

def drawline(char='$',time=5): 

print(char*time) 

drawline() 

drawline('@',10) 

drawline(65) 

drawline(chr(65))

 

4. What will be the output of the following code? 

def Fun1(mylist): 

for i in range(len(mylist)): 

if mylist[i]%2==0: 

mylist[i]/=2 

else: 

mylist[i]*=2 

list1 =[21,20,6,7,9,18,100,50,13] 

Fun1(list1) 

print(list1)

 

5. What will be the output of the following code? 

X = 100 

def Change(P=10, Q=25): 

global X 

if P%6==0: 

X+=100 

else: 

X+=50 

Sum=P+Q+X 

print(P,'#',Q,'$',Sum) 

Change() 

Change(18,50) 

Change(30,100)

 

6. What will be the output of the following code? 

def Alter(M,N=50): 

M = M + N 

N = M - N 

print(M,"@",N) 

return M

A=200 

B=100 

A = Alter(A,B) 

print(A,"#",B) 

B = Alter(B) 

print(A,‟@‟,B)

 

7. A Function can call another function or itself? (True/False)
8. _______ keyword is used to define a function
9. What are the different types of function? 
10. What are the different types of function arguments?




Series in Pandas Test - 29 April 2023

 Class 12 - B Series in Pandas Test:, GBSSS Khajoori Khas

1. Create a Series and Explain the use of head() and tail()

import pandas as pd

D=[10,20,30,40,50,60,70,80,90]

I=['a','b','c','d','e','f','g','h','i']

S=pd.Series(D,I)

print(S)

print(S.head())  #print —-------------------- elements

print(S.tail())     #print —-------------   elements

print(S.head(3))    #print —-----------------  elements

print(S.tail(3))    #print —----------- elements

print(S.head(-2))   #print —--- —---------------- elements (not print —------------  elements)

print(S.tail(-2))   #print —---------------- elements (not print —---------------- elements)

2. Which of the following are modules/libraries in Python?

a. NumPy

b. Pandas

c. Matplotlib

d. All of the above

3. NumPy stands for ____

a. Number Python

b. Numerical Python

c. Numbers in Python

d. None of the above

  1. _________ is an important library used for analyzing data.

a. Math

b. Random

c. Pandas

d. None of the above

  1. Important data structure of pandas is/are ___________

a. Series

b. Data Frame

c. Both of the above

d. None of the above

  1. Pandas Series can have _________________ data types

a. float

b. integer

c. String

d. All of the above

  1. _________ is used when data is in Tabular Format.

a. NumPy

b. Pandas

c. Matplotlib

d. All of the above

  1. Which of the following commands is used to install pandas?

a. pip install pandas

b. install pandas

c. pip pandas

d. None of the above


Friday, December 30, 2022

12 CS Pre Board Dec 2022

 

SECTION - A

1. False

2. C - 18

3. C -  a

4. D - **

5. D - 4map

6. B - random

7. []  / Empty List

8. D - Server

9. C - flush()

10 . B - Stop

11 . A - SMTP, POP

12. B - ALTER

13. A - read()

14. A - 0

15. C - (comma) ,

16. B - commit()

17. A

18. A

SECTION - B

Q: 19.

def swap(d):

    n = {}

    values = d.values()

    keys = list(d.keys())

    k = 0

    for i in values:

        n[i] = keys[k]

        k=k+1

    return n

result = swap({'a':1,'b':2,'c':3})

print(result)


Output:

{1: 'a', 2: 'b', 3: 'c'}

Q: 20

Cookies are small pieces of text sent to your browser by a website you visit. They help that website remember information about your visit, which can both make it easier to visit the site again and make the site more useful to you.

Advantages

Cookies are extremely user friendly.

Disadvantages

Size limitations also exist on cookies. They cannot store large amount of information. Most cookies are able to store information only up to 4kb.

OR

Client-side scripting

It runs on the user’s computer.

HTML, CSS, and JavaScript are used.

Server-side scripting

It runs on the webserver.

PHP, Python, Java, Ruby are used.

Q: 21 (a)

mystring = 'Programming is Fun'

print(mystring[-50:10:2].swapcase())

pORMI

Q: 21 (b)

a,b,c,d = (1,2,3,4)

mytuple = (a,b,c,d)*2+(5**2,)

print(len(mytuple)+2)

11


Tuesday, December 27, 2022

12 IP Pre Board Dec 2022 Solution

 Section - A

1. LAN 

2. Data Theft

3. Unused Old computer

4. 12

5. 26000

6. Free

7. ii - SELECT COUNT (FEE) FROM STUDENT;

8. ROUND()

9. MIN()

10. iv - S1.tail()

11. student_df.sort_values(by=["marks"])

12. All of these

13. Avast

14.Dayname()

15. Patent

16. Digital Footprint

17. B

18. B

Section - B

19.  

Static Website:

Static website is the basic type of website that is easy to create.

A static site is a website built with pages of static content, or plain html, JavaScript, or CSS code. 

Dynamic Website:

Dynamic website is a collection of dynamic web pages whose content changes dynamically. 

It accesses content from a database or Content Management System (CMS). Therefore, when you alter or update the content of the database, the content of the website is also altered or updated.


OR


Four networking goals are:

Resource sharing.

Reliability.

Cost-effective.

Fast data sharing.


20. 

SELECT house, count(*) FROM Student group by house having house='Green' or house='Orange';

21.

Having Clause

The HAVING clause used in SQL  with aggregate functions because the WHERE keyword cannot be used with aggregate functions.

Having clause is only used with the SELECT clause.

Having clause is generally used after GROUP BY.


SELECT column_name(s) FROM table_name WHERE condition GROUP BY column_name(s) HAVING condition ORDER BY column_name(s);


Example:

SELECT COUNT(CustomerID), Country FROM Customers GROUP BY Country HAVING COUNT(CustomerID) > 5;


22.

import pandas as pd

D={'H1':40,'H2':30,'H3':35,'H4':45}

A=pd.Series(D)

print(A)


H1    40

H2    30

H3    35

H4    45

dtype: int64


23.

IPR

Intellectual property rights are the rights given to persons over the creations of their minds.

There are four main types of intellectual property rights, including patents, trademarks, copyrights, and trade secrets.


OR


Net Etiquettes.

  • Be respectful.
  • Be aware of what you are commenting on social media.
  • Be careful with humor and sarcasm.
  • You should take care of how you are sharing your data and who can see this.
  • Friend requests and group invites should be checked before you accept them.

24.

0     True

1    False

2     True

3    False

dtype: bool

25.

(a) Digital Footprints

A digital footprint is data that is left behind when users have been online. There are two types of digital footprints which are passive and active. A passive footprint is made when information is collected from the user without the person knowing this is happening. An active digital footprint is where the user has deliberately shared information about themselves either by using social media sites or by using websites.


(b) Phishing

Phishing is described as a fraudulent activity that is done to steal confidential user information such as credit card numbers, login credentials, and passwords. Phishing is described as a fraudulent activity that is done to steal confidential user information such as credit card numbers, login credentials, and passwords


26.

(I) Select Tname, Salary from Teacher;

(II) Select sum(salary) from Teacher;

(III) Select count(NoofPeriod) from Teacher;

OR

(I) ALL THE BEST

(II) INFOR

(III) INDIA


27.

import pandas as pd

D=[[110,'Gurman',98],[111,'Rajveer',95],[112,'Samar',96],[1113,'Yuvraj',88]]

DF=pd.DataFrame(D,columns=['Id','Name','Marks'])

print(DF)


     Id     Name  Marks

0   110   Gurman     98

1   111  Rajveer     95

2   112    Samar     96

3  1113   Yuvraj     88


28.

import numpy as np

import pandas as pd


D={'Name':['Item1','Item2','Item3','Item4'],'Price':[150,180,225,500]}

DF=pd.DataFrame(D)

print(DF)

DF['Special_Price']=[135,150,200,440]

print(DF)

DF.loc[4] = ['The Secret',800,500]

print(DF)

del DF['Special_Price']

print(DF)


29

(I) - Cyber Bullying

(II) Report to local police station and cyber cell, E-FIR, Inform to parents

(III) IT Act 2000

OR

Free and open-source software (FOSS) is a term used to refer to groups of software consisting of both free software and open-source software where anyone is freely licensed to use, copy, study, and change the software in any way, and the source code is openly shared so that people are encouraged to voluntarily improve the design of the software

Example of FOSS:

GNU/Linux, Mozilla Firefox, VLC media player,SugarCRM,GIMP,VNC,Apache web server,LibreOffice.


30.

(I)  select * from emp;

(II) select ename, sal, deptno from emp where comm is null;

(III) select empno, ename, sal, sal * 12 as 'Annual Salary' from emp;

31.

(I) SELECT MID("INDIASHINING", 7,7);

(II) SELECT INSTR("WELCOMEWORLD", 'COME') ;

(III) SELECT ROUND(23.78,1);

(IV) SELECT MOD(100,9);

(V) SELECT TRIM(userid) from users;


OR


UCASE()

The UCASE() function converts a string to upper-case.

Syntax

UCASE(text)

Ex:

SELECT UCASE("ram");

RAM


TRIM()

The TRIM() function removes leading and trailing spaces from a string.

Syntax

TRIM(string)

SELECT TRIM('    RAM    ');

RAM

MID()

The MID() function extracts a substring from a string (starting at any position).

Syntax

MID(string, start, length)

SELECT MID("Manmohan", 5, 3);

oha

DAYNAME()

The DAYNAME() function returns the weekday name for a given date.

Syntax

DAYNAME(date)

SELECT DAYNAME("2022-12-30");

Friday

POWER()

The POWER() function returns the value of a number raised to the power of another number.

Syntax

POWER(x, y)

SELECT POWER(4, 2);

16


Q: 32

(I) Server should be installed in Admin department as it has maximum number of computers.

(II) 







(III)  Hub/Switch
(IV) Dynamic
(V)  Video Conferencing

Q: 33.

import matplotlib.pyplot as plt
MT=['Gold','Silver','Bronze']
M=[20,15,17.5]
plt.bar(MT, M)
plt.xlabel('Medal Type')
plt.ylabel('Medal')
plt.title('Indian Medal Tally in Olympics')
plt.show()
plt.savefig("abc.png")





OR

import matplotlib.pyplot as plt
Week=[1,2,3,4]
Avg_week_temp=[40,42,38,44]
plt.plot(Week, Avg_week_temp)
plt.show()


Q: 34

(I) select Lcase(CName)/lower(CName) from cloth;
(II) select min(price) from cloth;
(III) select count(size) from cloth where size = 'M';

OR

Select count(CName) from cloth where year(DOP) = '2022';

Q: 35

import numpy as np
import pandas as pd

D={'School':{'CO1':'PPS','CO2':'JPS','CO3':'GPS','CO4':'MPS','CO5':'BPS'},
  'Tot_students':{'CO1':40,'CO2':30,'CO3':20,'CO4':18,'CO5':28},
  'Topper':{'CO1':32,'CO2':18,'CO3':18,'CO4':10,'CO5':20},
  'First_Runnerup':{'CO1':8,'CO2':12,'CO3':2,'CO4':8,'CO5':8}
}
DF=pd.DataFrame(D)
print(DF)

  School  Tot_students  Topper  First_Runnerup
CO1    PPS            40      32               8
CO2    JPS            30      18              12
CO3    GPS            20      18               2
CO4    MPS            18      10               8
CO5    BPS            28      20               8


print(DF.shape)
(5, 4)
print(DF[2:4])
  School  Tot_students  Topper  First_Runnerup
CO3    GPS            20      18               2
CO4    MPS            18      10               8
print(DF.iloc[2:5,2:3])
    Topper
CO3      18
CO4      10
CO5      20
print(DF['Tot_students']-DF['First_Runnerup'])
CO1    32
CO2    18
CO3    18
CO4    10
CO5    20
dtype: int64


Tuesday, December 6, 2022

What is DataFrame?


12 CS Function Assignment - 06 Dec

1. What is function?

2. Explain the types of function?

3. Write the name of 10 built in function of Python.

4. Write the name of 5 modules of Python.

5. Write the 5 functions of math module.

6. Write the 5 functions of random module.

7. Write the 5 functions of Statistics module.

8. Write the 5 functions of pickle module.

9. Write the 5 functions of csv module.

10. Write the syntax to define and call the user defined function.

Tuesday, November 1, 2022

Class 11 CS Assignment


Q. 1: What is the full form of CPU?

(a)   Central Processing Unit

(b)  Control Processing Unit

(c)   Common Processing Unit

(d)  Common Programming Unit

Q. 2: What is the decimal equivalent of binary number 11001?

(a)   3

(b)  25

(c)   31

(d)  None of these

Q. 3: Which is the correct ascending order of memory unit?

(a)   TB, PB, GB, MB

(b)  PB, MB, GB, TB

(c)   MB, GB, TB, PB

(d)  MB, GB, PB, TB

Q. 4: Which of the following is Utility software?

(a)   Windows

(b)  MS-Office

(c)   Tally

(d)  Quick Heal

Q. 5: First General of computer operate with - 

(a)   Vacuum Tube

(b)  Transistor

(c)   IC

(d)  Microprocessor

Q. 6: What is the full form of ISCII?

(a)   International Script Code for Information Interchange

(b)  Indian Script Code for Information Interchange

(c)   Information Script Code for Information Interchange

(d)  Indian Skill Code for Information Interchange

Q. 7: The octal equivalent of the decimal number 417 ------

(a)   619

(b)  640

(c)   641

(d)  598

Q. 8: Convert the Hexadecimal Number 1E2 to decimal?

(a)   480

(b)  482

(c)   483

(d)  484

Q. 9: What is the output of (-22%5) in Python?

(a)   2

(b)  3

(c)   -2

(d)  -3

Q. 10: What is the output of (5 and 3) in Python?

(a)   5

(b)  3

(c)   True

(d)  False

Q. 11: What is the output of (not 5 and 3 or 7)?

(a)   5

(b)  3

(c)   7

(d)  None of these

Q. 12: What is the output of -4j +3?

(a)   -4j +3

(b)  3+4j

(c)   (3-4j)

(d)  3-4j

Q. 13: Which is an immutable type?

(a)   List

(b)  String

(c)   Tuple

(d)  Dictionary

Q. 14: Which is a valid identifier?

(a)   if

(b)  True

(c)   for

(d)  none

Q. 15: Which is a complex number?

(a)   3 + 4i

(b)  2i + 4

(c)   4 – 3j

(d)  3 + (-1)1/2

Q. 16: What is the full form of IDLE?

(a)   Integrated Development Environment  

(b)  Integrated Development and Learning Environment  

(c)   Integrated Design and Learning Environment  

(d)  Integrated Digital and Learning Environment