Hi Guys, can I have a little pointer please


#1

I may be being stupid but can someone look at this code and figure out how the .1 , .3, and .6 came to be the right input for the code.

The bullet point was “Multiply the 3 averages by their weights and return the sum of those three. Homework is 10%, quizzes are 30% and tests are 60%.”

See code below:

lloyd = {
“name”: “Lloyd”,
“homework”: [90.0, 97.0, 75.0, 92.0],
“quizzes”: [88.0, 40.0, 94.0],
“tests”: [75.0, 90.0]
}
alice = {
“name”: “Alice”,
“homework”: [100.0, 92.0, 98.0, 100.0],
“quizzes”: [82.0, 83.0, 91.0],
“tests”: [89.0, 97.0]
}
tyler = {
“name”: “Tyler”,
“homework”: [0.0, 87.0, 75.0, 22.0],
“quizzes”: [0.0, 75.0, 78.0],
“tests”: [100.0, 100.0]
}

def average(numbers):
total = sum(numbers)
total = float(total)
return total / len(numbers)

def get_average(student):
homework = average(student[“homework”])
quizzes = average(student[“quizzes”])
tests = average(student[“tests”])

total = homework *.1 + quizzes * .3 + tests * .6
return total

Thanks in advance, sorry if it a stupid question but I’m just learning this and I can’t figure this out.

Regards,

Harry Babbage


#2
10% => 10 / 100 => 0.1
30% => 30 / 100 => 0.3
60% => 60 / 100 => 0.6

#3

I was frantically trying to delete this post as on reading it again I realised my mistake. Now I feel stupid. Been looking at it for 20 minnute thinking…Huh?

Thanks anyway MTF :slight_smile:

Quick question, which language would be good to learn after Python(judging by my previous question that’ll never happen hahaha)


#4

Being as Python is an increasingly popular language, what need have you to learn any other? You could study Python for months (or years) and just keep getting better informed and write more and more sophisticated apps, games, data analyzers, etc. If you are getting a hang of the language and enjoy what you are learning, then stick with it.


#5

Thanks MTF,

I’m a serving soldier at the moment but plan on transitioning into the cyber industry. Would having Python alone qualify me for employment or is there anything else you could recommend. I literally have time to study for up to 12 hrs a day for the next 5 months. I am really enjoying learning Python at the moment but I find that I keep forgetting simple things that I need to ‘‘Get Solution’’ or use a hint for. It really bugs me lol :stuck_out_tongue:


#6

Given that, I would suggest pour it on and keep practicing, reading and experimenting. Get to know the language intimately and find as many ways as you can to do the same thing.

Sticking with one language, especially one as powerful as Python, is a good way to firm up peripheral skills… logic being at the top of the list. Better that you master one language and build up confidence and your knowledge base. In the future if you are required to learn another language it will be a simple matter of tacklng the different syntax. The programming concepts are pretty much the same across the board. Yes, there are fundamental differences between languages, some nuance, some practical, but they have more in common than not.


#7

Thanks a lot man. I’m just really apprehensive as to whether this is going to help my employment prospects. Nevertheless I will keep on learning as its fun and interesting. So many cool things to do with Python once skilled enough


#8

Sounds like a pretty chill unit if you can just transition and study for 5 months!
I was at NTC as a 90 day loss!

If you have any questions about transitioning out of the military pm me.
Use your G.I. Bill and/or Voc. Rehab It’s an incredible way to learn and be on your feet.


#9

Dude! I wish I had the benefits you guys get in the US. I’m British :slight_smile: I only have so much time to learn because I need a Hip Replacement!!! :frowning: I’m only 30…


#10

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.