Computer programming correct answers gives instructions -> computer will do exactly
- a program must follow the syntax strictly -> interpreter/compiler can recognize
Debugging correct answers - find out what goes wrong & fix it
- is an interactive procedure
How does computer take instructions? correct answers high-level language -> interpreter &
compiler -> low-level language (machine code)
Literals correct answers Numerical literal: integer, float
String literal: a sequence of characters
Boolean literal: true/ false
Non-literal: data that have no type (null/ sth else)
Variables correct answers - cannot begin with a number
- begin with a letter/ underscore_
- case-sensitive
- only contain alpha-numeric characters & underscores
Operations correct answers manipulate literals/ operations
- arithmetic operators: + - * /
- assignment operators: assigning: =
- comparison operators: == != >= <= > <
- logical operators: not and or
- bitwise operators
- etc.
collection of literals correct answers list: has order
set
dictionary
expressions correct answers a combination of literals, variables, operators, and function calls
that produce a result when evaluated.
statements correct answers a unit of code that has an effect
a piece of code that performs an action
if statement correct answers condition -> action
loops correct answers repeating & more
used to execute a block of code repeatedly based on a specified condition or for a
predetermined number of iterations.
functions correct answers - built-in / write it on your own
- reusable block of code that performs a specific task.
- help to reuse your instructions/code
- make code more concise/readable
, classes correct answers - a blueprint/template for creating objects.
- define your own data type
- define functions in a class -> manipulate it
computer programming vs computer science correct answers computer programming:
- focus on writing code
- create computer processes
computer science:
- includes computer programming, but broader
- studies computer processes (e.g., develop theories): data structures, algorithms (e.g., sorting
data), database theory, developing mathematical models, improving efficiency and
performance.
IDE correct answers Integrated Development Environment
Compiler vs Interpreter correct answers Compiler: converts the entire code high -> low, a
program that converts all instructions into machine code so that they can be read and
executed by a computer
Interpreter: converts high -> low, line-by-line, a program that analyzes and executes each line
of code
Script mode vs Interactive mode correct answers Script mode: not show variable's value, file
can be saved & reopened
interactive mode: show value after hit 'enter', progress is lost if restart, quick testing
Precedence of expressions correct answers Highest
() parathesis
** exponential
- negation
* multiplication, / division, // integer division, % modulo
+ addition, - subtraction
Lowest
String representation correct answers - alphabet (case-sensitive), numbers, special characters
in double/single quote
- triple quote: texts in multiple lines (paragraph)
R String correct answers - add r/R before string
- include the character after the escape characters
- misconception: treat the backslashes \ as a regular character
in bool type: correct answers true: anything that is not 0/none
false: otherwise
lexicographical order correct answers Small
'' empty string
' ' space
0-9 digits