Chapter 1 - Python Recap & Intro to Django
Chapter 1 - Python Recap & Intro to Django
Python Review
Python Syntax
● Python is a dynamically-typed language i.e. a variable does not need to be
declared with a type and one variable can take on different data types.
● Tuples
○ An immutable ordered collection of elements (cannot be modified after
creation, to put it simply)
Sets and dictionaries
● Sets
○ An unordered collection of unique elements
○ Can be created from other iterables like lists, strings and tuples
● Dictionaries
○ Store key-value pairs. The key can only be hashable data types like
numbers, strings or tuples.
○ The values can be any Python object
Conditionals
● Conditional statements control the flow of execution
Loops
● Python offers for loops and while loops. You can also add an else statement to
the end of a loop.
● Both loops support break and continue.
For loop While loop
Functions
● Functions allow code
reusability
● Python functions can accept 0
or more arguments and even
permit the use of placeholders
(*args, **kwargs)
● Functions can also return
multiple values
Django
Installation
and Setup
Django Installation
● Before getting started, please create a new folder on your computer for this
course titled Advanced_OOP. Please take note of where this folder is located.
● Now open a terminal and type the pip command to install django: pip install
django or python -m pip install django
● Open a terminal in the Exercises folder created above. We are going to create
our first django project here
● Write a function that takes a name as input and returns "Hello, !".
● Write a program that asks for a user's age and prints if they are a minor or an
adult.
● Use the `math` module to compute the square root of a number entered by
the user.
● Use a regular expression to extract all email addresses from a given text.