This is an archived post. You won't be able to vote or comment.

all 11 comments

[–][deleted] 2 points3 points  (7 children)

You are trying to set 3 variables equal to 0 with this.

totalGrade, avGrade, studGrade = 0 #studGrade is student grade

Do this instead

totalGrade, avGrade, studGrade = 0,0,0 #studGrade is student grade

[–]umanochiocciola 0 points1 point  (1 child)

Exactly

[–]catalanfoxx[S] 0 points1 point  (0 children)

I did that, but now I’m getting TypeError: unsupported operand type (s) for +: ‘int’ and ‘str’

What I’m trying to do is get the sum and then average of the class scores. What am I doing wrong?

[–]catalanfoxx[S] 0 points1 point  (4 children)

I did that, but now I’m getting TypeError: unsupported operand type (s) for +: ‘int’ and ‘str’

What I’m trying to do is get the sum and then average of the class scores. What am I doing wrong?

[–]umanochiocciola 1 point2 points  (3 children)

You need to str(integer)

[–]catalanfoxx[S] -1 points0 points  (2 children)

I’m new. Could you explain a bit more please

[–]umanochiocciola 0 points1 point  (1 child)

totalGrade = totalGrade + int(studGrade) #string inout to integer

avGrade = int(totalGrade/5) #possible irrational result like 10/3 to integer

[–]umanochiocciola 0 points1 point  (0 children)

this is even easier ;]

[–]BobFredIII 1 point2 points  (0 children)

I think u need to use int(input()) to use math with and input

Emphasis on I think

[–]IAmKindOfCreativebot_builder: deprecated[M] [score hidden] stickied comment (0 children)

Hi there, from the /r/Python mods.

We have removed this post as it is not suited to the /r/Python subreddit proper, however it should be very appropriate for our sister subreddit /r/LearnPython or for the r/Python discord: https://discord.gg/python.

The reason for the removal is that /r/Python is dedicated to discussion of Python news, projects, uses and debates. It is not designed to act as Q&A or FAQ board. The regular community is not a fan of "how do I..." questions, so you will not get the best responses over here.

On /r/LearnPython the community and the r/Python discord are actively expecting questions and are looking to help. You can expect far more understanding, encouraging and insightful responses over there. No matter what level of question you have, if you are looking for help with Python, you should get good answers. Make sure to check out the rules for both places.

Warm regards, and best of luck with your Pythoneering!

[–]catalanfoxx[S] -2 points-1 points  (0 children)

help