Computer Chap # 3 Notes NBF Class 11th-1
Computer Chap # 3 Notes NBF Class 11th-1
Q2. Write code to take input a number from user and print its mathematical table on
screen from 1 to 10,
Ans. Program:
x = eval (input (‘Enter a number to get its table: '))
for i in range (10):
print (x, 'x’, i+1, '=', x* (i+1))
03. Take an odd number as input from the user, check if it is odd, otherwise ask the user
to reenter an odd number,
Ans. while True:
x = eval (input ('Enter an Odd Number: '))
if (x % 2! = 0):
print ("You Entered an Odd Number")
break
else:
print ("Number is Even, Re Enter the Number")
04. Write down the main examples of Python based application.
Ans. Following are some examples of python-based applications:
i. Web Development
0.5 Differentiate between global and local variables with the help of suitable
Extended Response Questions (ERQs)
Q1. Explain the applications of Python in different business and technical domains.
Ans. Python is a versatile programming language widely used across various business and
technical domains due to its simplicity, readability, and extensive library support. Here are
some key applications:
i. Web Development
a. Frameworks: Django, Flask, Pyramid.
b. Use: Building robust websites, web applications.
c. Examples: Instagram, Pinterest, and Spotify use Django.
v. Desktop Applications
a. Libraries: Tkinter, PyQt, Kivy.
b. Use: Building cross-platform desktop applications with graphical user interfaces.
c. Examples: Text editors, file management tools, custom utilities.
Q2. What are basic functions that 'List' provides? Elaborate each of them with an example.
Ans. Len() Function
It provides with the total number of elements in a list
Min() Function
It is used to extract the smallest number from the elements in the list.
Max() Function
It is used to extract the largest number from the elements in the list.
Sum() Function
It sums up all the elements of the list.
Insert() Function
It inserts an element in the list.
Index() Function
It returns the position of the number in a list. In case of multiple occurrences of the
number, the placement of first match is returned.
Randint() Function
It is used to generate a random number in the given range.
03. Write a program for Dice Rolling Race Game for 2 Players.
Ans. Python Code
import random
target 100
p1, p2 = 0,0
if p1 >= target:
print ("P1 wins!")
break
p2 += random.randint(1, 6)
print (f " P2 : {𝑝2}")
if p2 >= target:
print("P2 wins!")
break
Q.4 How to locate and select Debugger in IDLE? Write steps by taking an example into
consideration.
Ans. Step1: Open "Python IDLE" from start menu,
Step2: Write your computer program using python language.
Step3: From the IDLE menu Bar, Click on Debug option, Select "Debugger" from the
drop-down menu.
Step4: A window titled as ‘‘Debug Control’’ will pop-up on screen.
Step5: Notice a ‘‘Debug On’’ message on the shell prompt.
Step6: Watch variables and their corresponding values.
‘