Question

Q3: Write a Python program the prompts the user for information for stu num students. For each student prompt for the student
0 0
Add a comment Improve this question Transcribed image text
Answer #1

# I have attached 2 codes, if you are using python2 use first code, if you are using python 3 use second code

#Please UPVOTE if you find my solution useful!!!

#==============Code 1(if you are using Python 2)==============

stu_nums=int(raw_input("Enter number of students: "))

for i in range(1,stu_nums+1):
    name=raw_input("Enter name of student "+str(i)+": ")
    sum=0;
    for j in range(1,4):
        score=int(raw_input("Enter score "+str(j)+": "))
        sum=sum+score
    sum=sum/3
    ans="%0.2f" % sum
    print("Name: "+name)
    print("Average: "+ans+"\n")

#===============Code 1 ends==================

#Don't forget to UPVOTE if you like my solution!!

#Following images shows code 1 and it's output....

stu_nums=int(raw_input(Enter number of students: )) WN 3- for i in range(1, stu_nums+1): name=raw_input(Enter name of stud

Enter number of students: 2 Enter name of student 1: Gary James Enter score 1: 23 Enter score 2: 32 Enter score 3: 45 Name: G

#Please UPVOTE if you find my solution helpful!!!

#=============Code 2(if you're using Python 3)===========

stu_nums=int(input("Enter number of students: "))

for i in range(1,stu_nums+1):
    name=input("Enter name of student "+str(i)+": ")
    sum=0;
    for j in range(1,4):
        score=int(input("Enter score "+str(j)+": "))
        sum=sum+score
    sum=sum/3
    ans="%0.2f" % sum
    print("Name: "+name)
    print("Average: "+ans+"\n")

#===============Code 2 ends==================

#Don't forget to UPVOTE if you like my solution!!

#Following images shows code 2 and it's output....

1 stu_nums=int(input(Enter number of students: )) 2 3 - for i in range(1, stu_nums+1): name=input(Enter name of student +

Enter number of students: 2 Enter name of student 1: Gary James Enter score 1: 23 Enter score 2: 32 Enter score 3: 45 Name: G

#Don't forget to UPVOTE if you like my solution!!

Add a comment
Know the answer?
Add Answer to:
Q3: Write a Python program the prompts the user for information for stu num students. For...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT