{Solved} O Level Practical Question Paper January 2023
February 08, 2023 by Primegyan 16.35k
In this article we are going to share Practical Questions with solution for O Level Exam and this is orginal o level practical question paper 2023. so let's discuss...
Q1. Write a python program to sort python dictionaries by key or value.
Solution:
mydict = {'raj': 25, 'rajnish': 9, 'sanjeev': 15, 'kavita': 2, 'suraj': 32}
# Sort by key
xk=dict(sorted(mydict.items()))
print("Sorted by key: ",xk)
# Sort by value
xv=dict(sorted(mydict.items(), key=lambda item: item[1]))
print("Sorted by Value: ",xv)
#OUTPUT
Sorted by key: {'kavita': 2, 'raj': 25, 'rajnish': 9, 'sanjeev': 15, 'suraj': 32}
Sorted by Value: {'kavita': 2, 'rajnish': 9, 'sanjeev': 15, 'raj': 25, 'suraj': 32}
Q2. Write a python program to find the power of a number using recursion.
def recur(num,pow):
if pow == 0:
return 1
res=(num*recur(num, pow-1))
return res
num=int(input("Enter Number "))
pow=int(input("Enter Power "))
print("Answer: ",recur(num,pow))
#OUTPUT
Enter Number 2
Enter Power 8
Answer: 256
Q3. Write a python program to multiply two number by repeated addition.
Example: 6*3=6+6+6
#METHOD 1
def multiply(a,b):
sum=0
for i in range(b):
sum=sum+a
print("The multiply is: ",sum)
num1=int(input("Enter first number "))
num2= int(input("Enter second number "))
multiply(num1,num2)
#OUTPUT
Enter first number 6
Enter second number 3
The multiply is: 18
#METHOD 2
num1=int(input("Enter first number "))
num2=int(input("Enter second number "))
product=0
for i in range (1,num2+1):
product=product+num1
print("The multiply is: ",product)
#OUTPUT
Enter first number 6
Enter second number 3
The multiply is: 18
Also Read: O Level Practical old question paper with solution
Video Solution:
- Write a python program to sort python dictionaries by key or value.
- Write a python program to find the power of a number using recursion.
- Write a python program to multiply two number by repeated addition.
Example: 6*3=6+6+6