##### Quick Contact

##### Python Tutorial

- What is Python?
- How to Install Python?
- Python Variables and Operators
- Python Loops
- Python Functions
- Python Files
- Python Errors and Exceptions
- Python Packages
- Python Classes and Objects
- Python Strings
- PostgreSQL Data Types
- Python Generators and Decorators
- Python Dictionary
- Python Date and Time
- Python List and Tuples
- Python Multithreading and Synchronization
- Python Modules
- What is Python bytecode?
- Python Regular Expressions

##### Python Selenium

##### Interview Questions & Answers

#### Python Strings

Python string is the set of the characters surrounded by individual quotes, double quotes, or triple quotes. The system does not learn the characters; internally, it stores manipulated character as the combination of the 0’s and 1’s.

In this tutorial, we understand that various Python in-built mathematical, random number, trigonometric functions and their use on numbers and inbuilt string methods.

##### Mathematical functions

Function | Description |
---|---|

abs(x) | This function decides the absolute cost of x, which is the (positive) distance among x and zero. |

ceil(x) | This function determines the ceiling of x, which is the smallest integer not less than x. |

cmp(x, y) | This function returns values as -1, 0 and 1. It returns-1 if x < y, 0 if x == y, or 1 if x > y. |

exp(x) | This function determines the exponential of x: ex. |

fabs(x) | This function determines the absolute value of x. |

floor(x) | This function decides the floor of x, which is the biggest integer not higher than x. |

log(x) | This function determines the natural logarithm of x, for x> 0. |

log10(x) | This function determines the base-10 logarithm of x for x>0. |

max (x1, x2,..) | This function decides the largest of its arguments, which is the value nearest to positive infinity. |

min (x1, x2,..) | This function decides the smallest of its arguments, which is the value nearest to negative infinity. |

modf(x) | This function determines the fractional and integer method of x in a two-element tuple. Both parts have a similar sign as x. The integer part is replaced as a float by the function. |

pow(x, y) | This function determines the value of x**y. |

round(x [,n]) | In this function, x rounded to n digits from the decimal point. |

sqrt(x) | This function determines the square root of x for x > 0. |

##### Random Number functions

Function | Description |
---|---|

choice(seq) | This function restore a random element from a list, tuple, or string. |

randrange ([start,] stop [,step]) | This function returns the randomly chosen element from range (start, stop, step). |

random() | This function returns a random float r, such that 0 is less than or equal to r and r is less than 1 |

seed([x]) | This function sets the integer beginning value used in generating random numbers. It can call this function before calling any other random module function. |

shuffle(lst) | This function can randomize the elements of a list in place. It returns Nothing. |

uniform(x, y) | This function returns a random float r, such that x is less than or equal to r and r is less than y. |

##### Trigonometric functions

Function | Description |
---|---|

acos(x) | This Python in-built trigonometric function returns the arc cosine of x, in radians. |

asin(x) | This Python in-built trigonometric function returns the arc sine of x, in radians. |

atan(x) | This Python in-built trigonometric function returns the arc tangent of x, in radians. |

atan2(y, x) | This Python in-built trigonometric function returns atan(y / x), in radians. |

cos(x) | This Python in-built trigonometric function returns the cosine of x radians. |

hypot(x, y) | This Python in-built trigonometric function returns the Euclidean norm, sqrt(x*x + y*y). |

sin(x) | This Python in-built trigonometric function returns the sine of x radians. |

tan(x) | This Python in-built trigonometric function returns the tangent of x radians. |

degrees(x) | This Python in-built trigonometric function converts angle x from radians to degrees. |

radians(x) | This Python in-built trigonometric function converts angle x from degrees to radians. |

##### Mathematical Constants

Constants | Descriptions |
---|---|

Pi | The mathematical constant pi. |

E | The mathematical constant e. |

##### Python in-built String Methods

Methods | Descriptions |
---|---|

capitalize() | This Python in-built function is for String which makes the first letter of the string in uppercase. |

center(width, fillchar) | This Python in-built function for String returns a space-padded string with the original string centred to a total of width columns. |

count(str, beg= 0,end=len(string)) | This Python in-built function for String counts how many times str occurs in the string or a substring of string if beginning index beg and ending index end are given. |

decode(encoding=‘UTF8’,errors=‘strict’) | This Python in-built function for String decodes the string using the codec registered for encoding. Encoding defaults to the default string encoding. |

encode(encoding=‘UTF8’,errors=‘strict’) | This Python in-built function for String replace encoded string version of string; on error, default is to raise a ValueError unless bugs are supported with ‘ignore’ or ‘replace’. |

endswith(suffix, beg=0, end=len(string)) | This Python in-built function for String determines if a string or a substring of string (if beginning index beg and ending index end are given) ends with a suffix; returns true if so and false. |

expandtabs(tabsize=8) | This Python in-built function for String expands tabs in the string to various spaces; defaults to 8 spaces per tab if tabsize not given. |

find(str, beg=0 end=len(string)) | This Python in-built function for String determines if str occurs in the string or a substring of string if beginning index beg and ending index end are provided returns index if found and -1. |

index(str, beg=0, end=len(string)) | This Python in-built function for String is the same as find() but raises an exception if str not found. |

isalnum() | This Python in-built function for String returns true if the string has minimum one character and all characters are alphanumeric and false otherwise. |

isalpha() | This Python in-built function for String returns true if the string has minimum one character and all characters are alphabetic and false otherwise. |

isdigit() | This Python in-built function for String returns true if the string contains only digits and false. |

islower() | This Python in-built function for String returns true if the string has at least one cased character and all cased features are in lowercase and false. |

isnumeric() | This Python in-built function for String returns true if a Unicode string contains only numeric characters and false otherwise. |

isspace() | This Python in-built function for String returns true if the string contains only whitespace characters and false otherwise. |

istitle() | This Python in-built function for String returns true if the string is appropriately “titlecased” and false otherwise. |

isupper() | This Python in-built function for String returns true if the string has minimum one cased character and all cased features are in uppercase and false. |

join(seq) | This Python in-built function for String merges (concatenates) the string representations of elements in sequence seq into a string, with separator string. |

len(string) | This Python in-built function for String returns the length of the string. |

ljust(width[, fillchar]) | This Python in-built function for String returns a space-padded string with the original string left-justified to a total of width columns. |

lower() | This Python in-built function for String converts all uppercase letters in a string to lowercase. |

lstrip() | This Python in-built function for String removes all leading whitespace in string. |

maketrans() | This Python in-built function for String returns a translation table to be used in translate function. |

max(str) | This Python in-built function for String returns the max alphabetical character from the string str. |

min(str) | This Python in-built function for String returns the min alphabetical character from the string str. |

replace(old, new [, max]) | This Python in-built function for String would replace all occurrences of old in the string with new or at most max appearance if max gave. |

rfind(str, beg=0,end=len(string)) | This Python in-built function for String is the same as find () but search backwards in the string. |

rindex( str, beg=0, end=len(string)) | This Python in-built function for String is the same as an index () but search backwards in the string. |

rjust(width,[, fillchar]) | This Python in-built function for String returns a space-padded string with the original string right-justified to a total of width columns. |

rstrip() | This Python in-built function for String removes all trailing whitespace of string. |

split(str=””, num=string.count(str)) | This Python in-built function for String splits string according to delimiter str (space if not provided) and returns a list of substrings; divided into at most num substrings if given. |

splitlines( num=string.count(‘\n’)) | This Python in-built function for String splits a string at all (or num) NEWLINEs and restore a list of every line with NEWLINEs removed. |

strip([chars]) | This Python in-built function for String performs both lstrip() and rstrip() on the string. |

swapcase() | This Python in-built function for String inverts case for all letters in a string. |

translate(table, deletechars=””) | This Python in-built function for String translates string according to translation table str(256 chars), removing those in the del string. |

upper() | This Python in-built function for String converts lowercase letters in a string to uppercase. |

zfill (width) | This Python in-built function for String returns initial string leftpadded with zeros to a total of width characters; intended for numbers, zfill () retains few sign provided (less one zero). |

isdecimal() | This Python in-built function for String returns true if a Unicode string contains only decimal characters and false otherwise. |

Enroll Yourself : Python Training