Lab1

docx

School

San Jose State University *

*We aren’t endorsed by this school

Course

104

Subject

Electrical Engineering

Date

Dec 6, 2023

Type

docx

Pages

13

Uploaded by CountWolfMaster424

Report
San Jose State University Department of Electrical Engineering EE104, Spring 2023, Pham Laboratory Assignment #1 Objectives This lab is a guided tour of the Anaconda installation process. The goal of this lab is to prepare the tools you will be using for the rest of the semester and help you to recognize key patterns so that you can be quickly productive by leveraging available resources. Grading Program or Requirement Earned score / Max score HelloWorld.py / 10 FinancialCalculator.py / 25 Calculator.py / 25 Game Development: ShootTheFruit.py /20 Create a standalone executable file with a calculator program or a game program / 10 Submit Lab1_Lastname_FirstName.Zip file on time to Canvas / 10 TOTAL ________ / 100 Bibliography I would like to acknowledge the Python open-source community and respective suppliers for making the material available. Download, Installation, and Licensing You will need a computer with a CPU equivalent to Intel CORE i6 and 32MB of RAM for intensive computing. Older versions of computers will work but very slow. Installing Anaconda Go to https://www.anaconda.com/ 1
Click on Download After downloading, you should have this file in your Download folder. Double click on it to install Anaconda. After the installation completed, you can check out that Anaconda3 (64-bit) has been installed. 2
Click on Anaconda Navigator to invoke the Navigator: You may need to update to the latest navigator. Go ahead and answer YES to update. Select Launch Navigator to launch the newer version. You can quit the old version if it is still running in the background. 3
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Below are four main apps that we will use in this class. Alternatively, you can invoke individual apps from the Windows menu: Congratulations on completing the Anaconda installation process. You are ready to proceed to the next installation. 4
Installing Notepad++ There are many good programming editors that you can download and install. I personally use Notepad++. Here is how you will install it. Google for notepad++ download and click on the link to Current Version #.#.# Then install it from your Download folder. After the installation, you should see the Notepad++ icon from the Windows menu. You can drag its icon and drop it to the Windows tray as a short cut. Congratulations on completing the Notepad++ installation process. You are ready to proceed to the first Python program. 5
Python Programming Your First Hello World Python Program First Method – Using the Command Line Invoke Anaconda Powershell Prompt Try a few lines of Python. You will see it is very intuitive. Type exit() at the >>> prompt to exit to the directory view. Second Method – Write a program from Spyder You can invoke Spyder from the Window menu, or from the Anaconda Navigator. 6
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Type the following program into the Spyder text editor. Press the green play button to execute it on the right console. Alternatively, you can type it from Notepad++, save it as a file. Let’s name it HelloWorld.py. Then drop it into Spyder. Remember to change the Language to Python to see the Python keyworks in colors. 7
Congratulations on completing your first Hello World program using the Command Line method, Spyder using its built-in text editor, and using Notepad++! Lab Submission Submit a screen shot of your HelloWorld.py program executing from the Spyder console. Now you are ready to try something more complex and more interesting! 8
Your First Financial Computing Python Program Drop the file LoanCalculator.py into the Spyder editor and execute it. Get acquaintance yourself to the code below. Don’t worry about how to write the program yet at this point. You just need to be able to recognize where things are. Lab Submission Double check the formula on line 54 is the formula from this website: https://www.valuepenguin.com/mortgages/mortgage-payments- calculator You can modify the program in whichever way you want to accommodate this formula: M = P [ I ( 1 + I )^N ] / [ ( 1 + I )^N – 1 ] In order to find your monthly payment amount "M," you need to plug in the following three numbers from your loan: P = Principal amount (the total amount borrowed) I = Interest rate on the mortgage N = Number of periods (monthly mortgage payments) Add comments to all important parts of the program. Add one more box to show total interest paid at the end of the loan life time. Good job! Now let’s try another Calculator program to see how things work. 9
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
Your First Python GUI Calculator Program GUI is short for Graphic User Interface. GUI is intuitive and easy for user to use your app. Let’s do it! Drop the SimpleCalculator.py program to Spyder and execute it. Play around with the calculator. Recognize how the color assignments, the function assignment, rows and columns, etc. Try to change the background and foreground colors, add more rows and columns, and functionality. Lab Submission 1. Add 2 more functions to the calculator (10 points each), and beautify the GUI using professional colors, bigger text fonts, etc. (5 points) 2. Record a quick video clip with your own voice explaining the code and how it is executing along with the code. 10
Your First Python GUI Game Program Game is fun! Python is an excellent choice for game development. Let’s do one! Reading: Chapter 3, Coding Game In Python From the Powershell, install the followings: pip install pygame pip install pgzero From < YOUR GAME DIRECTORY>\CodingGameInPython\Chapter 3 Shoot The Fruit\Game Files, drop the file ShootTheFruit.py program to Spyder and execute it. Lab Submission 1. Add comments to each line of code. (10 points) 2. Change the game any you want to, such as the original location of each fruit, the fruit picture, how the game responds to your mouse clicks, use another image, etc. (10 points) Run the python code from this website to convert the picture to 32x32 format: https://www.codegrepper.com/code-examples/python/resize+image+to+32x32+python #The following code should be run from the same image directory from PIL import Image image = Image.open("deer.jpg") image = image.resize((32,32),Image.ANTIALIAS) image.save(fp="deer32x32.jpg") 3. Record a quick video clip with your own voice explaining the code and how it is executing along with the code. Explain anything you added to the program. 11
Create a Standalone Executable File (10 points) Follow the steps in one of the link below to generate a standalone executable file for your application. Use it to demonstrate your lab. You only need to produce an executable file for any of the programs above (not all of them). https://datatofish.com/executable-pyinstaller/ https://towardsdatascience.com/how-to-easily-convert-a-python-script-to-an-executable-file-exe-4966e253c7e9 That’s all for this lab. Hopefully it sparks your curiosity into the Python world! See you in Lab 2. Laboratory Hand-In Requirements Once you have completed a working design, prepare for the submission process. You are required to demonstrate a working design. You are also required to submit an archive of your project in the form of a ZIP file. Use 7-Zip option to create the ZIP file. Name the archive lab#_ yourlastname_ yourfirstname.zip . See the following figure for an example. You can download 7-Zip from https://www.7-zip.org/download.html Archive Project as a Zip File 12
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help
You will submit your zip file to the instructor through Canvas by the due date and time. For each part, record a quick video clip with your own voice explaining the code and how it is executing along with the code, and results. Explain anything you added to the program. If your program is not completely functional by the due date, you should demonstrate and turn in what you have accomplished to receive partial credit. See the syllabus for the late penalty guideline 13