Exercise Instructions:
-
Create a file called "student.py" and create a Student class. The Student class should have a constructor that takes in a name and GPA and stores them both as instance fields. Create a report_gpa method which returns a string (does not print out, just returns) that says "{name} has a GPA of {gpa}". In a separate file (you can just call it "app.py"), import the Student class, instantiate it with a hardcoded name and GPA, and print out the result of calling the report_gpa method on that class instance.
-
Create a script which calculates a number in the fibonacci sequence using a recursive function. Use the Python time module (Links to an external site.) to record the time it takes to run the function. Print out the fibonacci number and the number of seconds it took to run the function. You can hardcode the call to your function with 35 or any other number.
-
Create a virtual environment (with any name) and activate it. Install the requests library (Links to an external site.) which is used to make HTTP requests to HTTP servers, just like a web browser can do. Remember to create your requirements.txt file after installing 3rd party modules in a virtual environment. Use the requests library to print out the HTML source code of https://www.charlotte.edu/ (Links to an external site.). If you get stuck, check out this page in the docs (Links to an external site.) and this YouTube video (Links to an external site.) (feel free to watch all of it to learn more, but you should only need the first five minutes or so). Remember do not commit the environment directory created by venv but do commit the requirements.txt file.