Computer Science - Machine Learning Python Programming Assignment

profilefreamji

Assignment Help. Please don’t forget to add comments in the code

  • 5 months ago
  • 30
files (1)

Lab2.pdf

Page 1 of 3 NorQuest College – CMPT 1011: Lab Assignment 5

CMPT 1011: Introduction to Computing

Lab Assignment 2: Variables, mathematical operations and data types

Value

This coding challenge is worth 3% of your final grade.

Background

In this coding challenge you will be using variables to calculate and print the correct output.

This assignment relates to the following General Learning Outcomes:

1. Explain fundamental concepts in computing science

2. Examine different data types and manipulating variables

Instructions

1. Use Intellij Idea write your code and make sure it works for couple of examples.

Problem statement: Shopping calculator

A shopkeeper sells apples at 3$/unit, bananas at 1.8$/unit and oranges at 2.5$/unit. He

usually sells 20 apples, 50 bananas and 35 oranges per day. However, due to extreme

snowy conditions, he’s offering special discounts:

• Apples: 10% off,

• Bananas: 15% off clearance sale,

• Oranges: 10 for 22$.

Now, a customer arrives on a snowy day and wants to buy X apples, Y oranges and Z

bananas.

Your task is to calculate and print the following:

1. Revenue from the Customer:

• Ask for the number of apples (X), oranges (Y) and bananas (Z) bought. For

example: "How many oranges? <Y>" and "How many bananas? <Z>"

• Calculate the total cost for the customer, factoring in all discounts.

Page 2 of 3 NorQuest College – CMPT 1011: Lab Assignment 2

• Print: "The shopkeeper sold X apples, Y oranges and Z bananas to the customer for

a total of $<M>." Where <M> is your total calculated price.

2. Usual daily revenue:

• Calculate and print the shopkeeper's usual daily revenue based on the standard

pricing.

• Print: "Usually, the shopkeeper makes ‘$’." Where ‘$’ should have your calculated

total revenue for X apples, Y bananas and Z oranges.

Suggestions:

• You are to solve the problem by declaring variables containing each fruit unit price.

For example, apples_price = 3, bananas_price = 1.8 etc. You will also have

different variable storing each fruits’ discounted price for snowy days, e.g.

discounted_apples_price = 0.9* apples_price.

• When asking for user inputs, use descriptive variable names and correct casting to

type as needed. For example:

num_apples = float(input("How many apples? "))

• Use clear variable names when calculating total revenue for the customer and the

usual daily revenue. For example, total_customer_revenue, total_usual_revenue

etc.

• In print statements, practice concatenating variable values using f-strings, the “+”

or “,” operator. Example of f-strings:

print(f"The shopkeeper sold {num_apples} apples,

{num_oranges} oranges and {num_bananas} bananas to the

customer for a total of ${total_customer_revenue}.")

2. Submit your "<FirstName>_<LastName>_Lab2.py" file to the Moodle assignment box.

3. Deadlines will be announced in Moodle. Consider this assignment your opportunity to

integrate what you’ve learned throughout the course.

4. You will be assessed using the rubric provided.

Page 3 of 3 NorQuest College – CMPT 1011: Lab Assignment 2

Assignment Rubric (Total: __/12 marks)

5 3 2 1

Does Not

Meet

Expectations

0

Print

statements

and input

function usage

All the print

statements

are

correctly

showing the

values and

input

function

used

properly

1 or few

print

statements

missing. 1

or few

inputs not

taken.

A few

messages not

displayed, and

input function

not correctly

used.

Both print

statements

and input

function not

used correctly.

No evidence

Variable

naming and

Type casting

All variable

names

sensible

and

correctly

casted to

types as

required

Some

variable

names

sensible

and

correctly

casted to

types as

required

Variable

names are not

clear

Variable

names not

clear and type

casting not

done correctly

No evidence

Filename and

documentation

Good

documentation

in code and

correct

filename

Either

documentation

or filename

not correct

No evidence