Showing posts with label XI-IP. Show all posts
Showing posts with label XI-IP. Show all posts

Friday, November 11, 2022

Python Practical List XI-IP

List of Practicals to be completed in Python for class XI IP

 

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

  
OLD FILES
 
 
 

 

Tuesday, October 13, 2020

Answer Key - CLASS XI - IP (UT-1 exam - 2020-21)

 

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)

Saturday, February 1, 2020

Dictionaries Manipulation Practice


Dictionaries Manipulation Practice

Question:
Write a program to print the worker’s informations (Name age, salary) in records format.
Answer:
Employees = {‘Rohan’ : {‘age’ : 20, ‘salary’ : 10000}, ‘Mohan’ : {‘age’ : 30, ‘salary’ : 15000}}
for key in Employees :
    print “Employee”, key + ‘:’
    print ‘Age :’ + str (Employees [key] [‘age’]
    print ‘Salary :’ + str (Employees [key] [‘salary’])

Question:
What is a key-value pair with reference to Python dictionary ?
Answer:
A dictionary is a mapping between a set of indices (which are called keys) and a set of values. Each key maps a value. The association of a key and a value is called a key-value pair.

Question:
What are the characteristics of Python Dictionaries ?
Answer:
The 3 main characteristics of a dictionary are :
1.    Dictionaries are Unordered : The dictionary elements (key-value pairs) are not in ordered form.
2.    Dictionary Keys are Case Sensitive : The same key name but with different case are treated as different keys in Python dictionaries.
3.    No duplicate key is allowed : When duplicate keys encountered during assignment, the last assignment wins.
4.    Keys must be immutable : We can use strings, numbers or tuples as dictionary keys but something like [‘key’] is not allowed.

Question:
Write a Python program to input ‘n’ names and phone numbers to store it in a dictionary and to input any name and to print the phone number of the particular name.
Answer:
phonebook = dict( )
n = int(input("Enter total number of friends"))
i = 1
while i<=n:
    a = input("Enter name")
    b = input("Enter phone number")
    phonebook[a] = b
    i = i + 1
print("Dictionary is:- ")
print(phonebook)

name = input("Enter name to search")

if name in phonebook.keys():
        print("Phone number =", phonebook[name])
else:
    print("Given name not exist")