<jupyter_start><jupyter_text>Laboratory 6 - Part 1  Classes and ObjectsIn object-oriented programming, a class is an extensible program-code-template for creating objects, providing initial values for state (member variables) and implementations of behavior (member functions or methods). In many languages, the class name is used as the name for the class (the template itself), the name for the default constructor of the class (a subroutine that creates objects), and as the type of objects generated by instantiating the class; these distinct concepts are easily conflated.When an object is created by a constructor of the class, the resulting object is called an instance of the class, and the member variables specific to the object are called instance variables, to contrast with the class variables shared across the class.Classes provide a means of bundling data and functionality together. Creating a new class creates a new type of object, allowing new instances of that type to be made. Each class instance can have attributes attached to it for maintaining its state. Class instances can also have methods (defined by its class) for modifying its state.Class definitions, like function definitions (def statements) must be executed before they have any effect. (You could conceivably place a class definition in a branch of an if statement, or inside a function.)In practice, the statements inside a class definition will usually be function definitions, but other statements are allowed, and sometimes useful — we’ll come back to this later. The function definitions inside a class normally have a peculiar form of argument list, dictated by the calling conventions for methods — again, this is explained later.When a class definition is entered, a new namespace is created, and used as the local scope — thus, all assignments to local variables go into this new namespace. In particular, function definitions bind the name of the new function here.When a class definition is left normally (via the end), a class object is created. This is basically a wrapper around the contents of the namespace created by the class definition; we’ll learn more about class objects in the next section. The original local scope (the one in effect just before the class definition was entered) is reinstated, and the class object is bound here to the class name given in the class definition header (ClassName in the example).whatis an object.....Learn more at 1. https://docs.python.org/3/tutorial/classes.html 2. https://en.wikipedia.org/wiki/Class_(computer_programming)  1) Class and objects  Exercise-1: Write a class named '**CarSpeed**' to calculate the speed (in miles/hour) of different brands of cars based on the information given in the table below.  The formula to calculate speed is also given below.  Based on your output, which brand of car has the highest speed?$$Speed = \frac{Distance}{Time}$$| Car brand   | Distance (miles) | Time (hours) || ----------- | -----------------|------------|| Ford        | 120              | 1.75       || Ferrari     | 100              | 1.20       || BMW         | 205              | 2.35       || Porsche     | 155              | 1.85       || Audi        | 190              | 2.10       || Jaguar      | 255              | 2.45       | Notes: 1. Use docstrings to describe the purpose of the class.2. Create an object for each car brand and display the output as shown below.Ford_Speed (miles/hour): **SPEED**  Ferrari_Speed (miles/hour): **SPEED**   BMW_Speed (miles/hour): **SPEED**    Porsche_Speed (miles/hour): **SPEED**   Audi_Speed (miles/hour): **SPEED**  Jaguar_Speed (miles/hour): **SPEED**  The car with the highest speed is: **CAR BRAND**<jupyter_code>class CarSpeed:
    """This class calculates the speed of the car based on the given distance and time"""
    def __init__(self, distance, time):
        self.distance = distance
        self.time= time
        
    def speed(self):
        return self.distance/self.time
    
ford = CarSpeed(120, 1.75)
ferrari = CarSpeed(100, 1.20)
bmw = CarSpeed(205, 2.35)
porsche = CarSpeed(155, 1.85)
audi = CarSpeed(190, 2.10)
jaguar = CarSpeed(255, 2.45)
print("Ford_Speed (miles/hour):", ford.speed())
print("Ferrari_Speed (miles/hour):", ferrari.speed())
print("BMW_Speed (miles/hour):", bmw.speed())
print("Porsche_Speed (miles/hour):", porsche.speed())
print("Audi_Speed (miles/hour):", audi.speed())
print("Jaguar_Speed (miles/hour):", jaguar.speed())

print("The car with the highest speed is: Jaguar") ## this needs work, should choose from highest speed, maybe make a dictionary<jupyter_output>Ford_Speed (miles/hour): 68.57142857142857
Ferrari_Speed (miles/hour): 83.33333333333334
BMW_Speed (miles/hour): 87.23404255319149
Porsche_Speed (miles/hour): 83.78378378378378
Audi_Speed (miles/hour): 90.47619047619047
Jaguar_Speed (miles/hour): 104.08163265306122
The car with the highest speed is: Jaguar<jupyter_text>Exercise-2: Write a class named '**Tax**' to calculate the state tax (in dollars) of Employees at Texas Tech University based on their annual salary.  The state tax is 16% if the annual salary is below 80,000 dollars and 22% if the salary is more than 80,000 dollars. $$Tax = Annual salary \times State\, tax\, \%$$| Employee    | Annual salary (dollars) | | ----------- | ------------------------|| Bob         | 1,50,000                | | Mary        | 78,000                  | | John        | 55,000                  | | Danny       | 1,75,000                |  Notes: 1. Use docstrings to describe the purpose of the class.2. Use if....else conditional statements within the method of the class to choose the relevant tax % based on the annual salary.3. Create an object for employee and display the output as shown below.Bob's tax amount (in dollars): **AMOUNT**  Mary's tax amount (in dollars): **AMOUNT**  John's tax amount (in dollars): **AMOUNT**  Danny's tax amount (in dollars): **AMOUNT**<jupyter_code>class Tax:
    """This class calculates the tax amount based on the annual salary and the state tax %"""
    def __init__(self, salary):
        self.salary = salary
        
    def taxamount(self):
        if self.salary < 80000:
            return self.salary*(16/100)
        else: 
            return self.salary*(22/100)
    
bob = Tax(150000)
mary = Tax(78000)
john = Tax(55000)
danny = Tax(175000)

print("Bob's tax amount (in dollars):", bob.taxamount())  
print("Mary's tax amount (in dollars):", mary.taxamount())  
print("John's tax amount (in dollars):", john.taxamount())  
print("Danny's tax amount (in dollars):", danny.taxamount())<jupyter_output>Bob's tax amount (in dollars): 33000.0
Mary's tax amount (in dollars): 12480.0
John's tax amount (in dollars): 8800.0
Danny's tax amount (in dollars): 38500.0
{'fraction_non_alphanumeric': 0.10075343477618555, 'fraction_numerical': 0.04106958191756537, 'mean_word_length': 3.4983388704318936, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 7, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 1, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '555627', 'license': 'CC0-1.0', 'n_tokens_mistral': 2045, 'n_tokens_neox': 1786, 'n_words': 842, 'path': '1-Lessons/Lesson06/Lab6/src/Lab6-Classes.ipynb', 'repo_name': 'dustykat/engr-1330-psuedo-course', 'size': '6769'}