Chapter 4 Flashcards

1
Q

What is an integer ( data type )?

A

Whole numbers both positive and negative

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

What is a float ( real number ) ?

A

Real numbers, decimals and intergers. All Integers can be floats but not the other way.

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

What is a string ( data type )?

A

Multiple characters ( a list of characters )

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

What is the difference between a strongly-typed and a weakly-typed language? And provide examples.

A

In a strongly typed language (C, C++) you have to explicitly specify the data type in a variable.

In a weakly typed language (python), the programming language “guesses” the data type.

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

len(string)

A

len(“orange”) => 6

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

string.capitalize()

A

“orange”.capitalize() => Orange

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

string.lower()

A

“BAnAna”.lower() => banana

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

string.upper()

A

“BAnANa”.upper() => BANANA

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

string.rjust(number)

A

“Dog”.rjust(50) => (50 length)Dog

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

string.replace(oldvalue, newvalue)

A

“Dog”.replace(“o”, “i”) => Dig

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

string.split(separator)

A

“myname”.split(“y”) => [“my”, “name]

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

string.strip(characters)

A

“…##..banana..#..”.strip(.#) => banana

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

string.join(list)

A

“+”.join([“Bill”,”Barney”,”Ben”]) => Bill + Barney + Ben

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

string.find(substring)

A

“The missing word”.find(miss) => 4

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

string.format (items)

A

“My name is {name} and I am {age} years old”.format(name=“Bob”,age= “27”) => My name is Bob and I am 27 years old.

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

\n

A

Newline

17
Q

\t

A

Tab

18
Q

\”

A

Prints the literal “

19
Q

\

A

Prints the literal \

20
Q

What is combining strings called?

A

Concatenation

21
Q

What is looping through a string called?

A

String traversal

22
Q

What does concatenation do?

A

Combines strings and lists. Does not combine integers or floats.

23
Q
A