Basics Of Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What is Computer Science?

A

The study of computer software, algorithms and efficiency

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Sequence of problem solving?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is an algorithm?

A

Set of steps to accomplish a task

(Everyday tasks require algorithms i.e brushing teeth)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What characteristics must algorithms have?

A

Must be precise so:
- repeatable
- have a predictable outcome
- can be executed by different people

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Elements of an algorithm

A

Sequence - Each step is followed by another step

Selection - a choice may be made among alternatives

Iteration - set of steps may be repeated

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is a program?

A

A set of instructions given to a computer, corresponding to an algorithm to solve a problem

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How does a program work?

A

1) Ingest information from the real world

2) Process data internally

3) Send computed data back to real world

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is: - Print
- “Hello World”

An example of?

A

Print - Function

Hello world - Argument

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a function?

A

A common task we can reuse

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Syntax vs Logic error

A

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]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What does:

\a
\b
\n
\t
\’
\”

Produce?

A
  • Bell
  • Backspace
  • Newline
  • Tab
  • Single Quote
  • Double Quote
  • Character
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Integer vs Floating point

A
  • Whole number with no fractional part = Integer
  • Number with fractional part (not extremely precise) = Floating
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

How to do:

Addition
Subtraction
Division
Multiplication
Modulus
Integer Division
Power
What are they examples of?

A

/
*
% 5%2 =1
//
** a**b

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Precedence of operators

A

( ) = High
* / % = Middle
+ - = Low

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is an identifier?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are variables?

A

Sections of memory where data can be stored

I.e a_value = 10

17
Q

What is a comment?

A

Part of code (Starting with #) that is ignored by python and intended to help a human reader

18
Q

What is a string literal / j Eric literal?

A

Fixed character sequences [“Hello]

Numbers used directly [3.15]

19
Q

What is syntax?

A

The fundamental rules of a programming language

20
Q

Wayne Napolo

Identify:

from math import sqrt
Side1 = 3.5 + 7.2
Side2 = 4.5
Hypotenuse = sqrt(side1side1) +(side2side2)

Print(“The hypotenuse is “, hypotenuse)

A

1) [#Wayne…] = Comment
2) [= 3.5 + 7.2] = Expression
3)[hypotenuse =] = variable
4)[sqrt] = function
5)[=4.5] = numeric literal
6)[”The hypotenuse is “] = string literal
7)[[ , hypotenuse] = Parameters