0% found this document useful (0 votes)
14 views

Python Programming

CSEC Information Technology

Uploaded by

dykegabrielle3
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
14 views

Python Programming

CSEC Information Technology

Uploaded by

dykegabrielle3
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Information Technology

Introduction to Python Programming

May 16, 2023


Objectives:
Identify terms associated with programing
Use a python editor

● A program is a set of instructions that run on a computer.


● A python program requires accurate wording or syntax to get done.

Generations of Computers Languages
There are 5 generations of computer languages, generations 1st to 5th.

Levels of Computer Languages


1. High Level is written in natural language, ie English and french. Programs written in
natural language must be converted by a translator.
2. Low Level programming languages are machine dependent and exist in the
language of the computer i.e. all the languages in the computer, “1”, “0” The codes do
not require any translation.

Translation Program
● Compiler: A compiler is a special program that translates a programming language's
source code into machine code, bytecode or another programming language.
● Interpreter: An interpreter is a program that directly executes the instructions in a
high-level language, without converting it into machine code
● Translator: a program. that converts source code into object code.
● Source code (natural language of the programmer)
● Object code (converted source code)

Source code is the natural language that the program is written in.
Codes are created in the editor and executed in the shell.
Information Technology
Introduction to Python Programming

Errors
Syntax Errors are mistakes in the source code, such as spelling and punctuation
errors, incorrect labels, and so on, which cause an error message to be generated by
the compiler. Does not conform to the programming language. Syntax Error will
prevent the source code from converting to object code.

Logic Error is a bug in a program that causes it to operate incorrectly, but does not
prevent the program from compiling. A logic error produces unintended or
undesired/unexpected output (result) or other behaviour, although it may not
immediately be recognized as such.

A Runtime error occurs when a program you're using or writing crashes


When there is an event, a memory leak that causes a program to crash in
midstream/partway execution

May 24, 2023

Objectives:
1. Use comments
2. Set up variables
3. Take input from user
4. Use different data types in Python

Datatype Keyword Example

integer int 5, 10, 1

real float 1.1, 0.009

string str “Albert”, “A”

Comments
Comments start with a number sign followed by natural language.
To explain a block of statements or single line of statements in a program.
Comments are placed above or beside the line of statements that they are describing.
Information Technology
Introduction to Python Programming

Above the line referring to


Or above the block of statements referring to

In python
display=print.

May 29, 2023


Reading Values from the User

10100
Pseudocode total
\\to accept 3 numbers, calculate the sum, display the sum
Declaration \\declaration of identifier
Variables
Num1, num2, num3, tot ← integer
Start
Display “Enter number” \\request for first number
Read num 1
Display “Enter next number” \\request for 2nd number
Read num 2
Tot ← num 1+num2+num3 \\calculating total
Display total

Python Codes
#this program will accept 3 numbers, calculate the total, display the total.
total = 0 #total is assigned a nominal value
num1=int(input("Please enter first number"))
num2=int(input("Enter your second number"))
num3=int(input("Enter your third number")) #calculating total for the 3 numbers
total =num1+num2+num3
print (total)
Information Technology
Introduction to Python Programming

Python can enable output and input in one line


num =int(input(Please enter number)

Python requires indentation


● To identify end of line
● New line
● Decision making
● End of statements
● Grouping

In python for
equality ==
Assignment =
Comment #
Not equal !=

You might also like