Introduction Flashcards
(11 cards)
What is the Console
The console shows the text output of your program. It’s right beneath the Interpreter
What are some well known uses for Python?
- Backend web servers
- Dev Ops and cloud engineering
- machine learning
- scripting and automation
- etc
It is not often used in front end apps but it is possible
What is code?
Code is just a series of instructions for a computer to follow one after another.
When giving the code multiple instructions, in what order does code run?
Code runs in order, starting at the top of the program to the bottom.
For example:
print(“this prints first”)
print(“this prints second”)
print(“this prints last”)
What is Syntax?
“Syntax” is jargon for “valid code that the computer can understand”.
- The rules for valid code in a programming language. (this term is not exclusive to just Python, you can use this term in other program languages)
- The rules for how expressions and statements should be structured in a language. For example, in Python, the following is correct syntax:
print(“hello world”)
While in a different programming language, like Go, the correct syntax would be: fmt.Println(“hello world”)
Other than Syntax errors.
What are some other bugs in your code that you can run into?
Syntax errors aren’t the only kind of problems you can run into when coding, for example:
- A bug in your logic. Your code is valid, and will run, but it does something unexpected.
- It’s too slow. Your code is valid and does what’s expected, but it does it slowly
(performance issues will be covered later)
What happens if you try to run code with invalid syntax?
You’ll get an error message from the Python interpreter and the code won’t execute.
What does the “Run” button do?
Run: For testing and debugging. There is no penalty for running your code.
What does the “Submit” button do?
Submit: Runs your code, deploying to production.
How do you get the average number over 4 servers?
print((250 + 241 + 244 + 255) / 4)
When might you use a None value?
Set None as the default value that will be replaced later.
One usecase is to represent that a value hasn’t been determined yet, for example, an uncaptured input.
For example, maybe your program is waiting for a user to enter their name. You might start with a variable:
username = None
Then later in the code, once the user has entered their name, you can assign it to the username variable:
username = input(“What’s your name? “)
Remember, it’s crucial to recognize that None is not the same as the string “None”. They look the same when printed to the console, but they are different data types. If you use “None” instead of None, you will end up with code that looks correct when it’s printed but fails the tests.