SlideShare a Scribd company logo
1 of 20
Download to read offline
C O N S T R U C T S A N D T E C H N I Q U E S A N D
T H E I R I M P L E M E N TAT I O N I N
D I F F E R E N T L A N G U A G E S 🐍
B Y O L I V E R Y O U N G
C O M M A N D W O R D S
• While
• If
• For
• Print()
• Input()
• Most languages
have the
following
keywords such
as Python,
however it
maybe worded
differently to
other
languages. For
example in Java
it maybe slightly
different.
• While ()
• If ()
• For ()
• System.out.
println()
• Input()
• Java• Python
C O N S TA N T S A N D VA R I A B L E S , L O C A L
A N D G L O B A L VA R I A B L E S
• Variable - is where to assign a value to; those values can change and be
replaced later on.
• Constants are variables that stay the same every time a program is executed.
• Constants are not expected to change.
• Python does not have any constants instead just make sure you don’t change
the value of the variable. For example: by = 50
• Java however does, for example final by = 50 which means that no matter
what, you can’t later on change that value. For example, I then later on do by
= ‘any word’ it will give an error message.
•
L O C A L VA R I A B L E S
• Local variables are just variables that
you can access within a particular
region. For example, for 🐍
qq = [1, ‘bring’, 2.2]
for pos in qq:
print pos
pos is a local variable to the for loop
and cannot be accessed outside of
that for loop block.
Another example:
def jump(x):
x = ‘’
y = ‘minger’
return x + y
I can’t access the variable x and y outside of
that function.
G L O B A L VA R I A B L E
• Global variable is a variable that can be accessed
either inside and or outside the function.
For example:
def zzzz (a):
a = 0
y = 20
return a + y
I can’t access the variable x
and y outside of that function.
But if I did this:
def zzzz (a):
global y
y = 20
a = 0
return a
zzzz()
Q = y+50
Print(Q)
S TAT E M E N T
• Assignment: is the assigning of a value to a variable. For example f = 20,
means you are assigning 20 to f, if I do f = ‘word’ later on, f becomes ‘word'.
You can also do q += 1, which means assign that addition of 1 into q, whilst
w -= 3, means assign that subtraction of 3 to w
• Input is a statement that is used to tell the computer that the user must enter
something in order continue with the program. For example in python, gg =
str(input())
• Output is a statement (in python is print) that displays or shows something
on the screen. For example, print(755)
• Sequence can contain any instructions (i.e. print, inputs etc. ) that are run in
the order they are presented. No instructions are skipped unless you specify
it to. for example:
S E Q U E N C E
raffle = [4, 5, 6, 1, 2, 5]
for numbers in raffle:
If numbers != 5:
print (numbers)
x = ‘hello’
for x in range(2,5):
   print(x)
• For example, the sequences
skips 5 because of the if
statement
O T H E R C O N S T R U C T S
D E F I N E S U B R O U T I N E S
• A procedure is a function which does not return
anything.
• A function is a block that usually returns something
• A subroutine is either a function or a procedure, i.e.,
a generic term for a collected code
P R O C E D U R E
def my_function():
   x = 13
print (x)
my_function()
def my_function(y):
   x = y + 1
return x
my_function(7)
F U N C T I O N
L O G I C A L O P E R AT O R S
A = ‘q’
B = 3
If A == ‘q’ and B == 3:
print(True)
AND ^
Uses of these: if you want something to be
both true before something happens
A = ‘q’
B = 3
If A == ‘q’ or B == 3:
print(True)
OR v
Uses of these: if you want only need one to
be true before something happens
L O G I C A L O P E R AT O R S
A = ‘q’
B = 3
If not(A == ‘q’ and B == 3):
print(True)
NOT ⌝ 
Uses of these: if you want something to be
not the case, before something happens
L O G I C A L O P E R AT O R S
A = 'q'
B = 3
if (A == 'q' and B == 3) or not(A == 'q'
and B == 3):
print(True)
Bi-conditional
<-> 
Because
L O G I C A L O P E R AT O R S
A R R AY S ( N A M E D I N P Y T H O N A S L I S T )
• Is a collection of elements, whether it be int, string or
float. It can be used for many things even calling out a
function in sequence.
• 2D arrays is list inside of a list
E X A M P L E S O F A R R AY A N D 2
D I M E N S I O N A L A R R AY
Q = [11, 12, 5, 2]
print(Q[3])
Q = [[11, 12, 5, 2], [15, 6,10]]
print(Q[2][0])
This will output 15This will output 2
F I L E H A N D L I N G
• You can connect this
to a database
I M P O RT   M Y S Q L . C O N N E C T O R
M Y _ D ATA B A S E =
M Y S Q L . C O N N E C T O R . C O N N E
C T (
  H O S T = " L O C A L H O S T " ,
  U S E R = " M Y U S E R N A M E " ,
 
PA S S W O R D = " M Y PA S S W O R D "
)
P R I N T ( M Y _ D ATA B A S E )
V = O P E N ( " D E M O F I L E 2 . T X T " , " A " )
V. W R I T E ( “ I C A N S E E T H E T R E E S . ” )
V. C L O S E ( )
# O P E N A N D R E A D T H E F I L E B Y D O I N G
T H E C O D E B E L O W
V = O P E N ( " D E M O F I L E 2 . T X T " , " R " )
P R I N T ( V. R E A D ( ) )
• You can create a .txt file.
• Write on it
• And close the file
• You can use the read function to
what is read inside of the file
F I L E H A N D L I N G
• We can use file handling when we want to write a
program that can manipulate a text file. For example,
when we want to manipulate data in it, i.e. anti-virus
program that detects a malicious code, or you just want
to remove all of the commas on the file using python
etc.
• You can also connect it to a database and transfer the
password and username to a database, which is usually
safer. So we can do some matching, if the user is in the
database already, then give an error etc.
D ATA S T R U C T U R E
• It is a way we
organise data, in a
structured way so that
we can efficiently
manipulate it later on.
• For example,
dictionary and list are
a form of data
structures in python
Q = [11, 12, 5, 2]
print(Q[3])
diction =
{ “1": "Bobby",
"2": “Sussy",
"3": “Sam” }
print(diction)
E V E N T H A N D L I N G
from tkinter import *
def singles(event):
print("Single clicks, recognised ")
def doubles(event):
print("Stopping, because double click")
import sys; sys.exit()
widget = Button(None, text='Mouse Clicks')
widget.pack()
widget.bind('<Button-1>', singles)
widget.bind('<Double-1>', doubles)
widget.mainloop()
Event handling is when
a particular function,
subroutine or method
(function in a class) in
response to an event
such as a click or
keyboard inputs.
Example, of event
handling in python.

More Related Content

What's hot

Software Project Planning 1
Software Project Planning 1Software Project Planning 1
Software Project Planning 1Gagan Deep
 
Spiral model explanation
Spiral model  explanationSpiral model  explanation
Spiral model explanationUmar Farooq
 
Pseudocode & flowchart examples
Pseudocode & flowchart examplesPseudocode & flowchart examples
Pseudocode & flowchart exampleshayrikk
 
Database systems - Chapter 1
Database systems - Chapter 1Database systems - Chapter 1
Database systems - Chapter 1shahab3
 
12th information practices mysql practice questions
12th information practices mysql practice questions12th information practices mysql practice questions
12th information practices mysql practice questionsHarish Gyanani
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQLrehaniltifat
 
Database relationship
Database relationshipDatabase relationship
Database relationshipGirija Muscut
 
STRUCTURED ANALYSIS (Software Engg.)
STRUCTURED ANALYSIS (Software Engg.)STRUCTURED ANALYSIS (Software Engg.)
STRUCTURED ANALYSIS (Software Engg.)BijoyaLaishram
 
Approaches To System Development
Approaches To System DevelopmentApproaches To System Development
Approaches To System DevelopmentHenhen Lukmana
 
Chapter 5 software design
Chapter 5 software designChapter 5 software design
Chapter 5 software designdespicable me
 
Computer programming - turbo c environment
Computer programming - turbo c environmentComputer programming - turbo c environment
Computer programming - turbo c environmentJohn Paul Espino
 

What's hot (20)

Integration
IntegrationIntegration
Integration
 
Mg6088 spm unit-2
Mg6088 spm unit-2Mg6088 spm unit-2
Mg6088 spm unit-2
 
Case tools
Case tools Case tools
Case tools
 
Software Project Planning 1
Software Project Planning 1Software Project Planning 1
Software Project Planning 1
 
Spiral model explanation
Spiral model  explanationSpiral model  explanation
Spiral model explanation
 
Pseudocode & flowchart examples
Pseudocode & flowchart examplesPseudocode & flowchart examples
Pseudocode & flowchart examples
 
Database systems - Chapter 1
Database systems - Chapter 1Database systems - Chapter 1
Database systems - Chapter 1
 
Software Engineering
Software EngineeringSoftware Engineering
Software Engineering
 
12th information practices mysql practice questions
12th information practices mysql practice questions12th information practices mysql practice questions
12th information practices mysql practice questions
 
1 - Introduction to PL/SQL
1 - Introduction to PL/SQL1 - Introduction to PL/SQL
1 - Introduction to PL/SQL
 
Spiral model
Spiral modelSpiral model
Spiral model
 
Database relationship
Database relationshipDatabase relationship
Database relationship
 
STRUCTURED ANALYSIS (Software Engg.)
STRUCTURED ANALYSIS (Software Engg.)STRUCTURED ANALYSIS (Software Engg.)
STRUCTURED ANALYSIS (Software Engg.)
 
joins in database
 joins in database joins in database
joins in database
 
Approaches To System Development
Approaches To System DevelopmentApproaches To System Development
Approaches To System Development
 
Chapter 5 software design
Chapter 5 software designChapter 5 software design
Chapter 5 software design
 
Computer programming - turbo c environment
Computer programming - turbo c environmentComputer programming - turbo c environment
Computer programming - turbo c environment
 
Sadcw 6e chapter4
Sadcw 6e chapter4Sadcw 6e chapter4
Sadcw 6e chapter4
 
Data models
Data modelsData models
Data models
 
Normalisation and anomalies
Normalisation and anomaliesNormalisation and anomalies
Normalisation and anomalies
 

Similar to Constructs and techniques and their implementation in different languages

009 Data Handling cs class 12 cbse mount litera
009 Data Handling cs class 12 cbse mount litera009 Data Handling cs class 12 cbse mount litera
009 Data Handling cs class 12 cbse mount literaRithinA1
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler DevelopmentLogan Chien
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fuclimatewarrior
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfezonesolutions
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE Saraswathi Murugan
 
Python 培训讲义
Python 培训讲义Python 培训讲义
Python 培训讲义leejd
 
Writing (Meteor) Code With Style
Writing (Meteor) Code With StyleWriting (Meteor) Code With Style
Writing (Meteor) Code With StyleStephan Hochhaus
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : PythonRaghu Kumar
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimizationg3_nittala
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Fariz Darari
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methodsPranavSB
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Languagevsssuresh
 
Ry pyconjp2015 turtle
Ry pyconjp2015 turtleRy pyconjp2015 turtle
Ry pyconjp2015 turtleRenyuan Lyu
 
Basics of Python Programming
Basics of Python ProgrammingBasics of Python Programming
Basics of Python ProgrammingManishJha237
 

Similar to Constructs and techniques and their implementation in different languages (20)

009 Data Handling cs class 12 cbse mount litera
009 Data Handling cs class 12 cbse mount litera009 Data Handling cs class 12 cbse mount litera
009 Data Handling cs class 12 cbse mount litera
 
Introduction to python
Introduction to pythonIntroduction to python
Introduction to python
 
Introduction to Compiler Development
Introduction to Compiler DevelopmentIntroduction to Compiler Development
Introduction to Compiler Development
 
Python quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung FuPython quickstart for programmers: Python Kung Fu
Python quickstart for programmers: Python Kung Fu
 
So I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdfSo I am writing a CS code for a project and I keep getting cannot .pdf
So I am writing a CS code for a project and I keep getting cannot .pdf
 
Pythonppt28 11-18
Pythonppt28 11-18Pythonppt28 11-18
Pythonppt28 11-18
 
FUNDAMENTALS OF PYTHON LANGUAGE
 FUNDAMENTALS OF PYTHON LANGUAGE  FUNDAMENTALS OF PYTHON LANGUAGE
FUNDAMENTALS OF PYTHON LANGUAGE
 
Python 培训讲义
Python 培训讲义Python 培训讲义
Python 培训讲义
 
Writing (Meteor) Code With Style
Writing (Meteor) Code With StyleWriting (Meteor) Code With Style
Writing (Meteor) Code With Style
 
Witchcraft
WitchcraftWitchcraft
Witchcraft
 
An Introduction : Python
An Introduction : PythonAn Introduction : Python
An Introduction : Python
 
Profiling and optimization
Profiling and optimizationProfiling and optimization
Profiling and optimization
 
Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02Basic Python Programming: Part 01 and Part 02
Basic Python Programming: Part 01 and Part 02
 
Functions, List and String methods
Functions, List and String methodsFunctions, List and String methods
Functions, List and String methods
 
Scala as a Declarative Language
Scala as a Declarative LanguageScala as a Declarative Language
Scala as a Declarative Language
 
Python.pptx
Python.pptxPython.pptx
Python.pptx
 
Ry pyconjp2015 turtle
Ry pyconjp2015 turtleRy pyconjp2015 turtle
Ry pyconjp2015 turtle
 
JavaFX, because you're worth it
JavaFX, because you're worth itJavaFX, because you're worth it
JavaFX, because you're worth it
 
Basics of Python Programming
Basics of Python ProgrammingBasics of Python Programming
Basics of Python Programming
 
Bt0065
Bt0065Bt0065
Bt0065
 

Recently uploaded

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonJericReyAuditor
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxAnaBeatriceAblay2
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxUnboundStockton
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 

Recently uploaded (20)

Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Science lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lessonScience lesson Moon for 4th quarter lesson
Science lesson Moon for 4th quarter lesson
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptxENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
ENGLISH5 QUARTER4 MODULE1 WEEK1-3 How Visual and Multimedia Elements.pptx
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
Blooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docxBlooming Together_ Growing a Community Garden Worksheet.docx
Blooming Together_ Growing a Community Garden Worksheet.docx
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 

Constructs and techniques and their implementation in different languages

  • 1. C O N S T R U C T S A N D T E C H N I Q U E S A N D T H E I R I M P L E M E N TAT I O N I N D I F F E R E N T L A N G U A G E S 🐍 B Y O L I V E R Y O U N G
  • 2. C O M M A N D W O R D S • While • If • For • Print() • Input() • Most languages have the following keywords such as Python, however it maybe worded differently to other languages. For example in Java it maybe slightly different. • While () • If () • For () • System.out. println() • Input() • Java• Python
  • 3. C O N S TA N T S A N D VA R I A B L E S , L O C A L A N D G L O B A L VA R I A B L E S • Variable - is where to assign a value to; those values can change and be replaced later on. • Constants are variables that stay the same every time a program is executed. • Constants are not expected to change. • Python does not have any constants instead just make sure you don’t change the value of the variable. For example: by = 50 • Java however does, for example final by = 50 which means that no matter what, you can’t later on change that value. For example, I then later on do by = ‘any word’ it will give an error message. •
  • 4. L O C A L VA R I A B L E S • Local variables are just variables that you can access within a particular region. For example, for 🐍 qq = [1, ‘bring’, 2.2] for pos in qq: print pos pos is a local variable to the for loop and cannot be accessed outside of that for loop block. Another example: def jump(x): x = ‘’ y = ‘minger’ return x + y I can’t access the variable x and y outside of that function.
  • 5. G L O B A L VA R I A B L E • Global variable is a variable that can be accessed either inside and or outside the function. For example: def zzzz (a): a = 0 y = 20 return a + y I can’t access the variable x and y outside of that function. But if I did this: def zzzz (a): global y y = 20 a = 0 return a zzzz() Q = y+50 Print(Q)
  • 6. S TAT E M E N T • Assignment: is the assigning of a value to a variable. For example f = 20, means you are assigning 20 to f, if I do f = ‘word’ later on, f becomes ‘word'. You can also do q += 1, which means assign that addition of 1 into q, whilst w -= 3, means assign that subtraction of 3 to w • Input is a statement that is used to tell the computer that the user must enter something in order continue with the program. For example in python, gg = str(input()) • Output is a statement (in python is print) that displays or shows something on the screen. For example, print(755) • Sequence can contain any instructions (i.e. print, inputs etc. ) that are run in the order they are presented. No instructions are skipped unless you specify it to. for example:
  • 7. S E Q U E N C E raffle = [4, 5, 6, 1, 2, 5] for numbers in raffle: If numbers != 5: print (numbers) x = ‘hello’ for x in range(2,5):    print(x) • For example, the sequences skips 5 because of the if statement
  • 8. O T H E R C O N S T R U C T S
  • 9. D E F I N E S U B R O U T I N E S • A procedure is a function which does not return anything. • A function is a block that usually returns something • A subroutine is either a function or a procedure, i.e., a generic term for a collected code
  • 10. P R O C E D U R E def my_function():    x = 13 print (x) my_function() def my_function(y):    x = y + 1 return x my_function(7) F U N C T I O N
  • 11. L O G I C A L O P E R AT O R S A = ‘q’ B = 3 If A == ‘q’ and B == 3: print(True) AND ^ Uses of these: if you want something to be both true before something happens
  • 12. A = ‘q’ B = 3 If A == ‘q’ or B == 3: print(True) OR v Uses of these: if you want only need one to be true before something happens L O G I C A L O P E R AT O R S
  • 13. A = ‘q’ B = 3 If not(A == ‘q’ and B == 3): print(True) NOT ⌝  Uses of these: if you want something to be not the case, before something happens L O G I C A L O P E R AT O R S
  • 14. A = 'q' B = 3 if (A == 'q' and B == 3) or not(A == 'q' and B == 3): print(True) Bi-conditional <->  Because L O G I C A L O P E R AT O R S
  • 15. A R R AY S ( N A M E D I N P Y T H O N A S L I S T ) • Is a collection of elements, whether it be int, string or float. It can be used for many things even calling out a function in sequence. • 2D arrays is list inside of a list
  • 16. E X A M P L E S O F A R R AY A N D 2 D I M E N S I O N A L A R R AY Q = [11, 12, 5, 2] print(Q[3]) Q = [[11, 12, 5, 2], [15, 6,10]] print(Q[2][0]) This will output 15This will output 2
  • 17. F I L E H A N D L I N G • You can connect this to a database I M P O RT   M Y S Q L . C O N N E C T O R M Y _ D ATA B A S E = M Y S Q L . C O N N E C T O R . C O N N E C T (   H O S T = " L O C A L H O S T " ,   U S E R = " M Y U S E R N A M E " ,   PA S S W O R D = " M Y PA S S W O R D " ) P R I N T ( M Y _ D ATA B A S E ) V = O P E N ( " D E M O F I L E 2 . T X T " , " A " ) V. W R I T E ( “ I C A N S E E T H E T R E E S . ” ) V. C L O S E ( ) # O P E N A N D R E A D T H E F I L E B Y D O I N G T H E C O D E B E L O W V = O P E N ( " D E M O F I L E 2 . T X T " , " R " ) P R I N T ( V. R E A D ( ) ) • You can create a .txt file. • Write on it • And close the file • You can use the read function to what is read inside of the file
  • 18. F I L E H A N D L I N G • We can use file handling when we want to write a program that can manipulate a text file. For example, when we want to manipulate data in it, i.e. anti-virus program that detects a malicious code, or you just want to remove all of the commas on the file using python etc. • You can also connect it to a database and transfer the password and username to a database, which is usually safer. So we can do some matching, if the user is in the database already, then give an error etc.
  • 19. D ATA S T R U C T U R E • It is a way we organise data, in a structured way so that we can efficiently manipulate it later on. • For example, dictionary and list are a form of data structures in python Q = [11, 12, 5, 2] print(Q[3]) diction = { “1": "Bobby", "2": “Sussy", "3": “Sam” } print(diction)
  • 20. E V E N T H A N D L I N G from tkinter import * def singles(event): print("Single clicks, recognised ") def doubles(event): print("Stopping, because double click") import sys; sys.exit() widget = Button(None, text='Mouse Clicks') widget.pack() widget.bind('<Button-1>', singles) widget.bind('<Double-1>', doubles) widget.mainloop() Event handling is when a particular function, subroutine or method (function in a class) in response to an event such as a click or keyboard inputs. Example, of event handling in python.