Practical python paper(Term I) with source code.

Introduction

The practical python paper wasn’t easy for my students. It’s been quite challenging to learn coding in the school since they get access to computers only during class hours and sometimes on weekends. Learning to code need consistent practice. My students get to practice one to two hours a week which makes the coding journey hard for them. However, in the academic year 2022, we decided to go the hard way and I tried my best to teach python programming despite having lots of challenges from both sides (tutor & learners).

Till the mid-term break, we could cover topics till procedural programming taking 1 hour 40 minutes a week. The data structures and object-oriented programming are planned in term II.

The practical python paper consists of two significant questions carrying 20 marks each for class 12. They are supposed to complete in 2 hours. Jamyang Phuntsho of class XII Com B could solve both the questions in 1 hour and 40 minutes. However, other students also gave a good try and the pass percentage was around 96%. In this blog post, we are sharing a python practical paper for the term I along with his source code.

Jamyang Phuntsho XII Com B-2022

Well, Jamyang has been really passionate about learning programming. He comes from one of the remote schools in Trashigang where he didn’t have access to laptops or computers earlier. However, he learns to code whenever he gets access to the school IT lab.

Question 1 (Student Result Program)

Students can choose any method to code the “student result program”. The first method is using functions and the second method is without implementing functions. They were provided an option to choose any method to create a text-based student result program.

Question 1. 1

Write a python program to calculate the result of the students studying in Jampeling Central School. Save your file as “Student Result Program”. The program should have three functions defined: student_biodata(), student_mark(), student_remark(), and student_result(). The program should accept the name of the student, class, section, and marks for any five subjects from the user.

Calculate the percentage of the student and generate a remark according to the following conditions:

  • If a student’s percentage falls below 0 or above 100, generate an error message, ”Error: Check the mark entry!”
  • If a student’s percentage falls between 0 and 45, they are considered a failure.
  • If a student’s percentage falls between 45 and 100, they are considered a pass.

Display a result in such a way that the student’s name, class, section, percentages, and remark are generated.

Hint:

  • student_biodata() should accept the name, class, and section of the student.
  • student_mark() should accept all the marks of five subjects.
  • student_remark() should calculate the percentage and generate a remark accordingly.
  • student_result() should print the well-formatted result.
  • PERCENTAGE = (Total mark of all subjects / total number of subjects)

Source code:

def student_biodata(name, clas, section):
    return name, clas, section

def student_mark(eng, dzo, math, sci, ict):
    return eng, dzo, math, sci, ict

def student_remark():
    total = eng + dzo + math + sci + ict
    global percentage, remark
    percentage = total/5
    remark = ''
    if percentage > 100 or percentage < 0:
        remark = "Error: Check your mark entry!"
    elif percentage > 0 and percentage < 45:
        remark = "failed!"
    elif percentage >=45 and percentage <= 100:
        remark = "passed!"
    return percentage, remark

def student_result():
    print(f"----Result of {name}----")
    print(f"Class:{clas}")
    print(f"Section:{section}")
    print(f"percentage:{percentage}%")
    print(f"Remark:{remark}")
    
name = input("Enter name of student:")
clas = input("Enter class:")
section = input("Enter section:")
eng = float(input("Enter English mark:"))
dzo = float(input("Enter Dzongkha mark:"))
math = float(input("Enter Math mark:"))
sci = float(input("Enter Science mark:"))
ict = float(input("Enter ICT mark:"))
print()
student_biodata(name, clas, section)
student_mark(eng, dzo, math, sci, ict)
student_remark()
student_result()

Sample Output:

Sample output 1:
-------------------
Enter name of student: Dawa
Enter class:12
Enter section: A
Enter English mark:45
Enter Dzongkha mark:66
Enter Math mark:89
Enter Science mark:78
Enter ICT mark:90

----Result of Dawa----
Class:12
Section: A
percentage:73.6%
Remark: passed!

Sample output 2:
-------------------
Enter name of student: Sonam
Enter class:10
Enter section: A
Enter English mark:30
Enter Dzongkha mark:23
Enter Math mark:67
Enter Science mark:2
Enter ICT mark:61

----Result of Sonam----
Class:10
Section: A
percentage:36.6%
Remark: failed!

Sample output 3:
-------------------
Enter name of student: Tshering Tobgay
Enter class:9
Enter section: C
Enter English mark:56
Enter Dzongkha mark:78
Enter Math mark:105
Enter Science mark:900
Enter ICT mark:45

----Result of Tshering Tobgay----
Class:9
Section: C
percentage:236.8%
Remark: Error: Check your mark entry!
Question 1.2

Write a python program to calculate the result of the students studying in Jampeling Central School. Save your file as “Student Result Program”. The program should accept the name of the student, class, section, and marks for any five subjects from the user. Calculate the percentage of the student and generate a remark according to the following conditions:

  • If a student’s percentage falls below 0 or above 100, generate an error message, ”Error: Check the mark entry!”
  • If a student’s percentage falls between 0 and 45, they are considered a failure.
  • If a student’s percentage falls between 45 and 100, they are considered a pass.


Display a result in such a way that the student’s name, class, section, percentage, and remark are generated.

Source code:

Jamyang Phuntho’s source code:

name=input("Enter Your Name:")
clas=int(input("Enter Your Class:"))
sec=input("Enter Your Section:")
English=float(input("Enter Your English Mark:"))
Dzongkha=float(input("Enter Your Dzongkha Mark:"))
Commerce=float(input("Enter Your Commerce Mark:"))
Economics=float(input("Enter Your Economics Marks:"))
Accountancy=float(input("Enter Your Accountancy Mark:"))

print("\nPrinting Your Result")
print("-------------------")
print(f"Name:{name}")
print(f"classs:{clas}")
print(f"Section:{sec}")

print(f"\nMarks obtained:")
print("-------------------")
print(f"English:{English}")
print(f"Dzongkha:{Dzongkha}")
print(f"Commerce:{Commerce}")
print(f"Economics:{Economics}")
print(f"Accountancy:{Accountancy}")

total=English+Dzongkha+Commerce+Economics+Accountancy
percentage=total/5
print("-------------------")
print("Your Percentage is:", percentage,"%")

if 0<=percentage<=44:
    print(f" Sorry {name} you have Failed!")
    
elif 100>=percentage>=45:
    print(f" Congratulations {name} You have Passed!")
else:
    print("Error: Check the Mark Entry!")

Expected output:

Sample output 1:
--------------------------------------------------
Enter Your Name: Dawa 
Enter Your Class:12
Enter Your Section: D
Enter Your English Mark:56
Enter Your Dzongkha Mark:78
Enter Your Commerce Mark:89
Enter Your Economics Marks:56
Enter Your Accountancy Mark:45

Printing Your Result
-------------------
Name: Dawa 
classs:12
Section: D

Marks obtained:
-------------------
English:56.0
Dzongkha:78.0
Commerce:89.0
Economics:56.0
Accountancy:45.0
-------------------
Your Percentage is: 64.8 %
Congratulations Dawa  You have Passed!

Sample output 2:
----------------------------------------------------------
Enter Your Name: Sonam
Enter Your Class:3
Enter Your Section:45
Enter Your English Mark:40
Enter Your Dzongkha Mark:32
Enter Your Commerce Mark:33
Enter Your Economics Marks:23
Enter Your Accountancy Mark:20

Printing Your Result
-------------------
Name: Sonam
classs:3
Section:45

Marks obtained:
-------------------
English:40.0
Dzongkha:32.0
Commerce:33.0
Economics:23.0
Accountancy:20.0
-------------------
Your Percentage is: 29.6 %
Sorry Sonam you have Failed!

Sample output 3:
----------------------------------------------------------
Enter Your Name: Tshering
Enter Your Class:12
Enter Your Section: A
Enter Your English Mark:45
Enter Your Dzongkha Mark:789
Enter Your Commerce Mark:56
Enter Your Economics Marks:900
Enter Your Accountancy Mark:67

Printing Your Result
-------------------
Name: Tshering
classs:12
Section: A

Marks obtained:
-------------------
English:45.0
Dzongkha:789.0
Commerce:56.0
Economics:900.0
Accountancy:67.0
-------------------
Your Percentage is: 371.4 %
Error: Check the Mark Entry!
Question 2(Calculator Program)

Write a python program to design a simple calculator using functions. Save your file as “Calculator Program”. Your program should have four functions defined i.e. add(), multiply(), subtract(), and divide(). The operations/calculations should be done based on the user’s choice.

The program should be realistic by incorporating the following logic:

  • Make sure to catch ZeroDivisionError while doing division operations.
  • Run your program in a while loop so that you can do the mathematical operations simultaneously. Don’t forget to include the exit point to terminate the while loop when you are done doing calculations.

Source code:

Jamyang Phuntsho’s code:

def add():
     add=num1+num2
     print(f"{num1}+{num2}={add}\n")
     
def subtract():
    sub=num1-num2
    print(f"{num1}-{num2}={sub}\n")
    
def divide():
    try:
        div=num1/num2
        print(f"{num1}/{num2}={div}")

    except ZeroDivisionError as e:
         print(f"Exception Occured:{e}\n")
         
def multiply():
    mul=num1*num2
    print(f"{num1}x{num2}={mul}\n")
    
print("Welcome to Jamyang's Calculator")
print("---------------------------")
while True:
    start =str(input("Do you want to use our Calculator(Yes or No):")).lower()
    if start == 'yes':
        num1=float(input("Enter The First Digit:"))
        num2=float(input("Enter The Second Digit:"))
        opp=str(input("Choose The Opperation(+,-,/,*):"))
        if opp == '+':
            add()
            
        elif opp == '-':
            subtract()
            
        elif opp == '*':
            multiply()
                                    
        elif opp == '/':
            divide()

        else:
            print("Errors!!! Please choose this opperation(+,-,*,/) only")
            
    elif start == 'no':
        print("Thank You! For Using Our Calculator.")
        break
    else:
        print("ERROR! Please Enter 'Yes' or 'No'\n")

Expected output:

Welcome to Jamyang's Calculator
---------------------------
Do you want to use our Calculator(Yes or No):yes
Enter The First Digit:50
Enter The Second Digit:10
Choose The Opperation(+,-,/,*):/
50.0/10.0=5.0
Do you want to use our Calculator(Yes or No):yes
Enter The First Digit:9
Enter The Second Digit:0
Choose The Opperation(+,-,/,*):/
Exception Occured:float division by zero

Do you want to use our Calculator(Yes or No):yes
Enter The First Digit:56
Enter The Second Digit:34
Choose The Opperation(+,-,/,*):+
56.0+34.0=90.0

Do you want to use our Calculator(Yes or No):yes
Enter The First Digit:56
Enter The Second Digit:4
Choose The Opperation(+,-,/,*):*
56.0x4.0=224.0

Do you want to use our Calculator(Yes or No):no
Thank You! For Using Our Calculator.