We can't find the internet
Attempting to reconnect
Something went wrong!
Hang in there while we get back on track
Tutorials - Trey Hunner: Intro to Python for Brand New Programmers
Learn the fundamentals of Python programming with this beginner-friendly tutorial, covering basic syntax, variables, control structures, functions, modules, error handling, and more.
Basic Syntax
- Python has a syntax similar to math, but with a different operator system
- Operators can be used to add, multiply, and divide numbers
Variables and Types
- Variables are used to store values and are case-sensitive
- Numbers can be integers or floats
- Strings are sequences of characters, which can be concatenated together
- Lists are mutable sequences that can be used to store multiple values
Control Structures
- Conditional statements (“if” and “elif”) are used to make decisions in code
- Loops (“for” and “while”) are used to repeat actions
- An “else” clause can be used with “if” and “elif” statements
Functions
- Functions are reusable blocks of code that can be called multiple times
- Functions can take arguments and return values *_functions.py is used to define and call functions
Modules and Imports
- Modules are reusable code libraries that can be imported into other code
- The “import” statement is used to bring a module into the current code
- The “import math” statement is used to bring the math module into the current code
Exception Handling
- Errors can occur in code when syntax or runtime errors occur
- Exception handling is used to catch and handle errors in code
- The “try” and “except” keywords are used to define error handling code
More
-
The
len()
function is used to get the length of a sequence (such as a list or string) -
The
type()
function is used to get the type of an object - The “print()” function is used to output text or values to the console
- The “input()” function is used to get input from the user and store it in a variable