![Page 1: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/1.jpg)
REFERENCE: CHAPTER 1
High-level languages + Python
![Page 2: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/2.jpg)
Game Programming…???
Half-life 3!
???mov ax, 0x5000add ax, 0x0001………….…(5 billion lines later)…jmp 0x6539
![Page 3: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/3.jpg)
High-level Programming languages to the rescue! Half-Life 3
mov ax, 0x5000add ax, 0x0001………….…(5 billion lines later)…jmp 0x6539
Halo Image from: http://ninjanerdstech.com/wiki/halo-4/
3
![Page 4: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/4.jpg)
Compilers / Interpreters
compiler or interpreter Specific to architecture and OS Steps:
Reads source file(s). Generates machine code (CPU instructions)
Compilers Stand-alone executable (.exe file)
Interpreters re-generate machine code every run
![Page 5: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/5.jpg)
High Level Languages
Name Some! Interpreted:
Compiled:
Why are there so many?
![Page 6: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/6.jpg)
Python!
+: Easy to read/write (more English-like than many)
+: A ton of libraries pygame (www.pygame.org)
+: Good balance between ease-of-use and power.
-: Interpreted (so a little slower)-: A little harder to distribute
![Page 7: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/7.jpg)
Installing python at home
Go to www.python.org Or…use the link(s) on ssugames
Python 2.x vs. 3.x Not a lot of differences. We’ll be using 3.1 in-class Find the one appropriate to your OS.
Available on: Windows, OSX, Linux, etc. VERY IMPORTANT: Get the 32-bit version, even if you
have a 64-bit OS (pygame only works with 32-bit python)
![Page 8: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/8.jpg)
Installing python at home, cont.
Pygame We won’t use it for a few weeks, but go ahead and
get it. Go to www.pygame.org Find the version that matches your python version
and OS.Test it.
Start IDLE Type this: If you don’t get an error, you’re all set!
![Page 9: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/9.jpg)
Script vs. Interactive mode
Interpreters usually have "interactive" mode[Script mode differences][Demonstrate in IDLE]
![Page 10: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/10.jpg)
python "IDE's" (and pro's and con's of each)
IDLE (comes with python) interactive mode script mode
DOS (in Win7) Start Menu => "cmd" cd myDir (cd .. goes back a level) z: c:\python31\python myfile.py
Notepad++PyScripter (http://code.google.com/p/pyscripter/)NetBeans…
![Page 11: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/11.jpg)
Errors
SyntaxExceptionsTry these:
print(Hello, World”)
print(Hello, World)
Print(“Hello, World”)
![Page 12: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/12.jpg)
Errors, cont.Call Stack:
The bottom section is the actual error:We got to the error from here:We got there from here:
This is the line number of the error:
This is the type of Error:
![Page 13: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/13.jpg)
Print Functionprint(expression)expression can be:
A string A number A mathematical expression:
4 + 5 4 - 5 4 * 5 4 / 5 2 ** 3
A comma-separated sequence of expressions [sep and end]
![Page 14: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/14.jpg)
Comments
[Syntax and evaluation][Why are they useful?]
![Page 15: REFERENCE: CHAPTER 1 High-level languages + Python](https://reader035.vdocuments.us/reader035/viewer/2022062223/5a4d1b1b7f8b9ab0599933c6/html5/thumbnails/15.jpg)
Input function
[As a means to pause]We'll see the real use shortly…