Introduction to Problem Solving with Python

Introduction to Problem Solving with Python for CBSE Class 11, Computer Science (Python). Questions and Answer with solution from NCERT book. Conceptual and application based question and answer of Computer Science (CS), important for exam point of view.

Introduction to Problem Solving with Python : Questions with Solution

Q.1: Write pseudocode that reads two numbers and divide one by another and display the quotient.

x= int(input ("Enter the first number"))
y= int(input("Enter the second number"))
print("the quotient is ",z)

2. Two friends decide who gets the last slice of a cake by flipping a coin five times. The first person to win three flips wins the cake. An input of 1 means player 1 wins the cake . An input of 1 means player 1 winds a flip and a 2 means player 2 wins a flip . Design an algorithm to determine who takes the cake .

for i in range (1,5):
    n=int(input("The head(h) for 1 or tale(T) for 2"))
    y=int(input("for choosean of the players head 1, for choosen tail 2"))
    if y==1 and n==1:
    if y==2 and n==2:
    if y==1 and n==2:
    if y==2 and n==1:
if count1 >=3:
     print("player 1 wins")
if count2 >=3:
    print("player 2 wins")

Q.3. Write pseudocode to print all multiples of 5 between 10 and 25.

for i in range(10,25):
if i%5==0:
print (i)

Q.4.Give an example of a loop that is to be executed a certain number of times.

For loop
for i in range(10,25)

Q.5.Suppose you are collecting money for something.
You need 200 in all. You ask your parents, uncles and aunts as well as grandparents. Different people may give either 10, 20 or even 50. You will collect till the total becomes 200. Write the algorithm.

SET totalMoney := 0=
WHILE totalMoney < 200
INPUT money     
totalMoney := totalMoney + money

Q.6.Write the pseudocode to print the bill depending upon the price and quantity of an item. Also print Bill GST, which is the bill after adding 5% of tax in the total bill.

input price of item and quantity
total price=price * quantity
total price with tax = 105/100(total price)

Q.7. Write pseudocode that will perform the following:
a)Read the marks of three subjects: Computer Science, Mathematics and physics, out of 100

csemark= int(input(“enter computer science marks “))
mathmark= int(input(“enter maths n.o”))
physics= int(input(“entrer physics n.o))

b)calculate the aggregate marks


c)calculate the percentage of marks

(mark+mathmark+physics/300) *100

Q.8.Write an algorithm to find the greatest among two different numbers entered by the user.

x=int(input("enter the first n.o"))
y=int(input("enter the second n.o")
if x==y:

Q.9.Write an algorithm that performs the following:Ask a user to enter a number. If the number is between 5 and 15, write the word GREEN. If the number is between 15 and 25, write the word BLUE. if the number is between 25 and 35, write the word ORANGE. If it is any other number, write that ALL COLOURS ARE BEAUTIFUL.

Enter the n.o
condition if checks
return true
if checks
return true
if checks
return true
print(“All colors are beautiful”)

Q.10.Write an algorithm that accepts four numbers as input and find the largest and smallest of them.

Input 4 n.o
for loop for 4 iteration
if number is greater than the now number
now number becomes the greater number

print greatest n.o the same number which comes after the iteration.

Thanks for reading Introduction to Problem Solving.


Write an algorithm to display the total water bill charges of the month depending upon the number of units
consumed by the customer as per the following criteria:
• for the first 100 units @ 5 per unit
• for next 150 units @ 10 per unit
• more than 250 units @ 20 per unit
Also add meter charges of 75 per month to calculate the total water bill

Enter the units consumed:
if less than 100
if less than 250 but greater than 100
if greater than 250
total add 75 to bill

Q.12. What are conditionals ? when they are required in a program?

IF else are conditional . they are required to compute reasoning questions .

Q.14: Following is an algorithm for going to school or college. Can you suggest improvements in this to include other options?

a) Wake up
b) Get ready

c) Take lunch box
d) Take bus
e) Get off the bus
f) Reach school or college

Take motor cycle

Q.15.Write a pseudocode to calculate the factorial of a number.

Take input
for loop starts to tge range of input
fac=fac*number in loop

Q.16. Draw a flowchart to check whether a given number is an Armstrong number. An Armstrong number of three digits is an integer such that the sum of the cubes of its digits is equal to the number itself. For example, 371 is an Armstrong number since 33 + 73 + 1**3 = 371.

Enter the n.o
gets digits of the n.o by the use of % operator on dividend the number given and 10.
Then cube each number
check n.o is equal to the given number
if yes then print Angstrong n.o

Q.17. Following is an algorithm to classify numbers as “Single Digit”, “Double Digit” or “Big”. Classify_Numbers_Algo

INPUT Number
IF Number < 9 “Single Digit”
Else If Number < 99 “Double Digit”
Else “Big” Verify for (5, 9, 47, 99, 100 200) and correct the algorithm if required

Answer: At 9 as input it will show double digit and also at 99. The comparison operator has to be changed to =<.in if comparative statement.

Q.18.For some calculations, we want an algorithm that accepts only positive integers upto 100

INPUT Number
IF (0<= Number) AND (Number <= 100)

a) On what values will this algorithm fail?
b) Can you improve the algorithm?

a) It will fail on 0 and 100.

b) The comparision oprator = needs to be deleted from the algorithm then it will work correctly.

Thanks for reading Introduction to Problem Solving CBSE Class 11, Computer Science (Python) NCERT Questions and Answer.

For more solved assignments- Click here

For practical file question – Click here

Leave a Comment

Your email address will not be published. Required fields are marked *