Lecture 1
Lecture 1
INTRODUCTION
A S S O C . P R O F. D R . R A S H I D A H F U N K E O L A N R E W A J U
ASSESSMENT
DISTRIBUTION
SEM 2 2023/2024 SECT 1 & SECT 2( 10-11.20am, 2-3.20pm)
Python - IDLE
Learning Environment) is an
integrated development environment
(IDE) for Python. The Python
installer for Windows contains the
IDLE module by default .
I D L E i s n o t a va i l a b l e by d e fa u l t i n
Python distributions for Linux. It
needs to be installed using the
respective package managers.
Execute the following command to
install IDLE on Ubuntu:
$ sudo apt-get install idle
IDLE can be used to execute a single statement just like Python Shell and also to
create, modify, and execute Python scripts. IDLE provides a fully-featured text
editor to create Python script that includes features like syntax highlighting,
autocompletion, and smart indent. It also has a debugger with stepping and
breakpoints features.
To start an IDLE interactive shell, search for the IDLE icon in the start menu and
double click on it.
Variables and Simple
Data Types
Python Variables and Data Types
What Really Happens When You Run hello_world.py
Let’s take a closer look at what Python does when you run
hello_world.py.
As it turns out, Python does a fair amount of work, even
when it runs a simple program:
Breaking some of these rules will Variable names should be short but
descriptive. For example, name is better than
cause errors; other guidelines just n, student_name is better than s_n, and
help you write code that’s easier to name_length is better than
read and understand. length_of_persons_name.
Be sure to keep the following variable Be careful when using the lowercase letter l
rules in mind: and the uppercase letter O because they
could be confused with the numbers 1 and 0.
VARIABLES Avoiding Name Errors When Using Variables
We’ll write some code that generates an error on purpose.
Enter the following code, including the misspelt word
mesage shown in bold:
DATA TYPES: For example, you might want two variables to represent a first name and
a last name respectively, and then want to combine those values to
display someone’s full name:
STRINGS
One kind of error that you might see with some regularity is a syntax
error.
DATA TYPES: A syntax error occurs when Python doesn’t recognize a section of your
You can add (+), subtract (-), multiply (*), and divide (/)
DATA TYPES: integers in Python.
DATA TYPES: This term is used in most programming languages, and it refers
to the fact that a decimal point can appear at any position in a
NUMBERS number.
When you divide any two numbers, even if they are integers that
result in a whole number, you’ll always get a float.
DATA TYPES: If you mix an integer and a float in any other operation, you’ll
NUMBERS get a float as well
When you’re writing long numbers, you can group digits using
DATA TYPES: underscores to make large numbers more readable.
NUMBERS When you print a number that was defined using underscores, Python
prints only the digits.
You can assign values to more than one variable using just a
DATA TYPES: single line.
NUMBERS This can help shorten your programs and make them easier to
read; you’ll use this technique most often when initializing a set
of numbers.