IT101-1L 6-7 Flashcards
The __________ is used to determine the length of a string. It returns the number of characters in the string.
len() method
is used to replace occurrences of a substring in a string with a new substring. It returns a new string with the replacements made.
The replace() method
is used to remove leading and trailing whitespace characters (such as spaces and tabs) from a string.
The strip() method
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.
The join() method
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
The startswith() and endswith() methods
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.
The find() method
works similarly but finds the last occurrence of the substring instead
index() method
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.
The sqrt function
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.
The pow function
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.
The sin and cos functions
involves changing the data type of a value temporarily to perform a specific operation or assignment that requires a different data type.
Typecasting
occurs when Python automatically converts a value from one data type to another without explicit instructions from the programmer.
Implicit typecasting
another name for implicit typecasting
automatic type conversion
requires the programmer to explicitly specify the desired data type. It involves using built-in functions to inform Python about the intended conversion
Explicit typecasting,
Explicit typecasting, another name?
type conversion,