Basics Of Programming Flashcards
What is Computer Science?
The study of computer software, algorithms and efficiency
Sequence of problem solving?
1) Understand the problem?
- What are the knowns and unknowns?
2) Plan how to solve the problem
- What algorithm is used to solve the problem
- What assumptions are being made?
- Is this similar to other problems?
- can the problem be split into parts?
3) Carry out your plan
- Write programs to implement algorithms?
4) Asses the result
- Does the program conform to the algorithm?
- Does the program/algorithm solve the problem?
- Is the program correct for the cases?
5) Describe what you have learnt
- So you do not make the same mistakes again
6) Document the solution
- Write a report for the uses of the program
- Write comments within the program
What is an algorithm?
Set of steps to accomplish a task
(Everyday tasks require algorithms i.e brushing teeth)
What characteristics must algorithms have?
Must be precise so:
- repeatable
- have a predictable outcome
- can be executed by different people
Elements of an algorithm
Sequence - Each step is followed by another step
Selection - a choice may be made among alternatives
Iteration - set of steps may be repeated
What is a program?
A set of instructions given to a computer, corresponding to an algorithm to solve a problem
How does a program work?
1) Ingest information from the real world
2) Process data internally
3) Send computed data back to real world
What is: - Print
- “Hello World”
An example of?
Print - Function
Hello world - Argument
What is a function?
A common task we can reuse
Syntax vs Logic error
Syntax - When the program doesn’t conform to the required structure
[ Print spelt incorrectly = PROGRAM WONT START ]
Logic - When the program runs but doesn’t work as expected
[ Must test it]
What does:
\a
\b
\n
\t
\’
\”
Produce?
- Bell
- Backspace
- Newline
- Tab
- Single Quote
- Double Quote
- Character
Integer vs Floating point
- Whole number with no fractional part = Integer
- Number with fractional part (not extremely precise) = Floating
How to do:
Addition
Subtraction
Division
Multiplication
Modulus
Integer Division
Power
What are they examples of?
/
*
% 5%2 =1
//
** a**b
Precedence of operators
( ) = High
* / % = Middle
+ - = Low
What is an identifier?
Used to name parts of code
(I.e print)
- Start with _ or letter, followed by more
- Prefered: hello_World or my_first_program
Reserved words: if, else, for