CSCI 101 - Intro to Computer Science

Python Lab

Quick Links: zyBook | Piazza | Canvas | CS @ Mines

Home | Contact | Schedule | Assignments | Syllabus |

Python Lab 1B: Mixed Fractions
Due Tuesday, September 7th, by 11:45pm


Introduction

Welcome to your second Python lab in CSCI 101! This lab, as well as Lab 1A, need to be submitted to Gradescope by the due date. You will submit each lab separately, as a single .py file.

To get started, open IDLE and then create a New File via the File menu. We suggest you immediately save this file in some directory you create that you will use to store/manage all your Python Labs this semester (e.g., CSCI101/PythonLabs). Save this file as Lab1B-mixed_fractions.py.

Assignment

An improper fraction is a fraction with a larger number in the numerator than in the denominator (e.g. 27/11). A mixed fraction is an improper fraction shown as a whole number with a proper fraction (e.g. 27/11 -> 2 5/11). Write a Python program that converts (possibly) improper fractions into mixed fractions. A couple of hints:
  • Use some of the new operators that you have learned in this class for the calculations.
  • F-string formatting will help you output the mixed fraction correctly.
For 102 students: we suggest you complete the CSCI 102 labs this week before this CSCI 101 lab.

Lab I/O Format

For lab assignments this semester, a specific Lab Input/Output Format is required. This format is described below:
  • When prompting for input, use the prompt string WORD>, where WORD is a single, uppercase word which describes the input. For example, this lab might choose: NUMERATOR> and DENOMINATOR>.
  • When providing output that will be graded, start the line with the word OUTPUT followed by exactly one space, e.g. OUTPUT . Think of this as "boxing your answer" on a math worksheet; it lets us quickly find your answer. Gradescope will skip any output lines that do not start with OUTPUT.
  • You are welcome to have other output lines that do not begin with OUTPUT; Gradescope will ignore these.
  • A submission without exactly correct output formatting will receive an AUTOMATIC ZERO. This is because Gradescope is automated—it does not look at your code, only the results, and thus the format of the results must be consistent for all students.

Example Execution 1

Input the numerator of the improper fraction.
NUMERATOR> 46
Input the denominator of the improper fraction.
DENOMINATOR> 7
46/7 as a mixed fraction is:
OUTPUT 6 4/7

Example Execution 2

Input the numerator of the improper fraction.
NUMERATOR> 246000000000000
Input the denominator of the improper fraction.
DENOMINATOR> 9840000000000
246000000000000/9840000000000 as a mixed fraction is:
OUTPUT 25 0/9840000000000

Example Execution 3

Input the numerator of the improper fraction.
NUMERATOR> 7
Input the denominator of the improper fraction.
DENOMINATOR> 43
7/43 as a mixed fraction is:
OUTPUT 0 7/43

Gradescope Submission Nuances

When you submit your Python file to Gradescope, multiple different test cases are run on your code. Passing all of the tests results in a 100% on the autograded portion of the lab.

You are allowed to submit to Gradescope four times (or less) for this lab. The maximum grade of your submissions will be your grade for the lab. Note: If your code doesn’t work (e.g., a syntax error exists, or an error is thrown in execution), then you will received an AUTOMATIC ZERO. You should test your code before submitting to ensure it executes correctly.

Comments

All Python files should include a header with your name, section, assignment info, references (i.e., who did you collaborate with on this assignment?; what resource did you use?), and approximate time taken to do the assignment. Be sure to cite any allowed external references used to complete the assignment. Any code without this header will lose 1 point. Here's an example:
        #   John Henke
        #   ​CSCI 101 – Section D
        #   Python Lab 1B
        #   References: TA Gabriel helped me in office hours with the math.
        #   Time: 45 minutes

Submission

Once you are satisfied with your solution to this lab, you need to submit the file to Gradescope. In Canvas, go to Assignments > Lab1B and upload Lab1B-mixed_fractions.py.

To receive credit, your code must execute in Python 3, and you must submit a single file for the assignment (your Python code file). In addition, your code must follow the Lab I/O Format.

Whenever you submit something to Gradescope, we strongly recommend you always double check what you submitted actually got submitted correctly (e.g., did the file upload correctly? did you submit the correct file? etc.) If your submission is incorrect, it's on you.

Note: this lab is worth 2 points.




Valid HTML 4.01 Strict Valid CSS! Level Triple-A conformance, W3C WAI Web Content Accessibility Guidelines 2.0