click below
click below
Normal Size Small Size show me how
Python
Chapter 1
| Question | Answer |
|---|---|
| What are hardware and software? | Hardware are the visible elements of the computer and Software is the program that tell the computer what to do. |
| List 5 major components of a computer | -CPU -memory -storage devices -input and output devices -communication devices |
| What does "CPU" stand for? | Central Processing Unit |
| What unit is used to measure CPU speed? | gigaHertz |
| What is a bit? What is a byte? | bits are binary digits (0 and 1), and bytes are the minimum storage unit in a computer (made of 8 bits). |
| What is memory for? What is RAM? | It gives bytes a unique address for storage and retrieval. It's called RAM because the memory can be accessed in any order. |
| What unit is used to measure memory size? | gigabytes |
| What is the primary difference between memory and a storage device? | memory is volatile (can be deleted after turning off) and storage devices are permanent storage |
| What language does CPU understand? | Machine language (in the form of binary code) |
| What is an assembly language? | it uses mnemonics to represent each machine language instruction. It is a low-level language |
| What is an assembler? | translates assembly-language programs to machine-language |
| What is a high-level programming language? | platform independent language, english-like, and use statements |
| What is a source program? | it's a program written in a high-level language. Also known as source code |
| What is an interpreter? | reads statement from the source code to machine code one statement at a time |
| What is a compiler? | translates the entire source code to machine code, then executes the machine code file |
| What is the difference between an interpreted language and a compiled language? | Interpreted language does one statement at a time, and compiled does it all at once |
| What is an operating system? | it manages and controls a computer's activities |
| List some popular operating systems | microsoft windows, Mac OS, and Linux |
| What are the major responsibilities of an operating system? | -controlling and monitoring system activites -allocating/assigning system resources -scheduling operations |
| What are multiprogramming, multithreading, and multiprocessing? | -allows multiple programs to run at the same time -allows a single program to execute multiple tasks at the same time -aka parallel processing, uses two or more processors together to perform subtasks and combine them to solve an entire task |
| What does it mean to say Python is interpreted? | it is translated and executed by an interpreter one statement at a time |
| Can a program written in Python 2 run in Python 3? | No |
| Can a program written in Python 3 run in Python 2? | No |
| What 2 modes can you run Python in? | interactive mode and script mode |
| Is python case-sensitive? | yes |
| what is the python source filename extension by convention? | .py |
| what is the command to run a python source file? | python filename.py |
| how do you denote a comment line and a comment paragraph? | lines used the "#" and paragraphs use " ' ' ' " |
| What is the statement to display the message HELLO WORLD on the console? | print("HELLO WORLD") |
| What are 3 kinds of program errors? | syntax, runtime, and logic errors |
| If you forget to put a closing quote on a string, what error is raised? | syntax error |
| If your program needs to read data from a file, but the file does not exist, what kind of error is this? | runtime error |
| Supposed you write a program from computing the perimeter of a rectangle, but you mistakenly write for the area instead. What kind of error is this? | logic error |
| How do you import the turtle module? | import turtle turtle.showturtle() |
| How do you display text in turtle? | turtle.write() |
| How do you move the pen forward? | turtle.forward() |
| How do you set a new color? | turtle.color() |
| How do you move the pen without drawing anything? | turtle.penup() |
| How do you draw a circle? | turtle.circle() |
| What is the purpose of turtle.done() at the end of a turtle script? | allows program to pause until the user closes the graphics window. Otherwise, the graphics window would close immediately after the program is finished. |