0% found this document useful (0 votes)
9 views

Python Worksheet (2)

The document outlines a worksheet for a computer science course where students are tasked with creating a Python program to implement a grading system. The program calculates the average score for students and determines their pass or fail status based on a specified threshold. Additionally, it highlights learning outcomes related to list manipulation, data handling, function usage, and conditional statements.

Uploaded by

virbhadra255
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Python Worksheet (2)

The document outlines a worksheet for a computer science course where students are tasked with creating a Python program to implement a grading system. The program calculates the average score for students and determines their pass or fail status based on a specified threshold. Additionally, it highlights learning outcomes related to list manipulation, data handling, function usage, and conditional statements.

Uploaded by

virbhadra255
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

DEPARTMENT OF

COMPUTER SCIENCE & ENGINEERING

WORKSHEET 1.1

Student Name: Mohit Kumar Singh UID: 22BCS10039


Branch: CSE Section/Group: 22BCS TPP 603 A
Semester: 4 Date of Performance:08-02-2024
Subject Name: Numerical Methods Subject Code: 22CSH-259
and Optimization using Python

1. Aim: Write a python code for schools grading system .the program needs to calculate the average
grade for each student from a list of students scores determines if each student has passed or failed
based on passing threshold.

2. Source Code:

def avg(scores):
return sum(scores) / len(scores)

def grade(score, passing_threshold):


if score >= passing_threshold:
return "Pass"
else:
return "Fail"

def main():
num_students = int(input("Enter the number of students: "))
passing_threshold = float(input("Enter the passing threshold: "))
students = []

for i in range(num_students):
name = input(f"Enter the name of student {i+1}: ")
scores = [float(x) for x in input(f"Enter the scores of {name} : ").split()]
avg_score = avg(scores)
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

grades = grade(avg_score, passing_threshold)


students.append((name, avg_score, grades))

print("\nStudent Grades:")
for student in students:
print("Name:", {student[0]})
print("Average Score:" ,{student[1]})
print("Grade:", {student[2]})

if _name_ == "_main_":
main()

3. Screenshot of Outputs:
DEPARTMENT OF
COMPUTER SCIENCE & ENGINEERING

4. Learning Outcomes:

1. List Manipulation: Students will gain proficiency in working with lists, including creating
lists, iterating over them using loops, and extracting values from lists.
2. Basic Data Manipulation: Students will learn how to manipulate numerical data, such as
calculating averages and determining pass or fail statuses based on thresholds.
3. Functions: Students will learn how to define and use functions to encapsulate reusable
pieces of code, promoting modularity and readability.
4. Conditional Statements: Students will understand conditional statements (if and else) and
how they are used to make decisions based on certain conditions.

You might also like