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

Fop Lec 1 Part 2

fundamentals of programming lec 1 part 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views

Fop Lec 1 Part 2

fundamentals of programming lec 1 part 2
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 29

Fundamentals of

Programming
Overview of Computer Programming

 Computer Programming?
 Computer programming, often referred to as coding or
software development, is the process of instructing a
computer to perform a task by providing it with a set of
instructions (code).
 Purpose:
 To automate tasks, solve problems, process data, and build
applications that enable computers to perform various
functions.
Computer Programming Important?

• Automation: Programming enables automation of repetitive and complex tasks,


improving efficiency.
• Problem Solving: It's a powerful tool for solving a wide range of problems.
• Innovation: It drives technological advancements and innovation in various industries.
• Career Opportunities: High demand for programmers in the job market.
Programming Languages

• Programming languages are a means to communicate with


computers. Each language has its own syntax and
semantics.
• Examples: Python, Java, C++, JavaScript, Ruby, etc.
• Choosing a Language: Depends on the task, application
domain, and personal preference.
Programming Process

• Algorithm: A step-by-step plan or set of instructions for solving a problem.

• Coding: Writing code in a specific programming language to implement the algorithm.

• Testing: Checking and debugging code for errors

• Execution: Running the program to achieve the desired result.


Fundamentals of Programming

• Variables and Data Types: Storing and manipulating data.

• Control Structures: Decision-making (if statements), looping (for, while), and


branching.

• Functions: Reusable blocks of code.

• Data Structures: Organizing and storing data efficiently (lists, arrays, dictionaries,
etc.).
Application Areas

• Web Development: Building websites and web applications (HTML, CSS, JavaScript,
etc.).
• Software Development: Creating desktop and mobile applications.
• Data Science: Analyzing and interpreting data (Python, R).
• Game Development: Developing interactive games (Unity, Unreal Engine).
• Embedded Systems: Programming for devices (IoT, microcontrollers).
Tools and Development Environments

• IDEs (Integrated Development Environments):

• Software for coding, debugging, and testing (e.g., Visual Studio Code, PyCharm).

• Version Control: Tools like Git for tracking changes in code.

• Debugging Tools: Assisting in identifying and fixing errors.


Best Practices

• Readability: Writing clean and understandable code.

• Efficiency: Optimizing code for speed and resource usage.

• Documentation: Providing comments and documentation for code clarity.

• Testing: Thoroughly testing code to ensure it works as intended.


Challenges and Problem Solving

• Common Challenges: Debugging, dealing with errors, and optimizing code.

• Problem Solving Skills: Breaking down complex problems into smaller, solvable

parts.
Typical Python Development Environment
 Python development environment consists of various tools and components that help

developers write, test, and manage Python code efficiently.

 Edit ( Write the Code)

Programmer writes program (and stores source code on disk)

 Python Interpreter:

Python is an interpreted language, and you need a Python interpreter to run

your Python scripts.


Typical Python Development Environment
 Link

Link object code with missing functions and data

Like String, Number and other types of data will combine

 Load

Transfer executable image to memory ( Load the data what will be Output)

 Execute

Execute the program one instruction at a time


Package Manager

 Python has a package manager called pip (or pip3 for Python 3)
that allows you to easily install and manage Python packages
(libraries and frameworks). You can use it to install third-party
packages like NumPy, Pandas, and Matplotlib.

 Install packages: pip install package_name

 List installed packages: pip list


Comments

 comments are used to include explanatory notes within your code

 These comments are ignored by the Python interpreter

 benefit of human readers (including yourself and other developers).

# This is a single-line comment


x = 10 # This comment explains the purpose of
this line of code
Single-Line Comments
 Single-line comments are used for adding comments on a single line of code.

 In Python, you can create a single-line comment using the # character.


Multi-Line Comments (Docstrings)

 Multi-line comments or docstrings are used to provide


documentation for modules, classes, functions, or methods.
 These are enclosed in triple quotes (either single or double) and
can span multiple lines.
Basic Program in Python
Creating Variable and Print Statement
Debugging
Bug means error
The process of removing the bugs is called
debugging in computer terminology
Types of bugs/errors
 Syntax error
 Related to the structure or grammar of a language
 When the rule is violated
 Identified by the translator
 Semantic error
 Also called logical
 Related to the logic
 It is not identified by the translator
Types of Errors…
 Syntax– wrong grammar, i.e., breaking the rules of
how to write the language
 Forgetting punctuation, misspelling keyword
 The program will not run at all with syntax errors
 Logic- the program runs, but does not produce the
expected results.
 Using an incorrect formula, incorrect sequence of
statements, etc.
Extension in python
.py file
Python basic file extension

 . ipynb file
Jupyter Note book file extension
Basic terminology
 Keywords
 keywords (also known as reserved words) are a set of
predefined words that have special meanings and purposes
within the language.
 These words cannot be used as identifiers (variable names,
function names, etc.)

 False: Represents the Boolean value False.


 None: Represents the absence of a value or a null value.
 True: Represents the Boolean value True.
 and: Used for logical conjunction (e.g., x and y returns True if
both x and y are True).
Basic terminology

 Constant

 Whose value does not change during execution


 Variable

 Which value may change during execution


 Identifiers used to hold location in memory
Data types

 Character ( 1 byte in memory)

 For letters

 Integer (int 2, short 2, unsigned int 2, long 4, unsigned long 4)

 For integer numbers

 Float (float 4, double 8, long double 10)

 For decimal numbers


Arithmetic Expressions
 Anexpression is a combination of operators
and operands
 Arithmeticexpressions compute numeric
results and make use of the arithmetic
operators: Addition +
Subtraction -
Multiplication *
Division /
Remainder %
Division and Remainder
 If both operands to the division operator (/) are integers, the result is an integer
(the fractional part is discarded)
14 / 3 equals? 4

8 / 12 equals? 0

 The remainder operator (%) returns the remainder after dividing the second
operand into the first
14 % 3 equals? 2

8 % 12 equals? 8
Assignment Operators
Assignment Sample Explanation
operator expression
+= c += 7 c=c+7

-= d -= 4 d=d-4

*= e *= 5 e=e*5

/= f /= 3 f=f/3

%= g %= 2 g=g%2
Relational operators

Relational operator are used to compare two values and


return Boolean results:
== equal to
!= not equal to
< less than
> greater than
<= less than or equal to
>= greater than or equal to

You might also like