IT101-1L 6-7 Flashcards

1
Q

The __________ is used to determine the length of a string. It returns the number of characters in the string.

A

len() method

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

is used to replace occurrences of a substring in a string with a new substring. It returns a new string with the replacements made.

A

The replace() method

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

is used to remove leading and trailing whitespace characters (such as spaces and tabs) from a string.

A

The strip() method

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

is used to join elements of an iterable (such as a list) into a single string. It returns a new string with the elements joined by the specified separator.

A

The join() method

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

are used to check if a string starts or ends with a specified prefix or suffix, respectively. They return True or False based on the check

A

The startswith() and endswith() methods

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

is used to find the first occurrence of a substring in a string. It returns the index of the first occurrence or -1 if the substring is not found.

A

The find() method

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

works similarly but finds the last occurrence of the substring instead

A

index() method

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

is used to calculate the square root of a number. It takes a single argument and returns the square root as a floating-point number.

A

The sqrt function

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

is used to raise a number to a power. It takes two arguments: the base number and the exponent. It returns the result as a floating-point number.

A

The pow function

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

are used to calculate the sine and cosine of an angle, respectively. These functions take the angle in radians as an argument and return the corresponding sine or cosine value as a floating-point number.

A

The sin and cos functions

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

involves changing the data type of a value temporarily to perform a specific operation or assignment that requires a different data type.

A

Typecasting

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

occurs when Python automatically converts a value from one data type to another without explicit instructions from the programmer.

A

Implicit typecasting

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

another name for implicit typecasting

A

automatic type conversion

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

requires the programmer to explicitly specify the desired data type. It involves using built-in functions to inform Python about the intended conversion

A

Explicit typecasting,

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

Explicit typecasting, another name?

A

type conversion,

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

Converts a value to an integer data type.

A

int():

17
Q

Converts a value to a floating-point data type.

A

float():

18
Q

Converts a value to a string data type.

A

str():

19
Q
A