Session 2: Learn to Code with SWIFT Flashcards

1
Q

What is a variable?

A

Used to store information like some labels to be referred later and stored in memory. Variables are containers of information and link between users and software.

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

Give an example of variable and how it stores in computer?

A

For example my age is 23. But computer only works with 0 and 1 so, 23 is for us. Now age is a variable and it’s value which is 23 stores inside the RAM(Random Access Memory). In programming perspective: var age = 23.

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

What is an assignment operator?

A

Or = assigns the variation to an operator which can be string “like this” or value e.g. 30.

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

What can be after assignment operator?

A

Assigns the value to variable.

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

3 main kinds of operators?

A

Unary(single), Binary(Double) and Ternary(Three)

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

Write the samples in codes for operators?

A

Unary(Only amICoolPerson)—> var amIACoolPerson = true, amICoolPerson = !amICoolPerson. Binary(name and this is great)—> var name = “this is great”. ….

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

What is string and it’s length?

A

A finite sequence of characters(either word or symbols or letter). The length can be from zero to a number.

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

What is string manipulation? Using a string from another variable and using inside another variable like: var name = “ali” , var family = “sadeghi” var fullName = name “ “ family.

A

Using a string from another variable and using inside another variable like: var name = “ali” , var family = “sadeghi” var fullName = name “ “ family.

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

What is string interpolation?

A

Using all previously used strings inside new string by using ((variable)) like var fullName2 = “(first) (last) is (age) years old”

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

What is append function?

A

When we want to add an object at the end of a variable like: var fullName.append = “AAA” —> Becomes: ali sadeghiAAA

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

Write sample code contains strings to change bad words?

A

var sentence = “what the F* you are As*”, if sentence.contains(“f*) || sentence.contains(“As*) { sentence.replaceingOccurrences (of: “f*” , with “Googooli”

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

What are the main types of Numbers?

A

3 groups: Integer, Float and Double

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

What is Integer?

A

Numbers with no fraction. It can be either positive, negative or zero.

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

What is difference between signed and assigned integers?

A

When we put a number we assign the integer to a limited number of integers can carry. e.g. UInt8 only can carry 8 digits. But if we don’t mention anything SWIFT automatically fixes upon needs.

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

What is Double Data type?

A

For when we use long digits or fractional we use Double. Double type is the preferred type suggested by SWIFT by default.

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

What is Float type?

A

It is like Double type but with fewer and shorter digits.

17
Q

What is Argument?

A

Argument is also know as parameter.

18
Q

What is fun?

A

It is the Function abbreviation

19
Q

What is Return Type?

A

After we define the function name and dedicate it’s argument before writing the function formula we use Return Type which clears out what will be the final type of outcome. It is like this: (—>Int {

20
Q

What is Let and Return?

A

After the Return type inside the parenthesis we should write the function after let NAME and then use return of NAME

21
Q

How does a function work? From start to end.

A

First—> Write the function and choose a name and mention it’s argument and their variable type

22
Q

Write an example: We want to buy a shoe 350.00 $ if our bank account is more than the price. Write a formula?

A

here is the formula

23
Q

Review key vocabs from Session 2 in your mind: Function, Array, Variable, Operator, Assignment Operator, Logical Operator, Comparison Operator, Value, Element, Array Assignment….

A