Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Hi i was curious what this info might be used for, it is the info for a programm

ID: 3803167 • Letter: H

Question

Hi i was curious what this info might be used for, it is the info for a programming question that i will recieve when i go to take my exam? Was seein if anyone has come across something like this and what they came up with, did some research, but haven't found anything.

Was given this as an answer, lookin for little explantion how i would go bout this

Hey.. this is a part of the input given as the text file content.

What i can figure from the above is, it looks like some program which is trying to capture the information related to product. The informtion can be such as Product Name, Product Id and Cost of the product.
So The input file can be in the following format..

The input file will contain first line as the product name, the second line will be product id and the third line will contain product cost per unit. The file may have multiple products and thus, the group of these three lines may repeat one after other, to represent multple products.

Like as per the given file:

Prodcut 1: Name: Slug Slippers, Id: 27, Cost: 39.99
Prodcut 2: Name: Headcrab, Id: 35, Cost: 24.99
Product 3: Name: Disease Balls, Id: 41, Cost: 20
Prodcut 4: Name: Bacon Wallet, Id: 12, Cost: 11.99
Prodcut 5: Busy Bees, Id: 10, Cost: 29.99


For the programming question, you may be given this data in a input file and you will be asked to read the data. After reading the data, you may be asked to store the information in appropriate objects, such as Classes etc.

How would i go about, taking the date and puttin it in different setups, like the last part says? That info above is how i will recieve it, but don't know the exact question yet. The question is called gift shop inventory, so guess a program that tells you how much of something is left and price i guess.

In python code please

Explanation / Answer

Create a class to store a product details. Lets call it ProductDetails

class ProductDetails(object):
   """Class that holds details of a Product"""
   def __init__(self, productName, productID, productCost):
       self.productName = productName
       self.productID = productID
       self.productCost = productCost

Now that we have a class to store the product details. Lets read the data from the file and add the data to object of ProductDetails class

products = []
with open(file) as f:
   while not EOF:
       productName = next(f)
       productID = int(next(f))
       productCost = int(next(f))
       products.append(ProductDetails(productName, productID, productCost))

Lets put that together as a complete program:

class ProductDetails(object):
   """Class that holds details of a Product"""
   def __init__(self, productName, productID, productCost):
       self.productName = productName
       self.productID = productID
       self.productCost = productCost

file = raw_input("Enter file (path): ")
products = []
with open(file) as f:
   while not EOF:
       productName = next(f)
       productID = int(next(f))
       productCost = int(next(f))
       products.append(ProductDetails(productName, productID, productCost))

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote