Summary of "Lab 1 intro to python"
Lab 1: Intro to Python (Deep Learning Applications)
Overview
This lab introduces students to Python and the development environment setup used in the Deep Learning Applications course. Topics covered include:
- Installing Python.
- Choosing and setting up an editor/IDE (PyCharm or VS Code) and the Microsoft Python extension.
- Installing and running Jupyter Notebook.
- Creating and running
.pyfiles. - Basic Python programming concepts:
print, strings, variables, string methods, escaping, and variable-naming rules.
Note: Python will be used for the deep-learning labs. Jupyter Notebook is recommended for interactive work.
Installation & Environment Setup
Install Python (Windows)
- Go to the official website: python.org → Downloads → Windows.
- Download the appropriate Windows installer (for most systems, the latest stable x86-64 executable installer).
-
During installation, check the box:
Add Python to PATH
-
Proceed with the installation.
Install an editor / IDE
- Options:
- PyCharm Community Edition (free)
- Visual Studio Code (VS Code)
- If using VS Code:
- Open Extensions and install the “Python” extension from Microsoft.
Install Jupyter Notebook (recommended)
Open Windows PowerShell (Run as administrator if necessary) and run the following commands:
python -m pip install --upgrade pip
python -m pip install jupyter
Launch Jupyter Notebook:
jupyter notebook
# or
python -m notebook
Keep the PowerShell/terminal session open (you can minimize it) while the notebook server runs.
Running a .py file in VS Code
- Create a folder (e.g.,
PythonProject) and a file (e.g.,hello.py). - Save the file (Ctrl+S).
- In VS Code: Terminal → New Terminal.
- Ensure the terminal path is the folder containing your file.
- Run:
python hello.py
How to Use Jupyter Notebook (basic workflow)
- In the browser UI opened by Jupyter:
- Click New → Python 3 to create a new notebook.
- Rename the notebook at the top if desired.
- Code is written in cells. Run a cell with the Run button or Shift+Enter.
- Cells allow executing segments of code independently, which is helpful for step-by-step experiments.
Core Python Language Points and Examples
- Use
print("text")to output text to the screen. Example:
print("hello")
- Each
printcall outputs on a new line by default. - Multiple statements may be placed on the same physical line using semicolons, but this is uncommon in Python.
Strings and quoting
- Single quotes:
'text' - Double quotes:
"text" - Triple quotes for multi-line strings or docstrings:
'''text'''or"""text""" - Use the opposite quote style to include quotes inside the string, e.g.:
python "He said 'hello'"
Variables
- Variables are created by assignment (no explicit type declaration). Example:
text = "hello"
- Python is case-sensitive:
Textandtextare different. - Print a variable (no quotes when printing the variable value):
print(text)
Printing variables mixed with text
-
Comma-separated printing (prints with a space separator):
python print("x =", x) -
f-strings (recommended for formatted output):
python print(f"x = {x}") -
Other formatting options exist (e.g.,
str.format()), but f-strings were emphasized.
Basic numeric example
c = 5
print(f"C = {c}") # outputs: C = 5
Common String Methods
-
Casing:
.title()— capitalize the first letter of each word.upper()— convert all letters to uppercase.lower()— convert all letters to lowercase Note: these methods return a modified copy; they do not change the original string unless reassigned.
-
Trimming whitespace:
.strip()— remove whitespace from both ends.lstrip()— remove whitespace from the left/start.rstrip()— remove whitespace from the right/end Whitespace in the middle of the string is not removed by these methods.
-
Removing specific prefix/suffix (Python 3.9+):
.removeprefix(prefix)— remove prefix if present.removesuffix(suffix)— remove suffix if present Example use case: strip"www."or".com"from a URL string.
-
Escape sequences inside strings:
\t— tab (approx. 4 or 8 spaces depending on display)\n— newline (move to a new line) Use these inside string literals to control spacing and newlines.
Variable Naming Rules
- Allowed characters: letters (a–z, A–Z), digits (0–9), underscore (
_). - Cannot contain spaces.
- Cannot start with a digit (e.g.,
1varis invalid;var1is valid). - Underscore may appear anywhere (including the beginning).
- Do not use reserved words (keywords) as variable names (e.g.,
def,print,if, etc.).
Practical Tips from the Lecture
- Use Jupyter for interactive experimentation; it’s easier for stepwise execution and immediate feedback.
- Save files often; in VS Code the unsaved icon disappears when you save (Ctrl+S).
- Each
printcommand outputs on its own line by default; to compose combined output, use commas or formatted strings. - Many more string methods exist beyond those demonstrated; the ones presented are the most commonly used in beginner work.
Corrections & Clarifications
-
Correct commands:
-
Upgrade pip:
bash python -m pip install --upgrade pip -
Install Jupyter:
bash python -m pip install jupyter -
Launch Jupyter:
bash jupyter notebook
-
-
The transcript’s “Add to Pass” refers to the installer checkbox “Add Python to PATH.”
- “F” formatting refers to Python f-strings: prefix a string with
fand use{variable}inside, e.g.f"C = {c}".
Speakers / Sources Mentioned
- Primary speaker: Course instructor / lab lecturer (unnamed).
- External tools / sources referenced:
- Official Python website (python.org)
- PyCharm Community Edition
- Visual Studio Code (VS Code) and the Microsoft Python extension
- Jupyter Notebook
- Windows PowerShell
- pip (Python package installer)
Category
Educational
Share this summary
Is the summary off?
If you think the summary is inaccurate, you can reprocess it with the latest model.