SlideShare a Scribd company logo
1 of 10
Code Efficiency
What is
efficient code?
 A program can be written in may different ways.
 Although the different solutions achieve the same
result, programmers should try and write code that is
efficient.
 Efficient code is best explained in examples...
Repetition
This is notefficient
code.
It does the same
thing 5 times.
How could it be
made more
efficient?
Repetition
By using a loop the
code is more
efficient.
This is especially the
case when looping a
large number of
times.
1DArrays
This is notefficient
code.
It uses 6 variables to
storethenames of 6
users.
How could it be
made more
efficient?
1DArrays
A 1D array can be
used to store the 6
names.
This makes the code
more efficient.
Selection
This is notefficient
code.
It makes 4
comparisons every
time.
How could it be
made more
efficient?
Selection
By using elif and
else statements, the
code will not always
run all 4
comparisons
This makes the code
more efficient.
Logical
Operators
Splitting the if
statement into 2
like this is not the
best solution.
How else might it
be done?
Logical
Operators
It is betterpractice
to use and / or to
createa complex if
statement.
More readable code

More Related Content

What's hot

Linear Search
Linear SearchLinear Search
Linear SearchSWATHIR72
 
Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Daniyal Mughal
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generationrawan_z
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer joinNargis Ehsan
 
Sql group functions
Sql group functionsSql group functions
Sql group functionsSumit Tambe
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesDataminingTools Inc
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generationAkshaya Arunan
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysisSoujanya V
 
Character set in c
Character set in cCharacter set in c
Character set in cpolast
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generationIffat Anjum
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programmingkayalkarnan
 
The look up table (LUT)
The look up table (LUT)The look up table (LUT)
The look up table (LUT)Basel Mansour
 
Calculation of Cyclomatic complexity
Calculation of Cyclomatic complexityCalculation of Cyclomatic complexity
Calculation of Cyclomatic complexitynikshaikh786
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary SearchReem Alattas
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Shehrevar Davierwala
 

What's hot (20)

How to Share a Secret
How to Share a SecretHow to Share a Secret
How to Share a Secret
 
Compiler Design Unit 5
Compiler Design Unit 5Compiler Design Unit 5
Compiler Design Unit 5
 
Algorithms - Aaron Bloomfield
Algorithms - Aaron BloomfieldAlgorithms - Aaron Bloomfield
Algorithms - Aaron Bloomfield
 
Linear Search
Linear SearchLinear Search
Linear Search
 
Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6Type checking compiler construction Chapter #6
Type checking compiler construction Chapter #6
 
Intermediate code- generation
Intermediate code- generationIntermediate code- generation
Intermediate code- generation
 
Inner join and outer join
Inner join and outer joinInner join and outer join
Inner join and outer join
 
Sql group functions
Sql group functionsSql group functions
Sql group functions
 
MS Sql Server: Joining Databases
MS Sql Server: Joining DatabasesMS Sql Server: Joining Databases
MS Sql Server: Joining Databases
 
Intermediate code generation
Intermediate code generationIntermediate code generation
Intermediate code generation
 
Code Generation
Code GenerationCode Generation
Code Generation
 
Asymptotic analysis
Asymptotic analysisAsymptotic analysis
Asymptotic analysis
 
Character set in c
Character set in cCharacter set in c
Character set in c
 
Hash tables
Hash tablesHash tables
Hash tables
 
Lecture 12 intermediate code generation
Lecture 12 intermediate code generationLecture 12 intermediate code generation
Lecture 12 intermediate code generation
 
32 shell-programming
32 shell-programming32 shell-programming
32 shell-programming
 
The look up table (LUT)
The look up table (LUT)The look up table (LUT)
The look up table (LUT)
 
Calculation of Cyclomatic complexity
Calculation of Cyclomatic complexityCalculation of Cyclomatic complexity
Calculation of Cyclomatic complexity
 
Linear Search & Binary Search
Linear Search & Binary SearchLinear Search & Binary Search
Linear Search & Binary Search
 
Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086Assembly language programming_fundamentals 8086
Assembly language programming_fundamentals 8086
 

Similar to N5 Code Efficiency

13 javascript techniques to improve your code
13 javascript techniques to improve your code13 javascript techniques to improve your code
13 javascript techniques to improve your codeSurendra kumar
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Codeeddiehaber
 
C# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringC# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringEyob Lube
 
Designing function families and bundles with java's behaviors parameterisatio...
Designing function families and bundles with java's behaviors parameterisatio...Designing function families and bundles with java's behaviors parameterisatio...
Designing function families and bundles with java's behaviors parameterisatio...Alain Lompo
 
How can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdfHow can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdfMindfire LLC
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programmingThang Mai
 
The Economics of OptimJ
The Economics of OptimJThe Economics of OptimJ
The Economics of OptimJPatrick Viry
 
Effective Programming In Scala
Effective Programming In ScalaEffective Programming In Scala
Effective Programming In ScalaHarsh Sharma
 
YAGNI Principle and Clean Code
YAGNI Principle and Clean CodeYAGNI Principle and Clean Code
YAGNI Principle and Clean CodeLuan Reffatti
 
Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016Łukasz Koniecki
 
Cis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programmingCis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programmingHamad Odhabi
 
9 Tips to write efficient and scalable code.pdf
9 Tips to write efficient and scalable code.pdf9 Tips to write efficient and scalable code.pdf
9 Tips to write efficient and scalable code.pdfOprim Solutions
 
Functional programming is not about complicated things
Functional programming is not about complicated thingsFunctional programming is not about complicated things
Functional programming is not about complicated thingsMichael Langford
 

Similar to N5 Code Efficiency (20)

DAA Unit 1.pdf
DAA Unit 1.pdfDAA Unit 1.pdf
DAA Unit 1.pdf
 
13 javascript techniques to improve your code
13 javascript techniques to improve your code13 javascript techniques to improve your code
13 javascript techniques to improve your code
 
Writing Readable Code
Writing Readable CodeWriting Readable Code
Writing Readable Code
 
C# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoringC# coding standards, good programming principles & refactoring
C# coding standards, good programming principles & refactoring
 
Designing function families and bundles with java's behaviors parameterisatio...
Designing function families and bundles with java's behaviors parameterisatio...Designing function families and bundles with java's behaviors parameterisatio...
Designing function families and bundles with java's behaviors parameterisatio...
 
How can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdfHow can JAVA Performance tuning speed up applications.pdf
How can JAVA Performance tuning speed up applications.pdf
 
Introduction to functional programming
Introduction to functional programmingIntroduction to functional programming
Introduction to functional programming
 
The Economics of OptimJ
The Economics of OptimJThe Economics of OptimJ
The Economics of OptimJ
 
Effective Programming In Scala
Effective Programming In ScalaEffective Programming In Scala
Effective Programming In Scala
 
YAGNI Principle and Clean Code
YAGNI Principle and Clean CodeYAGNI Principle and Clean Code
YAGNI Principle and Clean Code
 
Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016Java and effective programming. Is it possible? - IAESTE Case Week 2016
Java and effective programming. Is it possible? - IAESTE Case Week 2016
 
24 Multithreaded Algorithms
24 Multithreaded Algorithms24 Multithreaded Algorithms
24 Multithreaded Algorithms
 
Quick Intro to Clean Coding
Quick Intro to Clean CodingQuick Intro to Clean Coding
Quick Intro to Clean Coding
 
Lecture No 13.ppt
Lecture No 13.pptLecture No 13.ppt
Lecture No 13.ppt
 
Cis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programmingCis 1403 lab1- the process of programming
Cis 1403 lab1- the process of programming
 
12.6-12.9.pptx
12.6-12.9.pptx12.6-12.9.pptx
12.6-12.9.pptx
 
Codings Standards
Codings StandardsCodings Standards
Codings Standards
 
9-Coding.ppt
9-Coding.ppt9-Coding.ppt
9-Coding.ppt
 
9 Tips to write efficient and scalable code.pdf
9 Tips to write efficient and scalable code.pdf9 Tips to write efficient and scalable code.pdf
9 Tips to write efficient and scalable code.pdf
 
Functional programming is not about complicated things
Functional programming is not about complicated thingsFunctional programming is not about complicated things
Functional programming is not about complicated things
 

More from Forrester High School (20)

Program Design
Program DesignProgram Design
Program Design
 
Database Evaluation
Database EvaluationDatabase Evaluation
Database Evaluation
 
Testing SQL
Testing SQLTesting SQL
Testing SQL
 
SQL
SQLSQL
SQL
 
Database Query Design
Database Query DesignDatabase Query Design
Database Query Design
 
Data Dictionary
Data DictionaryData Dictionary
Data Dictionary
 
Compound Keys
Compound KeysCompound Keys
Compound Keys
 
Entity Occurrence Diagrams
Entity Occurrence DiagramsEntity Occurrence Diagrams
Entity Occurrence Diagrams
 
Entity Relationship Diagrams
Entity Relationship DiagramsEntity Relationship Diagrams
Entity Relationship Diagrams
 
Database Analysis
Database AnalysisDatabase Analysis
Database Analysis
 
Software Evaluation
Software EvaluationSoftware Evaluation
Software Evaluation
 
Software Testing
Software TestingSoftware Testing
Software Testing
 
Standard Algorithms
Standard AlgorithmsStandard Algorithms
Standard Algorithms
 
File Handling
File HandlingFile Handling
File Handling
 
Python Predefined Functions
Python Predefined FunctionsPython Predefined Functions
Python Predefined Functions
 
Python Substrings
Python SubstringsPython Substrings
Python Substrings
 
Variable Scope
Variable ScopeVariable Scope
Variable Scope
 
Sub-programs
Sub-programsSub-programs
Sub-programs
 
Records in Python
Records in PythonRecords in Python
Records in Python
 
Parallel arrays in python
Parallel arrays in pythonParallel arrays in python
Parallel arrays in python
 

Recently uploaded

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxDr. Ravikiran H M Gowda
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxVishalSingh1417
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxJisc
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...Poonam Aher Patil
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - Englishneillewis46
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17Celine George
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.pptRamjanShidvankar
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptxMaritesTamaniVerdade
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsTechSoup
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentationcamerronhm
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the ClassroomPooky Knightsmith
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxAreebaZafar22
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsKarakKing
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jisc
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024Elizabeth Walsh
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxDenish Jangid
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxCeline George
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibitjbellavia9
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...Nguyen Thanh Tu Collection
 

Recently uploaded (20)

REMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptxREMIFENTANIL: An Ultra short acting opioid.pptx
REMIFENTANIL: An Ultra short acting opioid.pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
Wellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptxWellbeing inclusion and digital dystopias.pptx
Wellbeing inclusion and digital dystopias.pptx
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Fostering Friendships - Enhancing Social Bonds in the Classroom
Fostering Friendships - Enhancing Social Bonds  in the ClassroomFostering Friendships - Enhancing Social Bonds  in the Classroom
Fostering Friendships - Enhancing Social Bonds in the Classroom
 
ICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptxICT Role in 21st Century Education & its Challenges.pptx
ICT Role in 21st Century Education & its Challenges.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)Jamworks pilot and AI at Jisc (20/03/2024)
Jamworks pilot and AI at Jisc (20/03/2024)
 
FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024FSB Advising Checklist - Orientation 2024
FSB Advising Checklist - Orientation 2024
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
How to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptxHow to setup Pycharm environment for Odoo 17.pptx
How to setup Pycharm environment for Odoo 17.pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
80 ĐỀ THI THỬ TUYỂN SINH TIẾNG ANH VÀO 10 SỞ GD – ĐT THÀNH PHỐ HỒ CHÍ MINH NĂ...
 

N5 Code Efficiency