Assignment-01(Based on Random Numbers)
Questions from Board Examinations and sample papers
Assignment -1
Find the output and Minimum, maximum Values (lower limit
and upper limit)
Q.No.1
import random
NAV=["LEFT", "FRONT", "RIGHT", "BACK"]
NUM=random.randint(1,3)
Navg=""
for c in range (NUM,1,-1):
Navg=Navg+NAV[c]
print(Navg)
Options:
i. BACKRIGHT ii.
BACKRIGHTFRONT iii. BACK iv. LEFTFRONTRIGHT
Q.No.2
import random
values=[10,20,30,40,50,60,70,80]
Begin=random.randint(1,3)
Last=random.randint(Begin,4)
for i in range(Begin,Last+1):
print(values[i],"-")
i.
30-40-50-
ii. 10=20-30-40- iii.
30-40-50-60- iv. 30-40-50-60-70
Q.No.3
import random
temp=[10,20,30,40,50,60]
c=random.randint(0,4)
for i in range(0,c):
print(temp[i],"#",end='')
i.
10#20#
ii. 10#20#30#40#50 iii.
10#20#30 iv. 50#60#
Q.No.4
import random
x=random.random()
y=random.randint(0,4)
print(int(x)," ",y+int(x))
i.
0:0
ii. 1:6 iii. 2:4 iii. 0:3
Assignment -2
(20.04.20)
1.
Describe the following Built in functions with
the help of examples.
len() Method, max() function, min()
function, index(), count(),tuple(),ceil(),floor(),fabs() method
2.
write a python program to find the sum of the
sequence given below, take the input from the function.
1+1/1!+1/2!+1/3!+1/4!+ …………… +1/n!
1+1/1!+1/2!+1/3!+1/4!+ …………… +1/n!
3.
Explain Global and local Scope of variable with
the help of example
4.
Explain Mutability and immutability of
variables/ values, with the help of suitable program.
5.
Write a
function that receives any 4 values and return the largest among them
also write the main function to call the function and print the result
Assignment - 3
Date:-25.04.2020
Date:-6.11.20
Serial_no, 1st_Room, Hundred$, Total Marks, Total_marks, _Percentage, True
ASSIGNMENT 24(29.12.20)
Date:-25.04.2020
- create a module - conversion.py that store function for various length conversion
miletokm() - to convert miles to kilometer
kmtomile() - to convert kilometer to miles
feettoinches() - to covert feet to inches
inchestofeet() - to covert inches to feet - Create a package calculate, which contain 3 modules
i). to return the factorial of any number, number should be given by the user during run time
ii). to return the percentage of marks of 5 subjects, marks of 5 subjects will be given by user during run time.
iii). to print any random number between any two desired number - what is the output of the following price of code?
#mod1
def change(a):
b=[x*2 for x in a]
print(b)
#mod2
def change(a):
b=[x*x for x in a]
print(b)
from mod1 import change
from mod2 import change - What will be the output
import math
import random
print(math.ceil(random.random()))
Justify your answer
Assignment - 4
Date:-29.04.20
1. Write a program to find the sum of a series 1+x/1!+x^2/2!+x^3/3!+…………....…………+x^n/n!
2. Write a program to find the sum of a series 1+x/2!+x^2/3!+x^3/4!+…..………………+x^n/(n+1)!
2. Write a program to find the sum of a series 1+x/2!+x^2/3!+x^3/4!+…..………………+x^n/(n+1)!
3. find and write the output of the following python code
msg1="WeLcOME"
msg2="GueSTs"
msg3=" "
for i in range (0,len(msg2)+1):
if msg1[i]>="A" and msg1[i]<="M":
msg3=msg3+msg1[i]
elif msg1[i]>="N" and msg1[i]<="Z":
msg3=msg3+msg2[i]
else:
msg3=msg3+"*"
print(msg3)
4. find and write the output of the following python code:
txt=["20","50","30","40"]
cnt=3
total=0
for c in[7,5,4,6]:
t=txt[cnt]
total=float(t)+c
print(total)
cnt-=1
5. Name the python library module for the functions - floor() and randint()
Solutions Q.1
import math
def fact(n):
fact=1;
for i in range(1,n+1):
fact=fact*i;
return fact
n=int(input("enter no of terms"))
x=int(input("enter the value of x"))
i=1
sum=1
while i<n:
f=fact(i)
sum=sum+math.pow(x,i)/f
i=i+1
print("the sum of the series",sum)
Solution Q.2
import math
def fact(n):
fact=1;
for i in range(1,n+2):
fact=fact*i;
return fact
n=int(input("enter no of terms"))
x=int(input("enter the value of x"))
i=1
sum=1
while i<n:
f=fact(i)
sum=sum+math.pow(x,i)/f
i=i+1
print("the sum of the series",sum)
Assignment - 5
Date:4.05.2020
Solutions Q.1
import math
def fact(n):
fact=1;
for i in range(1,n+1):
fact=fact*i;
return fact
n=int(input("enter no of terms"))
x=int(input("enter the value of x"))
i=1
sum=1
while i<n:
f=fact(i)
sum=sum+math.pow(x,i)/f
i=i+1
print("the sum of the series",sum)
Solution Q.2
import math
def fact(n):
fact=1;
for i in range(1,n+2):
fact=fact*i;
return fact
n=int(input("enter no of terms"))
x=int(input("enter the value of x"))
i=1
sum=1
while i<n:
f=fact(i)
sum=sum+math.pow(x,i)/f
i=i+1
print("the sum of the series",sum)
Assignment - 5
Date:4.05.2020
- Write a program to input n numbers of line s into the file test.txt, at the end of every file give end of line character(\n) .
- Write a program to read above created file, line by line and count how many lines are there and print the same .
- write a program to read the file test.txt and write the same into the file test1.txt, after converting each character into uppercase.
- How are following codes different from each other? explain
(a) myfile=open('song.txt',"r") (b) myfile=open('song.txt',"r")
myfile.read() myfile.read(100) - if the file song.txt contains the following song, than what output will be produced by above codes
Sare jahan se achha Hindostan hamara
Hum bulbule hain iske ye gulsitan hamara, hamara
Sare jahan se achha Hindostan hamara
Assignment 6
Date:-13.05.20
- write a program that reads a text file and create another file that is identical except that every sequence of consecutive blank spaces is replaced by a single space
- A file sport.dat contain information in the following format : Event ~ Participants
write a function that would read content from the file sports.dat and create a file named athelete.dat copying only those records from sports.dat where the event name is Athletics - write a program to count words this and that present in text file songs12.txt
- write a program to count no. of upper case alphabet in the text file alpha.txt
- write a program that copies a text file "songs.txt" onto "songs12.txt" baring the lines starting with a @ sign
Assignment 7
Date:29.06.2020
- Write a program to count the word "to" and "the" present in the text file "classxii.txt"
- A file contains a list of telephone numbers in the following form
Name Phone No.
Raman 9696969696
Rahul 9898989898
the name contains only one word , the name and Phone No. are separated by white space , write program to read file and display its content in two column - Write a Method in a python to write multiple line text contents into a text file myfile.txt
- Write a method in python to read the content from a text file diary.txt line by line and display the same on screen
- Write a function in python to count and display the number of lines starting with alphabet A, present in a text file "content.txt"
Assignment 8
Date:13.07.2020
1. Write a function upp(s) to convert the string into upper case using if it is in lowercase and in
lowercase if it is in upper case
lowercase if it is in upper case
2. Write a function upps1(s) to count upper case characters and print the same .
3. Write function to read a line of text from file first.txt and copy the same after converting all capital letters to small letter.
4. Write a program that read a text file and create another file that is identical except that every sequence of consecutive blank space is replaced by a single space
Assignment 9
Date:26.07.2020
1. what do you mean by Stack and Queue
2. Write a function to insert and element into the stack
3. Write a function to remove an element from the stack
4. Write a complete menue driven program to insert, delete and display the elements of Stack
Assignment 10
Date:5.08.2020
1. What do you mean by Network
2. What are the advantages of Network
3. What are the different types of Network
4. What do you mean by social Network
5. What do you mean by Internet and Intranet
Assignment 11
Date:1.09.2020
1. What do you mean by communication channel
2. Define Following terms :- Modem, Hub, Switch, Repeater, Router , Bridge, Gateway,
FTP, Telnet, Remote login, IOT,
FTP, Telnet, Remote login, IOT,
3. Define Optical fiber cable , coaxial cable, twisted pair cable
4. Define Cloud Computing with its type
5. Define Microwave Radio Wave, Satellite Communication,
Assignment 11
Date:27.9.2020
1. What do you mean by I/P address and MAC address ?
2. What do you mean by OSS?
3. What is the difference between Free Software and Freeware ?
4. What is the difference between Free Software and Shareware ?
5. What is the difference between OSS and proprietary Software ?
Assignment 12
Date:3.10.2020
1. What are the gender issues while teaching computer science ? explain in your own words ?
2. What do you mean by Identity theft ? what may be the possible solution for the same?
3. What are the disability issues while teaching and using computers ?
4. What do you mean by e - waste disposal process?
5. What are the benefits of e-Waste recycling ?
Assignment 14
(Autumn Break Home work)
Date:20.10.20
1. Explain the following Functions in MySql.
Substr(), instr(),mod(),random(),truncate(),all date functions , all aggregate functions
Substr(), instr(),mod(),random(),truncate(),all date functions , all aggregate functions
2. Differentiate between update and Modify Clause, Drop table and delete command , DDL
and DML
and DML
3. Define Database, Tuple, Attribute, Domain, Primary Key, Alternate Key, Foreign Key,
Cardinality, Degree of relation.
Cardinality, Degree of relation.
4. Explain with suitable example - BETWEEN AND, ORDER BY, GROUP BY, GROUP BY
HAVING, LIKE, DISTINCT.
HAVING, LIKE, DISTINCT.
5. Create a table emp with following description (empid - as primary key, name - should not be
blank , phone_no should not be the same for two employee , Category- Gen by default )
blank , phone_no should not be the same for two employee , Category- Gen by default )
6. MySql Practice Questions-01
Assignment 15
Date:-6.11.20
SQL- Revision
MySql Practice questions-02
Assignment 16(21.12.20)
1. Write a program that returns true if the number is even , false otherwise
2. Write a function to calculate volume of a box with appropriate default values for its parameters. your function should have the following input parameters- length of box width of box height of box.
3. Central computer which is powerful than other computers in the network is called as
a. Client b. Server c.Hub d. Switch
a. Client b. Server c.Hub d. Switch
4. What is the size of MAC address
a. 16 b. 32 c. 48 d. 64
a. 16 b. 32 c. 48 d. 64
5. Which of the economics group function ignore null value
a. Max() b. Count() c. Sum() d. All of the above
Assignment 17(22.12.20)
- write a program to have the following functions
a.) A function that takes number as argument and calculate cube for it . the function does not return a value . if there is no value passed to the function, in the function call , the function should calculate cube of 2.
b.) A function that takes two argument and return true if both the argument are equal, otherwise false - Define the following - NFS,GNU,Router,URL
- Explain Group by and order by in MYSql with suitable examples.
- Predict the output-
arr=[1,2,3,4,5,6]
for i in range (1,6):
arr[i-1]=arr[i]
for i in range(0,6):
print(arr[i],end=" ")
Assignment 18(23.12.20)
- Choose valid identifiers/variables from
a.) true b.)True c.) 1a1 d.)a11 e.)_a11 f.)first name g.) first_name h.) _firstname - Explain type casting . what are different types of type casting explain each with suitable examples
- Explain following terms - Circuit Switching and packet switching with examples.
- Explain Cartesian product with suitable example.
- what will be the data type of -
a.) s=____=17 b.) t=___________+'pie' c.) d=int(a/b)+c - what would be the output of
print(type([1,2])), print(type(a,2)), print(type[1/2])
ASSIGNMENT 19(24.12.20)
- find the output
def change(p,q=30):
p=p+q
q=p-q
print(p,"#",Q)
return (p)
r=150
s=100
r=change(r,s)
print(r,"#",s)
s=change(s)
2. What are different types of arguments/parameters that a function can hav?
3. Write a function that reads a line of text and calculate how many small case characters are
present in the file.
present in the file.
4. What is relation ? Define relational data model.
5. Define following -
Coaxial Cable, Ethernet Cable, Optical Fibre Cable.
Coaxial Cable, Ethernet Cable, Optical Fibre Cable.
ASSIGNMENT 20(25.12.20)
1. list=[10,20,30,40,'a','b','c']
find the output of following by using above list
print(list[]) ,print(list[:]), print(list[::]), print(list[1]), print(list[1:]),
print(list[:1]), print(list[1:5]), print(list[1:7:2])
find the output of following by using above list
print(list[]) ,print(list[:]), print(list[::]), print(list[1]), print(list[1:]),
print(list[:1]), print(list[1:5]), print(list[1:7:2])
2. Write a program to read a file "line.txt" and print first and last line from the file.
3. What do you mean by guided and unguided media of communication, Explain their types also.
4. What are different Constraints you are using during crating table,
explain each with suitable example
ASSIGNMENT 21(26.12.20)
1. find output
(a)
s1='b'
i=0
j=0
k=1
for i in range(0,4):
s2=s1
for j in range(0,k+1):
s2=chr(ord(s2)+1)
s1=chr(ord(s1)+2)
k=k+2
print(s2)
(b)
a=3
n1=336
n2=27
while True:
a=a*3
if a>n1:
a=a-5
break
while True:
a=a/3
a=int(a)
if a<n2:
a=a-5
break
print(a)
(c)
n=1491
e=54
u=6
rdx=0
bly=0
ifz=0
ifw=0
while u<n:
u=u*4
if not u%3:
u=u+20
ifz=ifz+1
rdx=rdx+1
print(u)
while u>e:
u=u/5
if not u%3:
u=u-5
ifw=ifw+1
bly=bly+1
print(u)
print(rdx+bly+ifz+ifw)
ASSIGNMENT 22(27.12.20)
1. Which of the following identifier names are invalid and why .Serial_no, 1st_Room, Hundred$, Total Marks, Total_marks, _Percentage, True
2. Write a function to Push and pop the element from the Stack
3. Rewrite the following code using while loop -
for i in range(1,100):
if i<50:
Sum=Sum+1
else:
Sum=Sum+2
for i in range(1,100):
if i<50:
Sum=Sum+1
else:
Sum=Sum+2
print(Sum)
4. What do you mean by ethical hacking
5. Explain "update" command and truncate function in MySql with suitable example
ASSIGNMENT 23(28.12.20)
1. What are the different rules to declare variable.
2. Write a program to find the sum of 1+(1+2)+(1+2+3)+(1+2+3+4)
3. Explain BETWEEN AND and Like Command in MySql with suitable example.
4. What are Gender issues while teaching computer science
1. Write a Function Remove_lowercase() that accept two filenames, and copies all the lines that do
not start with a lowercase letter from the first file into the second.
not start with a lowercase letter from the first file into the second.
2. Find the error and write the correct code.-
if v<5:
if v<5:
for i in range(v):
print "ABC"
else:
print "XYZ"
3. x=True y=False
Z=false
if x,y,z:
print "yes"
else:
print "No"
4. What is indexing in context of Python String, Why it is also called Two-way indexing
5. All aggregate functions ignore NULL except for _____________ function
a) Distinct b) Count (*) c)Average d) None of above
a) Distinct b) Count (*) c)Average d) None of above
ASSIGNMENT 25(30.12.20)
1. find out the error, correct it and than find its output
def fun(*a):
sum=0;
for i in a:
sum=sum+i
return sum
print(fun((10,20,30,40))
2. What are different types of arguments explain each with suitable examples.
3. W.A. function to check whether given number is prime or not.
4. Explain the following terms - WLL, Telnet,FLOSS,FSF
5. Create a table with following - (RollNo as primary key, Name of Student, Date of birth should not
be blank , phone number , Grade with default value 'E'
be blank , phone number , Grade with default value 'E'
ASSIGNMENT 25(3.1.21)
1. Each node of STACK contains the following informatin
pin code of a city and name of city
Write a program to implement the following operations in the above stack
a. PUSH() - to push a node in to the stack
b. POP() - to remove the node from the stack
pin code of a city and name of city
Write a program to implement the following operations in the above stack
a. PUSH() - to push a node in to the stack
b. POP() - to remove the node from the stack
ASSIGNMENT 26(4.1.21)
1. Explain the following terms
a. Microwave Communication , b. Infrared Communication, c. Radio waves
communication, d. Satellite Communication , e. Trojan, f. Worm, g.Malware,
a. Microwave Communication , b. Infrared Communication, c. Radio waves
communication, d. Satellite Communication , e. Trojan, f. Worm, g.Malware,
b. Expand the following -
LAN,WAN,MAN,PAN,FTP,HTTP,HTTPS,SMTP,POP,JSP,TCP/IP,
LAN,WAN,MAN,PAN,FTP,HTTP,HTTPS,SMTP,POP,JSP,TCP/IP,
2. Explain with suitable example- del() and pop functions in python dictionary
ASSIGNMENT 27(5.1.21)
1. Write Addnew(book) and Remove(book) function in python to add a new book and remove a
book from a list of books , considering to act them as push and pop operations of data
structure stack.
book from a list of books , considering to act them as push and pop operations of data
structure stack.
2. Write a function in python PUSH(Arr) , where Arr is the list of numbers. from this list push all numbers divisible by 5 into a stack implemented using by a list . display the stack if it has at least one element, otherwise display appropriate error message .
ASSIGNMENT 28(10.1.21)
a. Trace the flow of execution for following programs (i.e. sequence of execution of statements) and
also find the output -
also find the output -
- def power1(b,p):
- r=b**p
- return rounf(r,2)
- def power2(a):
- a=a+2
- a=power1(a,0.5)
- return a;
- n=5
- result=power2(n)
- print(result)
b.
- def increment(x):
- x=x+1
- #main program
- x=3
- print(x)
- increment(x)
- print(x)
c. Write a function in python to count the number of lines in a text file with an alphabet 'A'
d. Name nay two web browser.
f. Differentiate between Ring topology and star topology
g. What is natural join ? Explain with suitable example
ASSIGNMENT 29(11.1.21)
1. what data type is the object below -
(a) l=[1,23,'Hello',1] (b) L= 1,23,'Hello',1 (c)
(a) l=[1,23,'Hello',1] (b) L= 1,23,'Hello',1 (c)
2. to store in term of key and value what core data type does python provide.
3. suppose s1 = 'Kendriya Vidyalaya Sangathan' , what will be the output of following
(a) s1[::-5], (b) s1[::-1][::-5] (c) s1[::-1][-1]+s1[len(s)-1] (d) s1[-4:] (e) s1[:-4]
(a) s1[::-5], (b) s1[::-1][::-5] (c) s1[::-1][-1]+s1[len(s)-1] (d) s1[-4:] (e) s1[:-4]
4. What is the output of this code-
(a) print(int("3"+"4")) (b) print(3**3.0)
(a) print(int("3"+"4")) (b) print(3**3.0)
5. Write a program to find the x to power y, using for loop , user should input x and y during run time.
ASSIGNMENT 30(2.2.21)
1. Write a program to pickle and unpickle the data (using list) by importing pickle module
(Answer)-
l1=[10,20,30,40,50]
(Answer)-
l1=[10,20,30,40,50]
pickle_out=open("list1","wb")
pickle.dump(l1,pickle_out)
pickle_out.close()
rd=open("list1","rb")
l2=pickle.load(rd)
print(l2)
rd.close()
2. Write same program by taking any example of dictionary
2 Comments
This comment has been removed by the author.
ReplyDeleteFrom visesh Q.1 (4)
ReplyDeleteQ.2 (2) Q. 3 (3) Q. 4 (1)