Module 7.1- Introduction to Programming Flashcards

(8 cards)

1
Q

What is Programming?

A
  • process of creating instructions that a computer follows to perform tasks
  • these instructions are written in a specific language that computers can interpret and execute
  • programming is what makes everything from websites to mobile apps work
  • whether it’s calculating data, playing videos, or managing your email, programming tells the computer what to do and how to do it
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Key Concepts in Programming

A
  • Code- written instructions that tell the computer how to perform specific tasks
  • code is written in programming languages like Python, Java, or C++
  • Programs- a collection of code that executes a specific task e.g. Microsoft Word or Google Chrome are programs built using code
  • Algorithms- step-by-step instructions for solving a problem or completing tasks
  • in programming, algorithms define the logic behind the code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

DRY (Coding Principle)

A

(Don’t Repeat Yourself)

  • this principle encourages programmers to avoid writing the same code multiple times
  • instead, you can create reusable functions or modules that can be used throughout your program
  • this makes your code cleaner and reduces errors
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

KISS (Coding Principle)

A

Keep It Simple, Stupid)

  • this principle suggests keeping code as simple as possible
  • complex code is harder to maintain and more prone to bugs
  • by keeping things simple, you make your code more readable and easier to troubleshoot
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Readability (Coding Principle)

A
  • well-written code should be easy for other programmers (and your future self) to read and understand
  • this means using meaningful names for variables and functions, writing comments to explain what your code does, and organising your code logically
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Naming Conventions

A
  • Descriptive Names- variables and functions should have meaningful names that describe their purpose
  • instead of naming a variable x, call it totalPrice or UserName to clearly indicate what it stores
  • CamelCase- in many languages, variables and function names follow the camelCase convention, where the first word is lowercase, and each subsequent word starts with a capital letter e.g. userName or calculateTotal
  • Avoiding Reserved Words- programming languages have certain reserved words (like if, else, for) that you can’t use as variable or function names
  • always avoid using these in your code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Methodologies: Object-Oriented Programming (OOP)

A
  • Objects- these are instances of classes and represent entities in a program
    e.g. a car (object) in a driving simulation could have properties like color, speed, and fuel level, as well as actions (methods) like accelerate and brake
  • Classes- a class is like a blueprint for creating objects
    e.g. a car class would define the structure for all car objects, including their properties and methods
  • Inheritance- OOP allows for inheritance, where one class (like SportsCar) can inherit properties and methods from another class (like Car), adding its own unique features
  • OOP makes code more modular, easier to maintain, and reusable across different parts of a program
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Importance of Code Documentation

A
  • Comments- add comments within your code to explain complex logic or why certain decisions were made
  • comments should be brief and placed where they add the most value
  • Readme Files- for larger projects, a Readme file provides an overview of the program, including how to install, run, and use it
  • Function and Class Descriptions- when writing functions or classes, include a description of what they do, their inputs (parameters), and their outputs
  • e.g. if you write a function that calculates a discount, adding a comment like # this function calculates a 10% discount on the total price helps future developers (or yourself) understand its purpose at a glance
How well did you know this?
1
Not at all
2
3
4
5
Perfectly