A binary file named “TEST. dat” has some records of the structure [TestId, Subject, MaxMarks, ScoredMarks) Write a function in Python named DisplayAvgMarks(Sub) that will accept a subject as an argument and read the contents of TEST. dat. The function will calculate & display the Average of the ScoredMarks of the passed Subject on screen.
A binary file named “TEST.dat” has some records
of the structure [TestId, Subject, MaxMarks,
ScoredMarks] Write a function in Python named
DisplayAvgMarks(Sub) that will accept a subject
as an argument and read the contents of
TEST.dat. The function will calculate & display the
Average of the ScoredMarks of the passed
Subject on screen.
Contents
Explanation
def SumSalary(Sub):
f = open(“ABC.dat”, “rb”)
c=0
s=0
while True:
try:
g = p.load(f)
print(g)
if g[1]==Sub:
s=s+g[3]
c=c+1
except:
f.close()
print(“sum of salary”, s/c)
f.close()
Explanation:
binary file named “TEST.dat” has some records of the structure
[TestId, Subject, MaxMarks, ScoredMarks)
Write a function in Python named DisplayAvgMarks(Sub) that will accept a
subject as an argument and read the contents of TEST.dat. The function will
calculate & display the Average of the ScoredMarks of the passed Subject on
screen.
plzz ans fast
Explanation:
# Program make a simple calculator
# This function adds two numbers
def add(x, y):
return x + y
# This function subtracts two numbers
def subtract(x, y):
return x – y
# This function multiplies two numbers
def multiply(x, y):
return x * y
# This function divides two numbers
def divide(x, y):
return x / y
print(“Select operation.”)
print(“1.Add”)
print(“2.Subtract”)
print(“3.Multiply”)
print(“4.Divide”)
while True:
# Take input from the user
choice = input(“Enter choice(1/2/3/4): “)
# Check if choice is one of the four options
if choice in (‘1’, ‘2’, ‘3’, ‘4’):
num1 = float(input(“Enter first number: “))
num2 = float(input(“Enter second number: “))
if choice == ‘1’:
print(num1, “+”, num2, “=”, add(num1, num2))
elif choice == ‘2’:
print(num1, “-“, num2, “=”, subtract(num1, num2))
elif choice == ‘3’:
print(num1, “*”, num2, “=”, multiply(num1, num2))
elif choice == ‘4’:
print(num1, “/”, num2, “=”, divide(num1, num2))
break
else:
print(“Invalid Input”)
Explanation:
thank
answer:
Multiplication table (from 1 to 10) in Python
num = 9
# To take input from the user
# num = int(input(“Display multiplication table of? “))
# Iterate 10 times from i = 1 to 10
for i in range(1, 10):
print(num, ‘x’, i, ‘=’, num*i)
Output
9x 1 = 9
9 x 2 = 18
9x 3 = 27
9x 4 = 36
9x 5 = 45
9x 6 = 54
9x 7 = 63
9x 8 = 72
9x 9 = 81
9x 10 = 90
for i in range(0,101):
print(“\n”,i)
if(i%11==0):
print(“POP & NUMBER IS “, i) ;
Explanation:
HOPE IT HELPS YOU..
print(“Python is a dynamic, high level, free open source and interpreted programming language. It supports object-oriented programming as well as procedural oriented programming. It is very easy to code in python language and anybody can learn python basics in a few hours or days. It is also a developer-friendly language.”)
Explanation:
Use this command to print any output
Question:-To display odd numbers between 1 and 50Condition:-Use for loop in python__________Code:-for i in range (1,50,2):
print (i,end=”,”)
____________
Explanation:This program is to print odd numbers between 1 to 50in this code, i loop iterates from 1 to 49.it is written “print(i,end=”,”) ” so that i can print the odd numbers with comma(,)….it is also used to print the values in same lines….to print in separate lines….you can just write print(i)Each iteration is running 2 step forward starting from 1 that is 1,3,5…like this…..so the control will print odd numbers only. _________•Output Attached

