0% found this document useful (0 votes)
7 views11 pages

Important Points To Ponder

The document outlines key differences between primary and unique keys in databases, explaining their roles in identifying tuples and handling duplicates and nulls. It also describes the behavior of natural joins in SQL, the evaluation order of print statements in Python, and the use of various methods and functions across lists, dictionaries, and file handling. Additionally, it covers exceptions, slicing, and the impact of mutable vs immutable default arguments in function definitions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views11 pages

Important Points To Ponder

The document outlines key differences between primary and unique keys in databases, explaining their roles in identifying tuples and handling duplicates and nulls. It also describes the behavior of natural joins in SQL, the evaluation order of print statements in Python, and the use of various methods and functions across lists, dictionaries, and file handling. Additionally, it covers exceptions, slicing, and the impact of mutable vs immutable default arguments in function definitions.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

NEWLY ADDED POINTS:

IF DIFFERENCE BETWEEN UNIQUE AND PRIMARY KEY IS ASKED :


The only points you can mention:
1. PK is used to uniquely IDENTIFY a tuple ; UNIQUE is to restrict duplicate values in a column
2. PK does not allow duplicates and NULL; UNIQUE will allow NULLS ( any number of NULLS are
allowed in a column with UNIQUE constraint)
3. PK constraint is imposed on an attribute. UNIQUE can be imposed on several attributes
Given 2 tables, if output of a NATURAL JOIN is asked:
The common column ,wherever found in the tables will appear as the first column in the output and
the columns following it, depend on the order of the tables mentioned in the query, as shown in the
following example: Table : SALES

Code Salary ITCODE

1001 60000 12

1002 70000 15

1004 55000 17

Table : ITEM

ITCODE ITEMTYPE

12 STATIONARY

15 HOSIERY

17 BAKERY

SELECT * FROM SALES NATURAL JOIN ITEM;

ITCODE Code Salary ITEMTYPE

12 1001 60000 STATIONARY

15 1002 70000 HOSIERY

17 1004 55000 BAKERY


SELECT * FROM ITEM NATURAL JOIN SALES;

ITCODE ITEMTYPE Code Salary

12 STATIONARY 1001 60000

15 HOSIERY 1002 70000

17 BAKERY 1004 55000

If in a print( ) function, normal variables are included along with methods, the methods will be
evaluated first and then the output will be shown as the order in the print statement. For eg:
L= [34,25,56,78,12]
print( L, L.pop(), sorted(L))
[34, 25, 56, 78] 12 [25, 34, 56, 78]

NOTE: The pop() method would have removed the last element and when L is shown in the print
command, the changed list only will be displayed(though L is in the 1st position in the print
command)

When using fromkeys() to create a dictionary, the 1st argument will an iterable whose elements will
be used as keys of the new dictionary and the 2nd argument will the common value for all the keys.
But if the 2nd argument is a list and for one of the keys you change the list content, the changed list
will be reflected for all the keys:
D={}.fromkeys((100,200,300),[4,5])
print(D)
{100: [4, 5], 200: [4, 5], 300: [4, 5]}
D[200][1]=500
print(D)
{100: [4, 500], 200: [4, 500], 300: [4, 500]}
(Because all the values which is in the form of a list are obviously in a common memory location and
lists are mutable. It is like referencing a list: L1=[3,4] ; L2=L1 ; L2[0]=300; Both L1, L2 will be
[300,4]

In a list of values, if the insert method when used has a subscript that is not available in the list, then the
new element will only be appended:
Given l=[10,20]
l.insert(5,100) #note – subscript 5 does not exist
print(l) - will show
[10, 20, 100]
l.index(100)
2

In a text file, to write one statement to fetch data for whichever of the following condition is first met :
if ‘n’ bytes of characters are to be retrieved or till the ‘\n’ is encountered
the command will be: F.readline(n)
The del statement can be used with slice only with lists and not tuples
L=[4,6,3,10]
del L[1:3]
print(L)
[4, 10]

T=(4,6,3,10)
del T[1:3]
TypeError

Example for a single except block to deal with multiple exceptions :


try:
value = int(input("Enter a number: "))
result = 10 / value
except (ValueError, ZeroDivisionError) as e:
print(f"An error occurred: {e}")

If in a slice, the given range involves an ending subscript not available, the content from the beginning
subscript until the end of the content are retrieved.
(eg)
M = “EXAM”
print(M[3:20]) will show M

L= [4,6,3,9]
print(L[-1:10]) will show [9], because [-1:10] will be treated as L[3:10]

If F is the file object, to position the file pointer at the 50th byte from the beginning : F.seek(50)
To position the file pointer to read the (or from the) 50th character from the beginning : F.seek(49)

The network protocol that translates domain names into IP addresses to make the internet more user-friendly.- ,
DNS (Domain Name System) . (eg) DNS translates domain names like "mysite.com" into IP addresses like
"142.250.184.147

Difference between DROP TABLE, DELETE, TRUNCATE:


DROP TABLE - is a DDL command which will delete all the records in the table and finally delete the table
structure also. So the table will no longer be available in the memory
DROP TABLE TNAME
DELETE - is a DML command; deletes only the records; table structure will remain;
DELETE FROM TNAME; - will delete all the records and the empty table will remain in memory
DELETE FROM TNAME WHERE …… - will delete those records which satisfy the given condition
after the WHERE clause
TRUNCATE- is a DDL command; but will remove only the records; the table structure will remain; no
conditions can be given- so all the records will be deleted
TRUNCATE TABLE TNAME;
Assume table BANK exists with data as shown:
mysql> SELECT * FROM BANK;

ACODE NAME TYPE

1 AAA SAVING

2 BBB CURRENT

3 CCC CURRENT

4 DDD NULL

SELECT DISTINCT TYPE FROM BANK ; ----------- > will show:

TYPE

SAVING

CURRENT

NULL

But, SELECT COUNT(DISTINCT TYPE) FROM BANK;--------- > will show:

COUNT(DISTINCT TYPE)

2
(Because only count(*) will include NULLs; count(argument), where argument can be any attribute or
DISTINCT clause, will ignore NULLs

Even though floor division // operator is supposed to get the nearest lowest integer, if any one of the
operand(numerator or denominator) is a float the final answer must be a float
print(-3.56//9)= -1.0
print(1.125//-5)=-1.0
print(1.125//5)=0.0

Keyword arguments of connect must be in lower case(host, user, password, database). If the
Password is given as a number(like 123) that also should be in quotes.

If a slice is used on the LHS and an iterable on the RHS, the elements satisfying the slice will be
replaced by the elements of the iteable
L=[8,4,2]
L[:2]='poll'
L will now have [p,o,L,L,2]

If the formal parameter of a function header is given a default argument and is immutable every time the
function is called with a missing actual argument, the formal parameter will take the same default value.
Like:
def fn(a=10):
a=a+5
print(a)
for k in range(3):
fn()

Will give an output:


15
15
15

But If the formal parameter of a function header is given a default argument and is mutable every time
the function is called with a missing actual argument, the formal parameter will take the changed value of
the formal paramter. Like:
(eg-1)
def fn(a=[]):
a.append(5)
print(a)
for k in range(3):
fn()

Will give an output:


[5]
[5, 5]
[5, 5, 5]

(eg-2)
def fn(y,a={}):
a.setdefault(y,10)
print(a)
for k in range(1,4):
fn(k)

Will give an output:


{1: 10}
{1: 10, 2: 10}
{1: 10, 2: 10, 3: 10}

THIS PART ONWARDS WAS ALREADY SHARED :

#To delete all repeating elements in a list


l=[11,10,12,11,15,12,17,11,18,15,12,19]
print(l)
k=0
while True:
flag=0
j=k+1
while j<len(l):
if l[k] == l[j]:
for m in range(j,len(l)-1):
l[m]=l[m+1]
l[-1:]=[]
flag=1
j+=1
k+=1
if k==len(l):break
print(l)
Difference between AGGREGATE FUNCTIONS and SCALAR FUNCTIONS:
Aggregate functions work on the column specified in all the rows and returns a single value. (Eg)
SUM(), AVG(), MAX(), MIN(), COUNT()
Scalar functions works on the column specified and re turns output for each row(Eg) UCASE(),
LCASE(), MID(), LEN(), ROUND()

A LIST CAN BE CONCATENATED WITH ANYTHING THAT IS ITERABLE. If L=[6,8,12]


(Eg) L += [10,20]; print(L) will show [6, 8, 12, 10, 20]
L+= (9,2); print(L) will show [6, 8, 12, 10, 20, 9, 2]
L += “hai”; print(L) will show [6, 8, 12, 10, 20, 9, 2, 'h', 'a', 'i']

L+=range(1,10,4); print(L) will show [6, 8, 12, 10, 20, 9, 2, 'h', 'a', 'i', 1, 5, 9]

To have a string content across multiple lines using – triple quotes, using continuation character \
and using the escape sequence character \n – the effect of using len()
t="""hello
world"""
print(len(t)) --- 11
t="hello\nworld"
print(len(t)) --- 11
t="hello\
world"
print(len(t)) --- 10

Make a note of the datatype of the return value of methods (whether int/ str/ bool/ list/ tuple/
dictionary/ None etc)
Also make a note of methods which do not return a value ( so when used in a print() function or
assigned to a LHS variable it will be None) which means they work on & affect the original variable
1) String – all methods return a value
2) List- append(), extend(), sort(), reverse(), remove(), insert() - returns None [
index(), count(), pop() – will return a value]
3) Tuple- The 2 methods of tuple- index(), count() – will return some value(int)
4) Dictionary- clear(), update()
[get(), items(), keys(), values(), pop(), popitem(), setdefault(),fromkeys() – will return value]

The Augmented Assignment operator or the Arithmetic assignment operator( shorthands +=, -=, *=,
/=, %=, **= etc) has the least priority when evaluated in a mixed mode expression
(Eg A=53; B=24; C=5; C += A//B * (15 > 7 and 99) ; print(C) will result in 203 Short
hand happens after the RHS is evaluated.

The same expression without the () like :


A=53; B=24; C=5; C += A//B * 15 > 7 and 99 ; print(C) will result in 104
print(sorted([[3,1],[4,0],[2],[5,9]])) will result in
[[2], [3, 1], [4, 0], [5, 9]]

print(sorted([10,4,[3,5],9])) will result in


TypeError ( comparison between int and ;list)

In a list when a slice is used in the LHS and is assigned to something on the RHS, from the starting
index of the slice, the RHS values are inserted in the list, replacing the result of the slice (that is the
elements in the result of the slice will be deleted). For eg
Odd=[1,9,15,22,35,67]
Odd.insert(1,3) # list will now be: [1,3,9,15,22,35,67]
Odd[2:4]=[5,8] #will result in [1,3,5,8,22,35,67] – starting from subscript 2,
5&8 will be inserted, replacing the result of [2:4] (which is
index 2,3)
Odd[3:3]=[100,120] #will result in [1,3,5,100,120, 8, 22,35,67] – starting from
subscript 3, 100&120 will be inserted, replacing the result of
[3:3] (which will be empty – so no elements are replaced)

Similarly, if a subscript is used to assign a empty list [], the element in that subscript is replaced by
the [] but is a slice is used, all elements resulting from the slice will be deleted.
Odd[3]= [] #will result in [1,3,5,[ ],120, 8, 22,35,67]
Odd[-3:] = [ ] #will result in [1,3,5,[ ],120, 8 ]

Append method takes one parameter and adds it to the end of the list. If the parameter is a list itself
it is added to the existing list as a list. For eg
L= [ ]
L.append(100)
print(L) #will show [100]
L=[ ]
L.append([10,4, [5,3,1], 15 ])
print(len(L)) #will show 1
print(L[0][2][0]) # will show 5

The arithmetic operator // refers to floor division which generally truncates the floating point result
to give an integer like
53//24 will be 2 whereas 53/24 will be 2.2083333333333335
But if the numerator or denominator (or both) is a float, result of the floor division operator will be
a float, like
53.0//24 will be 2.0
And if the numerator or denominator is negative, result will be the floor(nearest SMALLEST value)
like:
-53//24 will be -3
53//-24 will be -3
-53//-24 will be 2

In a list along with numerals if Boolean values are given and if a sort() method is performed the
numerical representation of the Boolean values (False -0 , True-1) will be considered to perform the
operation but will store the data as Boolean value only, like:
B=[4, -2, 8, 6, 5, True, False]; B.sort();print(B) will result in
[-2, False, True, 4, 5, 6, 8]

print(max(False, -3, -4 ) ) will result in


False

If a module is not imported but its function is used, it will throw NameError
(eg) print(math.ceil(9.5)) without import math statement included

The order in which statements are interpreted/executed is of utmost importance. Consider this UDF:
(line numbers have been included to understand the order of interpretation)
1. a=100
2. def fn(p=a):
a. print(p+10)
3. a=120
4. fn()
5. print(a)

This will result in an output:


110
120
Execution starts from line1 and goes downwards. So with ‘a’ is assigned with 100, line 2 the function
header assigns this value of ‘a’ to the formal parameter which is stored in the stack memory. When
the interpreter realizes this to be function header, it skips the function body and moves onto line3.
When line4, the function call is executed, the control goes to the body, line 2.a and prints 100+10.
After the function body is executed, control goes to line 5 and prints the changed value of ‘a’

(changed in line3)

For questions on writing UDFs involving lists/stacks, include a line(either as part of the code itself or
a comment) showing the stack to be globally declared in the main (unless the stack is one of the

parameter in the function header)

If UDFs asked for file creation is asked, check if the question mentions about appending a record or
records, as in the latter case ‘n’ has to be read from the user indicating how many records and a loop
to be used to read & write ‘n’ records

In output questions on files, if the opening mode is r / r+ / w/ w+ / rb/ rb+ / wb/ wb+, immediately
on opening, the file size ( found using tell()) will be zero.
Only if the opening mode is a/a+/ab/ab+ on opening itself the file pointer is taken to the end of the
file and tell() will give the file size.

In text file codes, (generally all code/output questions) if an output format is given with the sample
input, your code should have statements to obtain that given output format (eg: No. of times M

occurs:, The new string is:)


If the UDF is mentioned to have the file name passed as parameter, the open statement should have
that variable directly written and not in quotes. For eg:
def REVERSE(x): # x is the existing text file to be manipulated
with open(x) as F : # note- x is not enclosed in quotes as it’s a variable
SQL
● For exact match use =
● For pattern match , use like and double quotes only for the pattern
● For outputs involving dates, use the date format as per the format given in the table in the
question
● Check if select distinct or count distinct is asked
● Check if order by or group by is asked
● The ‘group by’ field should also be in the select list (when a sql command is asked to be
written with group by)
● If Keyword for Order by clause is omitted , it is by default asc.
● To change the content of the table its update & not alter.
● None of the DML commands(SELECT, INSERT, UPDATE, DELETE) will have the keyword ‘table’
● If multiple columns are to updated use comma and not AND. Multiple conditions in the
WHERE clause only will have logical AND/OR
● Do not use python shorthands in expressions
● If a new record is asked to be inserted with some data given, count the number of fields in the
given table and count the number of data given- if it’s the same number use the syntax:
INSERT INTO TNAME VALUES(data) . If its fewer use the syntax: INSERT INTO TNAME(field
names) VALUES (data)
● For joins, both the table names to be mentioned, if common field has same name use qualifier
name.
● In outputs, if table.* is mentioned, it refers to all the fields of that table
● In sql outputs if an expression is given followed by a name, that name is to be shown as
heading for that column. For eg:
SELECT NAME, SAL, SAL*0.05 “BONUS” FROM EMPLOYEE;
(The column having the calculated values for 5% of SAL should have the heading BONUS)

Networks
● For 1 mark, write atleast 2 ad/disad
● Expand abbreviations before explaining
● For drawing layouts go for least total cable length; draw neat block diagrams using scale
& pencil
● For star topology : make sure the node chosen as central node(in your layout diagram)
has the server.
● Server in the building with max. no. of computers
● Modem is where server is placed
● Hub/switch in all buildings
● Repeaters between buildings with distance more than 100m
● For hilly terrain- no microwave/optical fiber. Onlyunguided media – satellite or radio
waves
● For internet connection – TCP/IP, leased line, modem, DSL, dialup, broadband
● Efficient way of connecting computers within a building – switch. Other wise Hub /
switch can be the answer
● Efficient topology for LAN- STAR. (So based on less cable length – BUS and based on
efficiency STAR can be quoted)
● URL eg : http://www.google.com
Domain name: google.com

Answers as in Board Answer Key :


1) Characteristics of Web 2.0 :
Makes the web more interactive through online social media. Support easy online
information exchange. Interoperability on the internet. Video sharing possible in
websites.

2) Write the key features differentiating Web 1.0, Web 2.0 and Web 3.0:
Web1.0 – Static HTML pages. 2.0-Added features(blogs, wikis, social networking sites) to
make the web more interactive/interoperable/online-information exchange. 3.0 – new
technologies like AI, ML, Blockchain, 2D/3D immersive user experience, greater surety &
privacy

3) Advantages of 3G over 2G :
Faster web browsing
Faster file transfer
Better video clarity
Better security

4) PAN – Personal area network ; network organized around a person using his
mobiles, laptops etc. LAN – Local area network; network organized around computers
within a building / campus covering an area upto 1 Km.

5) Hardware device to be procured by the company to be installed to protect and


control the internet users within the campus : Firewall / Router

6) Fastest media out of Optical fibre, Coaxial cable, Ethernet cable, Microwave,
Infrared. : Guided – Optical fibre; Unguided – Microwave / Infra red

7) Compare Packet & Message switching :


Similarity : Both follow store and forward.
Difference : Limitation on packet size; stored in main memory / disk

8) What kind of information is stored in cookie and how is it useful?


When a website with cookie capabilities is visited, its server sends certain information
about the browser, which is stored in the hard disk as a text file. It’s a way of server
remembering things about the user’s visited sites.

9) Difference between Email, Chat :


Email facilitates users to send and receive messages electronically in a store and forward
manner; the user and receiver needn’t be online.
Chat is an application to communicate with a person or group on the internet in real
time; so sender and receiver are online.

10) Two characteristics of wifi:


Allows wireless communication
Portable
Ideal for mass coverage and hilly terrains

11) HTTP – Hypertext transfer protocol – to view / access hypertext on web


pages . FTP – file transfer protocol – to transfer files from one computer to another
over the internet.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy