SlideShare a Scribd company logo
1 of 53
Introduction to
Coding
Grade VII
Version 1.0
Ethics of coding
• Be honest and trustworthy
• Give proper credit to another
person’s work
• Be competitive, but in a
professional manner
• Act professionally and
ethically always.
• Respect the privacy of others
• Honor confidentiality
Chapter 1: Variables in Real Life
This chapter aims at teaching students how
variables can be used in real life.
• We will learn how to initialize variables in
programming
• How to validate user input and performing
mathematical operations of different data types
What is variable initialization?
To use variables in
programming, we need
to create the variables
and assign it a reference
in computer memory.
Once we create a
variable, we also need
to assign it a value
before it is used at all.
This process of
assigning a value to
variable is called as
Initialization.
Variable Initialization Contd..
• A variable that is not initialized never has a defined value.
• Such a variable cannot be used until it is assigned with certain value.
• In a case where a variable is declared (read – created) but it is not initialized,
we can assign it a value in later steps using assignment operators.
Note: In some programming
languages like python, there is no
command to declare variables.
A variable is created the moment
you first assign a value to it.
Example of declaring
variables in python
a = 5
b = “Hello”
Data types in programming
Below are some basic data types available in Python:
• Integer
• Floating-Point Number
• String
• Boolean
Different data
types in
programming
• Integer is a data type used to define integer variables. Integers
can be of any length.
• They can be any positive or negative whole number.
Integer
• A floating-point number in Python is used to define decimal
numbers and is accurate up to 15 decimals places.
Floating number
• A string in Python is a sequence of Unicode characters. It is used
to define any form of strings ex. Text, Alphanumeric etc.
• In Python, we can use single quotes, double quotes or triple
quotes to define strings.
• Multi-line strings in Python can be represented using triple
quotes..
String
• Boolean data in Python is used to define Boolean variables.
Boolean variables can hold only two values in it, either “true” or
“false”.
Boolean
Data types in
programming
How to validate user input in programming?
• An important part of making sure that your program works fine is to
validate that the user enters valid values in the places where you are
expecting an input from the user.
• Similarly, in programming, whenever you create a variable with a specific
data type, and you are expecting a user to enter a certain value in that data
type, you should make sure that the user enters the right type of value,
which won’t cause any error during program execution.
• Any deviation of data type in the user's input will result in an error by
program.
• A very common way of validating user input in flagging out the wrong input.
Performing Math Operations in
Programming
Now that we have understood how to declare and initiate a variable and how validate
the user input, let us now understand how we can perform mathematical operations
of these variables.
In programming there are following operations that you can perform on variables:
• Addition
• Subtraction
• Multiplication
• Division
• Modulus
Syntax for
different
Mathematical
Operations
• Addition operation is used to perform mathematical addition of
two variables.
• In programming, we refer to “+” as a symbol of addition.
Addition
• Subtraction operation is used to perform mathematical
subtraction of two variables.
• In programming, we refer to “-” as a symbol of subtraction.
Subtraction
• Multiplication operation is used to perform the mathematical
multiplication of two variables.
• In programming, we refer to “*” as a symbol of multiplication.
Multiplication
• Division operation is used to perform the mathematical division
of two variables.
• In programming, we refer to “/” as a symbol of division.
Division
• Modulus operation is used to perform the mathematical
remainder of two variables.
• In programming, we refer to “%” as a symbol of modulus.
Modulus
Math Operations
in Programming
Chapter 2: Sequencing with block
coding
At the end of this this chapter you will understand
sequencing in programming. You will know:
• What is sequencing?
• Why is it important to follow a sequence in
programming?
• How to reduce steps in a sequence with loops
and conditional operators?
Recap of Loops
• In programming, repetition of a line or a block of code is also known as iteration.
• A loop is an algorithm which executes a block of code multiple times till the time a
specified condition is met.
• The break statement modifies the normal flow of execution while it terminates the
existing loop and continues execution of the statement following that loop.
• Whenever a program encounters a continue statement, the control skips the
execution of remaining statements inside the loop for the current iteration and jumps
to the beginning of the loop for the next iteration.
• When there is a loop inside another loop, it is called a nested loop.
What is a sequence?
• A sequence is a list of activities that
are done one after another.
• Sequencing refers to the specific
order in which we need to perform
the activities in order to get the
desired output.
• When creating algorithms or
programs, the instructions are
presented in a specific correct order.
• A sequence can contain any number
of instructions, but each instruction
must be run in the order they are
presented
• No instruction can be skipped.
Example of Sequencing
To understand concept of sequencing in
programming, look at the algorithm to swap two
numbers:
• Over here, to reach the final output, you need
to follow the algorithm step by step.
• First, Read the two numbers that needs to be
swapped. Then, assign value of num1 to a
temporary variable called “temp”. Next, assign
value of num2 to num1. Later, assign value of
“temp” to num2. Finally, Print the values of
num1 and num2 which are now swapped.
Step 1: Start
Step 2: READ num1, num2
Step 3: temp = num1
Step 4: num1 = num2
Step 5: num2 = temp
Step 6: PRINT num1, num2
Step 7: Stop
Example of Selection
• In this pseudocode we will check if age entered
by the user is of a senior citizen or not. A
person is a senior citizen if his age is above 60
years old.
• If you follow the sequence of pseudocode, you
will see that the program makes a “selection”
of which flow to enter depending on the age
defined in the program.
• If the age is more than or equal to 60, the
program enters the if block. If the age is less
than 60, the program enters else block.
int age = 61;
if (age>=60)
print(“Person is a senior
citizen”);
else
print(“Person is not a senior
citizen”);
Example of Iteration
• In programming, loops follow the iteration
depending on the condition. Every loop
iterates at least once if not more.
• Consider a program to print all the natural
numbers from 1 to 100.
• As you can see in the flow chart the flow of the
program will repeat or iterate for each number
from 1 to 100.
• For every single iteration it will check for the
condition and take the appropriate workflow. It
will repeat the block of code for multiple times
till the specified condition is achieved.
What is a bug?
Bug is a terminology used to
describe any unexpected
problem in your program. Any
deviation in the expected and
actual output of the program is
known as a bug.
Example of a bug
An easy example of a bug can be turned as follows:
• Suppose you create a boat which is expected to sail
in ocean.
• Now when the boat is ready and you try to sail it in
the water, you realize that there is a small hole in the
bottom on the boat from where water is seeping in.
• This water seeping in the boat at a slow speed may
create a problem for the boat in the long run.
• Thus, this hole in the bottom of the boat can be
termed as a “bug” in programming.
Different
types of loops
• For Loop is needed for iterating over a sequence. A for loop
executes for a specific number of times.
For Loop
• The While Loop can execute a set of commands till the condition
is true. While Loops are also called conditional loops.
• Once the condition is met then the loop is finished.
While Loop
• Any loop in program may contain another loop inside it. When
there is a loop inside another loop, it is called as a nested loop.
• How it works is that first success condition of outer loop
triggers the inner loop which runs and reaches completion. This
combination of loops inside loop is helpful while working with
requirements where user wants to work of multiple conditions
simultaneously. There is no restriction on how many loops can
be nested inside a loop.
Nested Loop
Types of Loops
Sequencing with loops and conditionals
Two important pillars of algorithms are:
• Selections
• Iterations
Loops in algorithms help in:
• Reducing the number of steps
• Reusing specific parts of the code
Where can you use sequencing with
loops and conditionals?
In real life, complex
algorithms can have
hundreds, if not
thousands, of steps in a
sequence.
However, often while
working on a sequence,
you will notice that certain
activities in the sequence
are repeated.
We can reduce the
number of steps of the
sequence by using a loop
along with certain
conditions to check when
the loop should stop.
Chapter 3: Fun with functions
At the end of this this chapter you will understand
use of functions in programming. You will know:
• Usefulness of using functions in code.
• How to define and call a function.
• Parameters in a function.
• Different type of values returned by a function.
• What are Events?
• What are Event Handlers?
What are functions?
• If there is a block of code that you want
your computer to repeat lots of times, then
you might want to use a function
• A function is a block of code made up of a
set of steps that results in a single specific
action
• All programming functions have input and
output.
• The function contains instructions used to
create the output from its input.
• It’s like a cow that eats grass (the input)
which its body turns into milk which a dairy
farmer then milks (the output).
Example of calling a function without parameters
Example of calling a function with single parameter
Example of calling a function to print statements
Increases readability
By making code
organized and
easy to
understand
Code reusability
increases
Redundant code
is removed and
replaced by
functions
Benefits of using
functions
Parameters and Return Types
• Variables accepted by a function to perform a set of actions
defined in its body are called function parameters
• Type of value returned by a function are called return types
What are Events?
An event is something that happens. In the
context of coding, events are a
generalization of all the things that the
program can respond to.
Some common examples of event include:
• Clicking on the button of a web page.
• A web browser fully loading a web page.
• Key press inside a desktop application.
What are Event
Handlers?
• An event handler is a piece of code
associated with an event in the code. An
event handler gets executed, when that
event occurs.
• You can say that event handler is a
routine that deals with the event,
allowing a programmer to write code
that will be executed when the event
occurs.
• In general, the event handler has the
name of the event, preceded by “on”.
For example, the event handler for the
Focus event is “onFocus”.
Chapter 4: Understanding arrays
and collections
In this chapter we will see how we can work with
large set of data in programming.
• What are arrays?
• How exactly can we iterate over collections?
• Modifying collections
What are collections?
• A collection is a container that
groups multiple items into a
single object.
• We can also retrieve and
manipulate data that is stored in
the collections.
• In real world, you can consider a
collection of cards, a telephone
directory or a mailbox to be an
example of collections
Advantages of using Collection
Collections allow programmers to group multiple items into a
common set.
Grouping of items makes it easier to identify and perform
different operations on them like retrieving and modifying data.
It increases the performance of the program.
It increases productivity and reduces operational time.
What are arrays?
• An Array is a collection of similar data type variables. Arrays do not support
different data types in same collection.
• You can make an Array of Integers as well as another Array of Strings.
• However, you cannot make an Array having Integer and Strings in same Collection.
• Consider an Array with variables of Integer Data Type stored in it.
An array can be declared in following format:
arr = [10, 20, 30, 40, 50, 60];
Arrays in programming
Limitation of Arrays
You can only store data with
same data types in an array.
The variables in an array are
always ordered sequentially with
index starting with 0
Limitations of arrays
Printing the first element of an array in Arcade
Calculating the sum of the elements of an array in
Arcade
Adding an element in an array in Arcade
How can we iterate over collections?
• Collections can consist of lists, sets, or maps. There is a lot of data that
we can store in collections. Naturally, we need to use this data or
perform modifications on this data depending on the program
requirement.
• We need to iterate through the data that is stored in these collections.
This is where the concept of Iterator comes into the picture.
• The iterators are used to provide users a uniform way of accessing
collections in a sequential manner. Whatever type of collection we are
using, we always need to traverse through the elements of these
collections to fetch the data or make any modifications to that data.
Modifying collections
• Programming facilitates multiple ways of modifying the data stored in
collections.
• Not every collection can be modified and there is a limitation on what can
be modified in a collection.
• Modifying a collection's elements while iterating through that collection is
not allowed and throws an error in the program.
• We cannot directly add or remove elements while iterating through the
collection that includes them.
Chapter 5: Hello world with Code
At the end of this this chapter you will understand
the basics of a programming language. You will
know:
• What is a programming language?
• What are the types of programming language?
• What is the basic syntax for writing a Python
program?
What is a Programming
language?
• A computer program is a set of instructions that is
given to a computer to execute.
• A programming language is a tool we use to write
instructions for computers to follow.
• Computers can only understand binary strings of 1s
and 0s.
• All modern programming languages, are made up of
a series of syntax and symbols that act as a bridge
that allows humans to translate their thoughts into
instructions that computers can understand.
Low Level
Programming
Languages
Programming languages are of
two types, high-level
languages and low-level
languages.
A low-level programming
language is one that is made
to be easily understood by the
computer.
They include machine code
and assembly language, both
of which instruct computer
hardware components to carry
out instructions directly.
However, low-level
programming languages are
difficult to learn and time-
consuming to code.
High Level
Programming
Languages
A high-level programming language is
made to help human programmers
communicate easily to the computer.
Some examples of high-level
programming languages include C, Java,
Python.
These languages are usually compiled or
converted into low-level programming
languages so that they can be executed
directly.
The person who invented the concept of
a compiler was Grace Hopper,
sometimes called "Amazing Grace".
High Level
Programming
Languages
Selection Sort Technique
• Selection Sort is one of the type of sorting techniques.
• Suppose an array A with N elements is in the memory. Selection sort works
as follows:
• First, find the smallest element in the list and put it in the first position.
Then, find the second smallest element in the list and put it in the
sorted position and so on.
• Let us try to sort Array = {3, 2, 11, 7} in ascending order using selection
sort.
Selection sort technique
Step 1: For i=0
Step 2: For i=1
Step 3: For i=2
Step 4: For i=3
The loop gets terminated as “i” becomes 2.
The final state of array after loop is terminated looks like above.
What are variables and data types in programming?
• Variables are used by programmers to store values.
• Whenever a variable is created, Python assigns a spot to it so that
its value can be stored till the program runs
• We can store lots of different types of information in a variable.
• For example, we can store a number, text, or a list of items. We
can also change the value assigned to a variable while the program
is running.
Thank You

More Related Content

Similar to Introduction to Coding with Ethics and Sequencing

Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structureSelf-Employed
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vbSalim M
 
CPP11 - Function Design
CPP11 - Function DesignCPP11 - Function Design
CPP11 - Function DesignMichael Heron
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdfNayanChandak1
 
Cis 1403 lab5_loops
Cis 1403 lab5_loopsCis 1403 lab5_loops
Cis 1403 lab5_loopsHamad Odhabi
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartPrasanna R Kovath
 
Cse115 lecture03problemsolving
Cse115 lecture03problemsolvingCse115 lecture03problemsolving
Cse115 lecture03problemsolvingMd. Ashikur Rahman
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Shipra Swati
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and importiamluqman0403
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)Yogesh Deshpande
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statementsankurkhanna
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Dr. Pankaj Agarwal
 
2.2 Demonstrate the understanding of Programming Life Cycle
2.2 Demonstrate the understanding of Programming Life Cycle2.2 Demonstrate the understanding of Programming Life Cycle
2.2 Demonstrate the understanding of Programming Life CycleFrankie Jones
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slidesluqman bawany
 

Similar to Introduction to Coding with Ethics and Sequencing (20)

Algorithm and C code related to data structure
Algorithm and C code related to data structureAlgorithm and C code related to data structure
Algorithm and C code related to data structure
 
Error handling and debugging in vb
Error handling and debugging in vbError handling and debugging in vb
Error handling and debugging in vb
 
CPP11 - Function Design
CPP11 - Function DesignCPP11 - Function Design
CPP11 - Function Design
 
Algorithm Analysis.pdf
Algorithm Analysis.pdfAlgorithm Analysis.pdf
Algorithm Analysis.pdf
 
Small Basic - Branching and Loop
Small Basic - Branching and LoopSmall Basic - Branching and Loop
Small Basic - Branching and Loop
 
Cis 1403 lab5_loops
Cis 1403 lab5_loopsCis 1403 lab5_loops
Cis 1403 lab5_loops
 
Basic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chartBasic syntax : Algorithm,Flow chart
Basic syntax : Algorithm,Flow chart
 
Cse115 lecture03problemsolving
Cse115 lecture03problemsolvingCse115 lecture03problemsolving
Cse115 lecture03problemsolving
 
An Introduction To Python - WHILE Loop
An Introduction To  Python - WHILE LoopAn Introduction To  Python - WHILE Loop
An Introduction To Python - WHILE Loop
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
 
Java developer trainee implementation and import
Java developer trainee implementation and importJava developer trainee implementation and import
Java developer trainee implementation and import
 
FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)FPL -Part 2 ( Sem - I 2013)
FPL -Part 2 ( Sem - I 2013)
 
Unit 1 psp
Unit 1 pspUnit 1 psp
Unit 1 psp
 
C programming
C programmingC programming
C programming
 
Function in Python
Function in PythonFunction in Python
Function in Python
 
Program concep sequential statements
Program concep sequential statementsProgram concep sequential statements
Program concep sequential statements
 
Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis Introduction to Algorithms Complexity Analysis
Introduction to Algorithms Complexity Analysis
 
2.2 Demonstrate the understanding of Programming Life Cycle
2.2 Demonstrate the understanding of Programming Life Cycle2.2 Demonstrate the understanding of Programming Life Cycle
2.2 Demonstrate the understanding of Programming Life Cycle
 
C- language Lecture 4
C- language Lecture 4C- language Lecture 4
C- language Lecture 4
 
Introduction to c first week slides
Introduction to c first week slidesIntroduction to c first week slides
Introduction to c first week slides
 

Recently uploaded

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesSinan KOZAK
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...Fwdays
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksSoftradix Technologies
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machinePadma Pradeep
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Neo4j
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsPrecisely
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfjimielynbastida
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Patryk Bandurski
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsMark Billinghurst
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Alan Dix
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfngoud9212
 

Recently uploaded (20)

#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
Unblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen FramesUnblocking The Main Thread Solving ANRs and Frozen Frames
Unblocking The Main Thread Solving ANRs and Frozen Frames
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks..."LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
"LLMs for Python Engineers: Advanced Data Analysis and Semantic Kernel",Oleks...
 
Benefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other FrameworksBenefits Of Flutter Compared To Other Frameworks
Benefits Of Flutter Compared To Other Frameworks
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Install Stable Diffusion in windows machine
Install Stable Diffusion in windows machineInstall Stable Diffusion in windows machine
Install Stable Diffusion in windows machine
 
Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024Build your next Gen AI Breakthrough - April 2024
Build your next Gen AI Breakthrough - April 2024
 
Unlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power SystemsUnlocking the Potential of the Cloud for IBM Power Systems
Unlocking the Potential of the Cloud for IBM Power Systems
 
Science&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdfScience&tech:THE INFORMATION AGE STS.pdf
Science&tech:THE INFORMATION AGE STS.pdf
 
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
Integration and Automation in Practice: CI/CD in Mule Integration and Automat...
 
The transition to renewables in India.pdf
The transition to renewables in India.pdfThe transition to renewables in India.pdf
The transition to renewables in India.pdf
 
Human Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR SystemsHuman Factors of XR: Using Human Factors to Design XR Systems
Human Factors of XR: Using Human Factors to Design XR Systems
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...Swan(sea) Song – personal research during my six years at Swansea ... and bey...
Swan(sea) Song – personal research during my six years at Swansea ... and bey...
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptxVulnerability_Management_GRC_by Sohang Sengupta.pptx
Vulnerability_Management_GRC_by Sohang Sengupta.pptx
 
Bluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdfBluetooth Controlled Car with Arduino.pdf
Bluetooth Controlled Car with Arduino.pdf
 

Introduction to Coding with Ethics and Sequencing

  • 2. Ethics of coding • Be honest and trustworthy • Give proper credit to another person’s work • Be competitive, but in a professional manner • Act professionally and ethically always. • Respect the privacy of others • Honor confidentiality
  • 3. Chapter 1: Variables in Real Life This chapter aims at teaching students how variables can be used in real life. • We will learn how to initialize variables in programming • How to validate user input and performing mathematical operations of different data types
  • 4. What is variable initialization? To use variables in programming, we need to create the variables and assign it a reference in computer memory. Once we create a variable, we also need to assign it a value before it is used at all. This process of assigning a value to variable is called as Initialization.
  • 5. Variable Initialization Contd.. • A variable that is not initialized never has a defined value. • Such a variable cannot be used until it is assigned with certain value. • In a case where a variable is declared (read – created) but it is not initialized, we can assign it a value in later steps using assignment operators.
  • 6. Note: In some programming languages like python, there is no command to declare variables. A variable is created the moment you first assign a value to it. Example of declaring variables in python a = 5 b = “Hello”
  • 7. Data types in programming Below are some basic data types available in Python: • Integer • Floating-Point Number • String • Boolean
  • 8. Different data types in programming • Integer is a data type used to define integer variables. Integers can be of any length. • They can be any positive or negative whole number. Integer • A floating-point number in Python is used to define decimal numbers and is accurate up to 15 decimals places. Floating number • A string in Python is a sequence of Unicode characters. It is used to define any form of strings ex. Text, Alphanumeric etc. • In Python, we can use single quotes, double quotes or triple quotes to define strings. • Multi-line strings in Python can be represented using triple quotes.. String • Boolean data in Python is used to define Boolean variables. Boolean variables can hold only two values in it, either “true” or “false”. Boolean Data types in programming
  • 9. How to validate user input in programming? • An important part of making sure that your program works fine is to validate that the user enters valid values in the places where you are expecting an input from the user. • Similarly, in programming, whenever you create a variable with a specific data type, and you are expecting a user to enter a certain value in that data type, you should make sure that the user enters the right type of value, which won’t cause any error during program execution. • Any deviation of data type in the user's input will result in an error by program. • A very common way of validating user input in flagging out the wrong input.
  • 10. Performing Math Operations in Programming Now that we have understood how to declare and initiate a variable and how validate the user input, let us now understand how we can perform mathematical operations of these variables. In programming there are following operations that you can perform on variables: • Addition • Subtraction • Multiplication • Division • Modulus
  • 11. Syntax for different Mathematical Operations • Addition operation is used to perform mathematical addition of two variables. • In programming, we refer to “+” as a symbol of addition. Addition • Subtraction operation is used to perform mathematical subtraction of two variables. • In programming, we refer to “-” as a symbol of subtraction. Subtraction • Multiplication operation is used to perform the mathematical multiplication of two variables. • In programming, we refer to “*” as a symbol of multiplication. Multiplication • Division operation is used to perform the mathematical division of two variables. • In programming, we refer to “/” as a symbol of division. Division • Modulus operation is used to perform the mathematical remainder of two variables. • In programming, we refer to “%” as a symbol of modulus. Modulus Math Operations in Programming
  • 12. Chapter 2: Sequencing with block coding At the end of this this chapter you will understand sequencing in programming. You will know: • What is sequencing? • Why is it important to follow a sequence in programming? • How to reduce steps in a sequence with loops and conditional operators?
  • 13. Recap of Loops • In programming, repetition of a line or a block of code is also known as iteration. • A loop is an algorithm which executes a block of code multiple times till the time a specified condition is met. • The break statement modifies the normal flow of execution while it terminates the existing loop and continues execution of the statement following that loop. • Whenever a program encounters a continue statement, the control skips the execution of remaining statements inside the loop for the current iteration and jumps to the beginning of the loop for the next iteration. • When there is a loop inside another loop, it is called a nested loop.
  • 14. What is a sequence? • A sequence is a list of activities that are done one after another. • Sequencing refers to the specific order in which we need to perform the activities in order to get the desired output. • When creating algorithms or programs, the instructions are presented in a specific correct order. • A sequence can contain any number of instructions, but each instruction must be run in the order they are presented • No instruction can be skipped.
  • 15. Example of Sequencing To understand concept of sequencing in programming, look at the algorithm to swap two numbers: • Over here, to reach the final output, you need to follow the algorithm step by step. • First, Read the two numbers that needs to be swapped. Then, assign value of num1 to a temporary variable called “temp”. Next, assign value of num2 to num1. Later, assign value of “temp” to num2. Finally, Print the values of num1 and num2 which are now swapped. Step 1: Start Step 2: READ num1, num2 Step 3: temp = num1 Step 4: num1 = num2 Step 5: num2 = temp Step 6: PRINT num1, num2 Step 7: Stop
  • 16. Example of Selection • In this pseudocode we will check if age entered by the user is of a senior citizen or not. A person is a senior citizen if his age is above 60 years old. • If you follow the sequence of pseudocode, you will see that the program makes a “selection” of which flow to enter depending on the age defined in the program. • If the age is more than or equal to 60, the program enters the if block. If the age is less than 60, the program enters else block. int age = 61; if (age>=60) print(“Person is a senior citizen”); else print(“Person is not a senior citizen”);
  • 17. Example of Iteration • In programming, loops follow the iteration depending on the condition. Every loop iterates at least once if not more. • Consider a program to print all the natural numbers from 1 to 100. • As you can see in the flow chart the flow of the program will repeat or iterate for each number from 1 to 100. • For every single iteration it will check for the condition and take the appropriate workflow. It will repeat the block of code for multiple times till the specified condition is achieved.
  • 18. What is a bug? Bug is a terminology used to describe any unexpected problem in your program. Any deviation in the expected and actual output of the program is known as a bug.
  • 19. Example of a bug An easy example of a bug can be turned as follows: • Suppose you create a boat which is expected to sail in ocean. • Now when the boat is ready and you try to sail it in the water, you realize that there is a small hole in the bottom on the boat from where water is seeping in. • This water seeping in the boat at a slow speed may create a problem for the boat in the long run. • Thus, this hole in the bottom of the boat can be termed as a “bug” in programming.
  • 20. Different types of loops • For Loop is needed for iterating over a sequence. A for loop executes for a specific number of times. For Loop • The While Loop can execute a set of commands till the condition is true. While Loops are also called conditional loops. • Once the condition is met then the loop is finished. While Loop • Any loop in program may contain another loop inside it. When there is a loop inside another loop, it is called as a nested loop. • How it works is that first success condition of outer loop triggers the inner loop which runs and reaches completion. This combination of loops inside loop is helpful while working with requirements where user wants to work of multiple conditions simultaneously. There is no restriction on how many loops can be nested inside a loop. Nested Loop Types of Loops
  • 21. Sequencing with loops and conditionals Two important pillars of algorithms are: • Selections • Iterations Loops in algorithms help in: • Reducing the number of steps • Reusing specific parts of the code
  • 22. Where can you use sequencing with loops and conditionals? In real life, complex algorithms can have hundreds, if not thousands, of steps in a sequence. However, often while working on a sequence, you will notice that certain activities in the sequence are repeated. We can reduce the number of steps of the sequence by using a loop along with certain conditions to check when the loop should stop.
  • 23. Chapter 3: Fun with functions At the end of this this chapter you will understand use of functions in programming. You will know: • Usefulness of using functions in code. • How to define and call a function. • Parameters in a function. • Different type of values returned by a function. • What are Events? • What are Event Handlers?
  • 24. What are functions? • If there is a block of code that you want your computer to repeat lots of times, then you might want to use a function • A function is a block of code made up of a set of steps that results in a single specific action • All programming functions have input and output. • The function contains instructions used to create the output from its input. • It’s like a cow that eats grass (the input) which its body turns into milk which a dairy farmer then milks (the output).
  • 25. Example of calling a function without parameters
  • 26. Example of calling a function with single parameter
  • 27. Example of calling a function to print statements
  • 28. Increases readability By making code organized and easy to understand Code reusability increases Redundant code is removed and replaced by functions Benefits of using functions
  • 29. Parameters and Return Types • Variables accepted by a function to perform a set of actions defined in its body are called function parameters • Type of value returned by a function are called return types
  • 30. What are Events? An event is something that happens. In the context of coding, events are a generalization of all the things that the program can respond to. Some common examples of event include: • Clicking on the button of a web page. • A web browser fully loading a web page. • Key press inside a desktop application.
  • 31. What are Event Handlers? • An event handler is a piece of code associated with an event in the code. An event handler gets executed, when that event occurs. • You can say that event handler is a routine that deals with the event, allowing a programmer to write code that will be executed when the event occurs. • In general, the event handler has the name of the event, preceded by “on”. For example, the event handler for the Focus event is “onFocus”.
  • 32. Chapter 4: Understanding arrays and collections In this chapter we will see how we can work with large set of data in programming. • What are arrays? • How exactly can we iterate over collections? • Modifying collections
  • 33. What are collections? • A collection is a container that groups multiple items into a single object. • We can also retrieve and manipulate data that is stored in the collections. • In real world, you can consider a collection of cards, a telephone directory or a mailbox to be an example of collections
  • 34. Advantages of using Collection Collections allow programmers to group multiple items into a common set. Grouping of items makes it easier to identify and perform different operations on them like retrieving and modifying data. It increases the performance of the program. It increases productivity and reduces operational time.
  • 35. What are arrays? • An Array is a collection of similar data type variables. Arrays do not support different data types in same collection. • You can make an Array of Integers as well as another Array of Strings. • However, you cannot make an Array having Integer and Strings in same Collection. • Consider an Array with variables of Integer Data Type stored in it. An array can be declared in following format: arr = [10, 20, 30, 40, 50, 60];
  • 37. Limitation of Arrays You can only store data with same data types in an array. The variables in an array are always ordered sequentially with index starting with 0 Limitations of arrays
  • 38. Printing the first element of an array in Arcade
  • 39. Calculating the sum of the elements of an array in Arcade
  • 40. Adding an element in an array in Arcade
  • 41. How can we iterate over collections? • Collections can consist of lists, sets, or maps. There is a lot of data that we can store in collections. Naturally, we need to use this data or perform modifications on this data depending on the program requirement. • We need to iterate through the data that is stored in these collections. This is where the concept of Iterator comes into the picture. • The iterators are used to provide users a uniform way of accessing collections in a sequential manner. Whatever type of collection we are using, we always need to traverse through the elements of these collections to fetch the data or make any modifications to that data.
  • 42. Modifying collections • Programming facilitates multiple ways of modifying the data stored in collections. • Not every collection can be modified and there is a limitation on what can be modified in a collection. • Modifying a collection's elements while iterating through that collection is not allowed and throws an error in the program. • We cannot directly add or remove elements while iterating through the collection that includes them.
  • 43. Chapter 5: Hello world with Code At the end of this this chapter you will understand the basics of a programming language. You will know: • What is a programming language? • What are the types of programming language? • What is the basic syntax for writing a Python program?
  • 44. What is a Programming language? • A computer program is a set of instructions that is given to a computer to execute. • A programming language is a tool we use to write instructions for computers to follow. • Computers can only understand binary strings of 1s and 0s. • All modern programming languages, are made up of a series of syntax and symbols that act as a bridge that allows humans to translate their thoughts into instructions that computers can understand.
  • 45. Low Level Programming Languages Programming languages are of two types, high-level languages and low-level languages. A low-level programming language is one that is made to be easily understood by the computer. They include machine code and assembly language, both of which instruct computer hardware components to carry out instructions directly. However, low-level programming languages are difficult to learn and time- consuming to code.
  • 46. High Level Programming Languages A high-level programming language is made to help human programmers communicate easily to the computer. Some examples of high-level programming languages include C, Java, Python. These languages are usually compiled or converted into low-level programming languages so that they can be executed directly. The person who invented the concept of a compiler was Grace Hopper, sometimes called "Amazing Grace". High Level Programming Languages
  • 47. Selection Sort Technique • Selection Sort is one of the type of sorting techniques. • Suppose an array A with N elements is in the memory. Selection sort works as follows: • First, find the smallest element in the list and put it in the first position. Then, find the second smallest element in the list and put it in the sorted position and so on. • Let us try to sort Array = {3, 2, 11, 7} in ascending order using selection sort. Selection sort technique
  • 48. Step 1: For i=0
  • 49. Step 2: For i=1
  • 50. Step 3: For i=2
  • 51. Step 4: For i=3 The loop gets terminated as “i” becomes 2. The final state of array after loop is terminated looks like above.
  • 52. What are variables and data types in programming? • Variables are used by programmers to store values. • Whenever a variable is created, Python assigns a spot to it so that its value can be stored till the program runs • We can store lots of different types of information in a variable. • For example, we can store a number, text, or a list of items. We can also change the value assigned to a variable while the program is running.

Editor's Notes

  1. The points mentioned in the slide are the basic principles of ethical hacking. It is essential for students to understand and follow these principles in day-to-day life in order to be a good professional as they grow in their career.
  2. This chapter aims at making students understand concept of variables and its practical implementations.
  3. Before using any variables of any data types, its important to initialize them in our program. We CANNOT use variables in a program without initializing them.
  4. Validating user input is significant as deviation in expected input and actual input can cause errors in program and cause wrong results to get generated.
  5. Programming supports all the most widely used arithmetic operations. We can apply these arithmetic operations on variables to achieve the expected output.
  6. This chapter aims at making students understand what is sequencing and how it can be applied in programming to solve difficult problems.
  7. A sequence is a series of actions that is completed in a specific order. Activity 1 is performed, then Activity 2, then Activity 3, etc., until all the actions in the sequence have been carried out.
  8. Point to be noted over here is that the steps that followed to achieve this output are in a sequence. Skipping any step from this sequence or altering the sequence will lead to errors in the program or generation of wrong output.
  9. In a program of drawing a rectangle, we had to turn right after drawing a line and we had to do so three times. We use a loop to reduce the number of steps in this exercise for the steps that are repeated numerous times.
  10. This chapter aims at making students understand the concept of functions and events and how it can be applied in programming to simplify our problems.
  11. A function is a block of organized, reusable code that can be used to perform a common, related action. Functions tend to provide better standard to your program and a higher privilege of code reusing.
  12. Out of various advantages that functions provide, we will focus on two basic advantages – Increased readability and Code reusability to make sure students understand the basic advantages first and later built up on their knowledge as they learn the programming further.
  13. Functions have the capability to accept all the data types available in programming as their parameters and return types.
  14. Events have wider applications in programming in real world. Students can use the mentioned examples to understand what are events and then think of other scenarios where they think they can apply events.
  15. For example, in MakeCode platform if you want a player to move forward when the user clicks on the forward icon you would create a code block. Over there, “on player walk” block is an event handler. Agent mode forward is the action that occurs with this event.
  16. This chapter aims at making students understand the concept of arrays and collections in programming. They get to know how to work with arrays and use them in programming.
  17. There are plenty examples where you can apply the concept of collections. Train coaches that are connected with each other, stack of plates and towels at a party are all examples of collections.
  18. These pointers of advantages of collections will help students to understand why collections will help simplify many of their coding challenges.
  19. The first element of an array always is indexed as a “0” and the total length of the array thus, is number of elements in the array – 1.
  20. It is important to keep these limitations in mind while using arrays in programming. There are ways and alternatives available in programming to over come these limitations which students will learn as they learn the programming concepts further.
  21. This chapter aims at making students understand what is a programming language, types of programming languages and basic syntax for writing a Python program.
  22. The very earliest computers were programmed by changing ones and zeros manually, alternating the circuit and the wiring. All modern programming languages, however, are made up of a series of syntax and symbols that act as a bridge that allows humans to translate their thoughts into instructions that computers can understand.
  23. Two common examples of low-level programming languages are – assembly language and machine language.
  24. Common high level programming languages are – Python, Java, Perl, PHP etc.
  25. Selection Sort technique is one of the most common sorting techniques used in programming. It helps you sort the existing list without having to create an additional list to keep the sorted elements thus allowing to save on memory space.
  26. Variables are used to store values in programming and later perform various actions on them. You can create variables of different data types available in programming to suit the program needs.