0% found this document useful (0 votes)
15 views34 pages

Python 1

The document outlines a computer programming course led by instructor Muhayimana Jules, detailing class evaluation methods, student behavior expectations, and course content covering programming languages, algorithms, and system development. It explains the differences between low-level and high-level programming languages, their advantages and disadvantages, and the programming methodology including problem analysis, design, coding, and testing. Additionally, it discusses the importance of algorithms and flowcharts in programming, providing examples of pseudocode and flowchart representations.

Uploaded by

provirw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views34 pages

Python 1

The document outlines a computer programming course led by instructor Muhayimana Jules, detailing class evaluation methods, student behavior expectations, and course content covering programming languages, algorithms, and system development. It explains the differences between low-level and high-level programming languages, their advantages and disadvantages, and the programming methodology including problem analysis, design, coding, and testing. Additionally, it discusses the importance of algorithms and flowcharts in programming, providing examples of pseudocode and flowchart representations.

Uploaded by

provirw
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Computer Programming

About instructor

MUHAYIMANA Jules
Office : ICT Directorate

About instructor AVAILABILITY:


Monday to Friday 8 am - 5 pm
Email: [Link]@[Link]
Class Evaluation
❑ Final grade on 100
❑ Passing grade >= 50
❑ Final Exam accounts for 40% of the final grade
✓ Home assignments
✓ In-class surprise quizes
✓ Online Quiz(es)
✓ Paper presentation
❑ All other class assignments account for 60% of the final grade

 Your responsibility: submit assignment on time and in the format requested. Do not expect
deadline extension. Arrange to submit your assignment on time. If you do not understand an
assignment, ask for clarification soon enough
Student Behavior
✓ Class starts at 8:00 am and ends at 1:00pm
✓ Class attendance is mandatory
✓ Student must be in class on time
✓ Assignments submitted after the deadline will not be graded
✓ Feel free to interrupt and ask questions
Course content
1. Introduction to Computer Programming 4. Control Structures

✓ History and importance of Python ✓ if, else, elif


✓ Computer Languages ✓ Loops: for, while, do...while
✓ Interpretation process and basic syntax ✓ break, continue
✓ Programming Methodology and algorithm 5. Functions
✓ Software development steps ✓ Function declaration, definition, and calling
✓ IDEs and Interpreter (e.g., Pycharm, VS code) ✓ Return values and parameters
✓ Scope and lifetime of variables
[Link] Types and Variables 6. Dictionary and list

✓ Keywords and identifiers ✓ One-dimensional and multi-dimensional arrays


✓ Variable declaration and initialization ✓ String handling (char arrays)
✓ Data types (int, float, string, tuple)

3. Operators and Expressions

✓ Arithmetic operators
✓ Arithmetic Operators
✓ Relational (Comparison) Operators
✓ Logical Operators
✓ Assignment Operators
✓ Membership Operators
✓ Identity Operators
COMPUTER LANGUAGES
❖ In order to communicate with the computer user also needs to have a
language that should be understood by the computer.
❖ For this purpose, different languages are developed for performing different
types of work on the computer.
❖ Basically, languages are divided into two categories according to their
interpretation.
Low Level Languages
✓ Low level computer languages are machine codes or close to it.
✓ Computer cannot understand instructions given in high level languages or in English.
✓ It can only understand and execute instructions given in the form of machine
language i.e. language of 0 and 1.
✓ There are two types of low level languages:
✓ Machine Language
✓ Assembly Language
Machine Language
 It is the lowest and most elementary level of Programming language and was the
first type of programming language to be Developed.
 Machine Language is basically the only language which computer Can
understand.
 In fact, a manufacturer designs a computer to obey just one Language, its
machine code, which is represented inside the computer by a String of binary
digits (bits) 0 and 1.
 The symbol 0 stands for the absence of Electric pulse and 1 for the presence of an
electric pulse .
 Since a computer is Capable of recognizing electric signals, therefore, it
understand machine Language.
Machine Language

 Advantages of Machine Language


 It makes fast and efficient use of the computer.
 It requires no translator to translate the code i.e. Directly understood by the computer
 Disadvantages of Machine Language:
 All operation codes have to be remembered
 These languages are machine dependent i.e. a particular Machine language can
be used on only one type of computer
Assembly Language
❖ It was developed to overcome some of the many inconveniences of
machine language.
❖ This is another low level but a very important language in which operation
codes and operands are given in the form of alphanumeric symbols
instead of 0‟s and l‟s.
❖ These alphanumeric symbols will be known as mnemonic codes and can
have maximum up to 5 letter combination
❖ e.g. ADD for addition, SUB for subtraction, START,LABEL etc. Because of this
feature it is also known as „Symbolic Programming Language‟.
❖ This language is also very difficult and needs a lot of practice to master it
because very small
Assembly Language

 English support is given to this language.


 The language mainly helps in compiler orientations.
 The instructions of the Assembly language will also be converted to
machine codes by language translator to be executed by the
computer.
Advantages of Assembly Language
❖ It is easier to understand and use as compared to machine language.
❖ It is easy to locate and correct errors.
❖ It is modified easily
Disadvantages of Assembly Language
❖ Like machine language it is also machine dependent.
❖ Since it is machine dependent therefore programmer Should have the
knowledge of the hardware also.
High Level Languages
❖ High level computer languages give formats close to English
language and the purpose of developing high level languages is
to enable people to write programs easily and in their own native
language environment (English).
❖ High-level languages are basically symbolic languages that use
English words and/or mathematical symbols rather than
mnemonic codes.
❖ Each instruction in the high level language is translated into many
machine language instructions thus showing one-to-many
translation
Types of High Level Languages
 Many languages have been developed for achieving different
variety of tasks, some are fairly specialized others are quite
general purpose.
These are categorized according to their use as:
❖ Algebraic Formula-Type Processing.
❖ Business Data Processing.
❖ String and List Processing
❖ Object Oriented Programming Language
❖ Visual programming language
 Algebraic Formula-Type Processing: These languages are oriented
towards the computational procedures for solving mathematical and
statistical problem

Examples are
 BASIC (Beginners All Purpose Symbolic Instruction Code).
 FORTRAN (Formula Translation).
 PL/I (Programming Language, Version 1).
 ALGOL (Algorithmic Language).
 APL (A Programming Language)
 Business Data Processing: These languages emphasize their capabilities for
maintaining data processing procedures and files handling problems.
 Examples are:
 COBOL (Common Business Oriented Language).
 RPG (Report Program Generator

 String and List Processing: These are used for string manipulation including
search for patterns, inserting and deleting characters.
 Examples are:
 LISP (List Processing).
 Prolog (Program in Logic).

 Object Oriented Programming Language: In OOP, the computer program


is divided into objects.
 Examples are:
 C++
 Java
 Visual programming language: these are designed for building Windows-
based applications
 Examples are:
 Visual Basic
 Visual Java
 Visual C

Advantages of High Level Language


❖ User-friendly
❖ Similar to English with vocabulary of words and symbols
❖ Therefore it is easier to learn.
❖ They are easier to maintain.
Disadvantages of High Level Language
❖ A high-level language has to be translated into the machine language by a
translator and thus a price in computer time is paid.
❖ The object code generated by a translator might be inefficient Compared to an
equivalent assembly language program
How a Program Works
 A computer’s CPU can only understand instructions that are written in
machine language. Because people find it very difficult to write entire
programs in machine language, other programming languages have
been invented.
 Each instruction in a program is a command that tells the CPU to perform a
specific operation. Here’s an example of an instruction that might appear
in a program: 10110000
 To you and me, this is only a series of 0s and 1s. To a CPU, however, this is
an instruction to perform an operation.1 It is written in 0s and 1s because
CPUs only understand instructions that are written in machine language,
and machine language instructions always have an underlying binary
structure.
A program is copied into main memory and then executed
When a CPU executes the instructions in a program, it is engaged in a process that is known
as the fetch-decode-execute cycle. This cycle, which consists of three steps, is repeated for
each instruction in the program. The steps are:
1. Fetch A program is a long sequence of machine language instructions. The first step of
the cycle is to fetch, or read, the next instruction from memory into the CPU.
2. Decode A machine language instruction is a binary number that represents a command
that tells the CPU to perform an operation. In this step the CPU decodes the instruction
that was just fetched from memory, to determine which operation it should perform.
3. Execute The last step in the cycle is to execute, or perform, the operation.
Compilers and Interpreters
Because the CPU understands only machine language instructions, programs that are written
in a high-level language must be translated into machine language. Depending on the
language that a program has been written in, the programmer will use either a compiler or
an interpreter to make the translation.
A compiler is a program that translates a high-level language program into a separate
machine language program. The machine language program can then be executed any
time it is needed.
The Python language uses an interpreter, which is a program that both translates and executes the
instructions in a high-level language program. As the interpreter reads each individual instruction
in the program, it converts it to machine language instructions and then immediately executes
them. This process repeats for every instruction in the program. This process is illustrated in
Figure 1-20. Because interpreters combine translation and execution, they typically do not create
separate machine language programs.
PROGRAMMING METHODOLOGY
❖ A computer is used to a solve a problem.
Steps :
1. Analyze the problem
2. Identify the variables involved
3. Design the solution
4. Write the program
5. Enter it into a computer
6 Compile the program and correct errors
7. Correct the logical errors if any
8. Test the program with data
9. Document the program
Algorithm
❖ Pseudocode: is a simplified version of programming codes, written in
plain English language and used to outline a program before its
implementation.. Pseudocode is very similar to everyday English.
❖ Algorithm: is a systematic, logical approach that provides a step-by-
step procedure for computers to solve a specific problem.
Algorithm is a step-by-step method of solving a problem.

❖ An algorithm is a step-by-step procedure or set of rules to solve a


specific problem or perform a particular task.
❖ It's like a procedure that tells a computer exactly what to do and in
what order.
Why Algorithms Matter in Programming

❖ Help to plan logic before coding


❖ Make debugging easier
❖ Allow efficient and optimized code
❖ Can be turned into flowcharts or pseudocode
❖ Make teamwork and communication easier in development
Properties of an Algorithm
1. Finiteness
 The algorithm must terminate after a finite number of steps.
 It should not go into an infinite loop.
Example: An algorithm to find the sum of two numbers must stop once the result is obtained.
2. Definiteness (Clarity)
 Every step of the algorithm must be precisely and unambiguously defined.
 There should be no confusion in the meaning or order of steps.
Example: "Add a and b" is definite, but "Do something with a and b" is vague.
3. Input
 An algorithm should have zero or more inputs, taken from a specified set of values.
 Inputs are the data the algorithm will process.
Example: Input two numbers to be added.
Properties of an Algorithm
4. Output
 The algorithm must produce at least one output.
 Output is the result of processing the input.
Example: Output the sum of the two input numbers.
5. Effectiveness
 Each step in the algorithm must be basic enough to be carried out using
known techniques.
 It should be practically possible to implement each step.
Example: “Multiply x by 2” is effective; “Make x better” is not.
Writing an algorithm
An algorithm can be written in English, like sentences and using mathematical
formulas.
 Sometimes algorithm written in English like language is Pseudo code.
Examples: To add two numbers

START
Step1: Input the numbers as x, y
Step2: sum=x + y
Step3: print sum
STOP
Finding the average of three numbers
Begin
Let a,b,c are three integers
Let d is float
Display the message “Enter any three integers:”
Read three integers and stores in a,b,c
Compute the d = (a+b+c)/3.0
Display “The avg is:” , d
End.

 For a better understanding of an algorithm, it is represented pictorially.


 The pictorial representation of an algorithm is called a Flow Chart.
 For this certain pictures are used.
Flowcharts
The pictorial representation of algorithm is called flowchart.

Uses of flow chart:

 Flow chart helps to understand the program easily.


 As different symbols are used to specify the type of operation performed,
 It is easier to understand the complex programs with the help of flowcharts.
Flowcharts symbols
Consider a problem of multiplying two numbers
Flowchart
Algorithm:
Pseudocode

start
Step1: Input the numbers as a and
b
Step2: find the product a x b
Step3: Print the result
stop
To find the highest of three numbers
Flowchart

Pseudocode
Start
Step 1: read the numbers as x ,y and z
Step 2: compare x and y
Step 3: if x > y then compare x with z and
find the greater
Step 4: Otherwise compare y with z and find
the greater
stop
System Development
System Development
1. Systems Requirements 5. System Test
Working with existing system and using proper The algorithms and flow charts developed in the
questionnaire, the problem should be explained previous steps are converted into actual
clearly. programs in the high level languages like C.
What inputs are available, what outputs are a. Compilation: The process of translating the
required and what is needed for creating program into machine code is called as
workable solution, should be understood clearly. Compilation.
2. Analysis b. Execution: It's the stage where the project
The method of solutions to solve the problem team transforms the design and
can be identified. requirements into a functional product. This
We also judge that which method gives best phase follows the planning and design
results among different methods of solution. stages and precedes the deployment and
3. Design maintenance phases.
Algorithms and flow charts will be prepared. 6. Maintenance
Focus on data, architecture, user interfaces and We are maintenance the software by updating
program components. the information, providing the security and
4. Coding license for the software.
is the process of translating the system design
into a machine-readable format using
programming languages such as Python, Java,
C#, etc

You might also like