GithubHelp home page GithubHelp logo

randyaajr / python-assignment Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 11 KB

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

Python 100.00%
python userinput average-calculator

python-assignment's Introduction

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..

python-assignment's People

Contributors

randyaajr avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.