Lecture 1 - Intro To Python - Part 1
Lecture 1 - Intro To Python - Part 1
to Python
Part 1
COMP 8347
Usama Mir
Usama.Mir@unwindsor.ca
Python Basics
Topics
Introduction
Why Python
Overview of IDLE
2
Why Python?
java
py
Source: https://trends.google.com/trends/explore?date=all&geo=US&q=%2Fm%2F05z1_,%2Fm%2F07sbkfb
3
Why Python?
Used for:
•RAD and Scripting Supports object-
What we see today on
•Process text oriented programming:
our devices is because
•Display images with classes and
of Python
•Making calculations and multiple inheritance.
predictions
Dynamically typed
language: Do not have Python vs. Java?
to assign variable types
4
Notable Features of Python
5
Indentation
Python does not use brackets to structure code, instead it uses
whitespaces
Tabs are not permitted.
Four spaces are required to create a new block,
To end a block simply move the cursor four positions left.
An example: Nested loop
for i in range(5):
for j in range(10):
print(j)
print(i)
print('done')
6
IDLE
7
IDLE EXAMPLE
8
Numeric Data Types
9
Arithmetic Operators
Basic arithmetic operators: + (addition), - (subtraction), *
(multiplication), / (division)
10
Basic Input/Print
Built-in input() function accepts input from user.
Takes optional string argument to print on console
Waits for user to type response and hit Enter
If no text, user just hits enter: return empty string
Otherwise, return string containing entered text
Example: i = input(“Enter an integer: ”)
11
References
12