Skip to content

This program asks the user to input a course number and then allows user to then set the grade/mark for each course. Then the user will recieve an output with his/she grade and average

Notifications You must be signed in to change notification settings

randyaajr/Python-Assignment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 

Repository files navigation

Python-Assignment


This assignment demonstrats my skills in the following:

  • Creating variable following Python naming convention
  • Reading/output data from/to VS Code Terminal
  • Converting string data type to integer
  • Using the two types of loop: While and For
  • Arithmetic operations with BEDMAS Rules
  • Using lists (Like Arrays in JavaScript)
  • If elif condition with logical operators

Assignment Instructions/Requirements:

Create a new Python and save it as .py file as “py-assignment1.py” like py-assignment1.py

  1. You will use print() to print the output in the terminal window
  2. The assignment was designed to be similar like the challenges that you have been using by adding hints and notes about the solution
  3. This assignment document contains screen shot for the output to give a better understanding and a clear idea about the final result
  4. Please feel free to use any other ways or logic you prefer or you like since you will get the same results at the end

Part 1:

  • You will ask the user to enter how many courses did he/she finish using the input() built-in function:

    • The text to be displayed with the print: “How many courses did you finish?”
    • Declare a variable named “num_of_courses” to save the number of courses (which is the value that will be returned from the print function based on the user’s input). The “num_of_course” should be just an int variable (variable with integer value).
    • Make sure that the input value (which is string) is converted into number (numeric) using the appropriate Python built-in function that we covered in our lectures
  • Declare an empty list (empty array in JS), this array variable will be used to contain the course marks (later) named “course_marks”. This “course_marks” will be just an empty list exactly as we did in

  • You will use “while loop” loop for a specific number of times based on your variable num_of_courses, for example if num_of _courses value is 5 as shown in the image above, you will make the loop iterate for 5 times. In each iteration of the loop, you will ask the user to enter his/her course mark. This mark will be inserted into the list “course_marks” immediately (instantly), so you will populate this list with the user input through this while loop.

  • After the user finish inserting all their value into our list “course_marks”, use “for loop” to print the items of course_marks list

Part 2:

  • You will find the average for all the courses:
    • First you need to find the total of all the courses marks inside the list (for sure) using any kind of loop you want
      • The math formula for average ➔ The total of the numeric values / How many numeric values
    • Then you can divide the total of the courses by the number of courses and assign the result into a new variable named “average”
      • In our Py assignment ➔ The total of all the marks inside our list / The length of our list
    • Print the following sentence: “Your average for your 5 courses is: 88.0”

Part 3

  • Output (print) the grade, so you will use “if condition” to check the average value as explained below:
    • If average >= 90 and average <=100 ➔ display: “Your grade is A+”
    • Else If average >= 80 and average <=89 ➔ display: “Your grade is B”
    • Else If average >= 70 and average <=79 ➔ display: “Your grade is C”
    • Else If average >= 60 and average <=69 ➔ display: “Your grade is D”
    • Else If average <60 [or just use else] ➔ display: “Your grade is F”

Happy coding!
Coding..

About

This program asks the user to input a course number and then allows user to then set the grade/mark for each course. Then the user will recieve an output with his/she grade and average

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages