~ Solve Problems and Learn how to code in Python

9a - Use Dictionaries, loops, functions, calculations(like average) to create a Football Coach Club application

Mr X is a football coach and wants to keep track of his various players. He wants to store their names and goals in a program that allows him to quickly view the details, update them, and also search by player. Fun stuff! In creating this application you will be learning some key and crucial skills that will help you solve more complicated projects. Take special note of the way the MAIN MENU is organised with the while loop outside of it. This avoids recursive calls to the main menu from each sub, which is a far better solution in the long run - you can read about recursion, if you're interested (although it's not quite where we are up to yet) here.

Challenge - use dictionaries to store player information and their goals. This will help Mr X their coach immensely!

First, watch the demo video below. Your task is to code something like this, and use the code below to get started

You can either edit and code online in repl.it or you can simply cut and paste the below into your own python file

#Run and play with the code! The program allows a user to enter a number of students (their names and test scores) and then search for a student, returning their average score for the three tests

#1------Create a similar program for a football coach (he wants to store player names + goals for 3 matches)
#2 -----main menu that allows for 1. Adding players + goals and 2. Search by Player 3. Quit
#3------A*/Extension students will also add features to UPDATE player goals and VIEW all player details
def main():
  print("Record student test scores here")
  num_students = int(input("Please enter number of students you wish to enter:"))
  print ("You are entering %s students" %num_students)
  student_info = {} #this creates a dictionary called student_info storing student name (key) and value ( a list of all their three test scores)
  student_data = ['Test 1 marks : ', 'Test 2 marks : ', 'Test 3 marks : ']
  for i in range(0,num_students):
      student_name = input("Enter Student Name :")
      student_info[student_name] = {}
      for entry in student_data:
          student_info[student_name][entry] = int(input(entry)) #storing the marks entered as integers to perform arithmetic operations later on.
  #print student_info
  print("Calculate average score: Enter student name:")
  name = input("Student name : ")
  if name in student_info.keys():
      print ("Average student marks : ", str(sum(student_info[name].values())/3.0))
      print("please enter valid name")

Tutorial - try it yourself before you watch these!

If you are completely unable to solve this on your own, we would suggest you go through these four tutorials step by step and learn as you create. You may then be able to solve the next challenge!

Solve and Learn Series #2 -Create and Learn - Creating a Football Coach App. This tutorial takes you through the creation of a mini program for a football coach. The football coach wishes to store information about his players, including their names, match goals, and do clever stuff like view all player details, view the average goals they have scored for all matches, update player details, and so on.....The tutorial makes use of a wide variety of skills that are covered in Series #2 including: sequence, selection, iteration (while and for loops), dictionaries, lists, string manipulation, local/global variables, functions, modular design, the creation of a main menu (with a while loop to avoid recursive menu calls) and more ....!

Part 1

Part 2

Part 3

Part 4

Code your solution here

Systems Life Cycle (in a nutshell): Analyse - Design - Create - Test - Evaluate. Designing something or writing out some pseudocode before you actually write code is always a good idea! Get in to the habit of doing so! You can draw your flowchart here and screenshot it.

A sample flow chart (design) for this particular challenge could look like:

Flowchart: Python program to get the Fibonacci series between 0 to 50
Each challenge section below provides an online drawing tool where you can dynamically create flowcharts. Screenshot them into your presentation for submission.

Solutions & Answers

Answers /Solutions in the "members area" drive under: "Solve and Learn >>SOLUTIONS"

Testing Table

You may want to read a little about Testing first. A teacher may go through some examples with you. Feel free to fill in the test table here, and screenshot it in to your powerpoint. Testing is absolutely essential once you have created a program!
Test No. Description Test Data(input) Expected Outcome Actual Outcome Further Action?
Coming soon!