Shared Flashcard Set

Details

Week 2
programming principles
14
Computer Science
Post-Graduate
11/08/2017

Additional Computer Science Flashcards

 


 

Cards

Term
Four common data types
Definition
Integer - whole number
string - sequence of characters
float - decimal places
Boolean - True or False
Term
Weakly typed language

Strongly typed language
Definition
Weakly - focus on being convenient. Generally achieved by making it easy to mix different data types together. Tries to work things out for you.

Strongly - focus on being safe. Conversions must be done explicitly. Programmer must consider and manually convert

Most languages are in the middle
Term
Static typing

Dynamic typing
Definition
language requires you to declare and adhere to the data types and variables (C, java) Assigning a different type will result in an error.

Dynamic - variables data type is determined by the data assigned.
Term
Values that equate to True
Definition
Anything that is not zero
bool(5)
bool(-5)
bool('5')
Term
Values that equate to False
Definition
bool(0)
bool(0.0)
bool('')
bool[]
Term
Concatenation of strings and numbers
Definition
python: convert number to a string and then concatenate (explicit) unless you use print()
Java - coerces both values into strings and concatenates them
Term
Why is knowing data types important?
Definition
- dictates what you can do with the it
- how/if you can mix data types
- what you need to test (all of it)!
Term
if - then statements
Definition
Selection statements. Instead of running from beginning to end, it runs certain parts of the code based on conditions being true (Boolean).

Draw flowchart

value = int(input('Enter number:')
if value <= 100:
print (value)

pseudocode for other languages
Term
if - then - else
Definition
Another selection statement. Run one section of code if the Boolean expression is true and another if false.

Draw flowchart

Other languages
Term
else - if
Definition
Chain selection statements together. Looks for the code following the first True condition and runs that

Draw flowchart
Term
logical operators
Definition
and - true of both true
or - true if one is true
not - reverse
Term
comparison or relational operators
Definition
<
>
== !=
>= <=
Term
Switch statement
Definition
Not in python. if your conditions all check for different values of the same thing, a switch statement can be used instead of else-ifs

draw flowchart
Term
What is a string method
Definition
built in functions that can only be used on strings. Allows you to manipulate strings or determine information about a string eg. isalpha(), islower()
Supporting users have an ad free experience!