Python3 - Built-In Functions

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

eval( )

Evaluates and executes an expression

exec( )

Executes the specified code (or object)

locals( )

Update and return a dictionary representing the current local symbol table.

filter( )

Use a filter function to exclude items in an iterable object. You must define the filter function first.

Built-in functions and exceptions

objects that can be used by all Python code without the need of an 'import' statement.

@staticmethod

A static method does not receive an implicit first argument.

zip( )

Make an iterator that aggregates elements from each of the iterables. Returns an iterator of tuples, where the i-th tuple contains the i-th element from each of the argument sequences or iterables.

open(file, mode )

Open file and return a corresponding file object. File is a path-like object giving the pathname (absolute or relative to the current working directory) of the file to be opened. Mode is an optional string that specifies the mode in which the file is opened.

tuple( )

Rather than being a function, tuple is actually an immutable sequence type, as documented in Tuples and Sequence Types — list, tuple, range.

next( )

Retrieve the next item from the iterator by calling its __next__() method.

class - int( )

Return an integer object constructed from a number or string x, or return 0 if no arguments are given.

id( )

Return the "identity" of an object. This is an integer which is guaranteed to be unique and constant for this object during its lifetime.

vars( )

Return the __dict__ attribute for a module, class, instance, or any other object with a __dict__ attribute.

pow(x, y )

Return x to the power y.

complex( )

Returns a complex number

dict( )

Returns a dictionary (Array)

float( )

Returns a floating point number

frozenset( )

Returns a frozenset object. This object is immutable and does not support indexing.

dir( )

Returns a list of the specified object's properties and methods

ascii( )

Returns a readable version of an object. Replaces none-ascii characters with escape character

bytearray( )

Returns an array of bytes

bin( )

Returns the binary version of a number prefixed with "0b".

bool( )

Returns the boolean value of the specified object

globals( )

Returns the current global symbol table as a dictionary (i.e. - returns the names that exist in the global namespace)

divmod( )

Returns the quotient and the remainder when argument 1 is divided by argument2

compile( )

Returns the specified source as an object, ready to be executed

getattr( )

Returns the value of the specified attribute (property or method) of the object

sum( )

Sums start and the items of an iterable from left to right and returns the total.

enumerate( )

Takes a collection (e.g. a tuple) and returns it as an enumerate object

hasattr( )

The arguments are an object and a string. The result is True if the string is the name of one of the object's attributes, False if not.

input( )

Capture input from user at the command line. If the prompt argument is present, it is written to standard output without a trailing newline. The function then reads a line from input, converts it to a string (stripping a trailing newline), and returns that.

hex( )

Convert an integer number to a lowercase hexadecimal string prefixed with "0x".

oct( )

Convert an integer number to an octal string prefixed with "0o". The result is a valid Python expression.

format( )

Formats a specified value. There are several format options available. For a full list, see this link: https://www.w3schools.com/python/ref_func_format.asp

class property( )

Getter and Setter methods. Return a property attribute. fget is a function for getting an attribute value. fset is a function for setting an attribute value. fdel is a function for deleting an attribute value. And doc creates a docstring for the attribute.

chr( )

Given a Unicode code point, returns a string chr(97) returns the string 'a' chr(8364) returns the string '€'. Oposite of ord( )

ord( )

Given a string representing one Unicode character, return an integer representing the Unicode code point of that character. Opposite of chr( )

help( )

Invoke the built-in help system. (This function is intended for interactive use.) If no argument is given, the interactive help system starts on the interpreter console.

print( )

Print objects to the text stream file.

class - list( )

Rather than being a function, list is actually a mutable sequence type, as documented in Lists and Sequence Types — list, tuple, range.

range( )

Rather than being a function, range is actually an immutable sequence type, as documented in Ranges and Sequence Types — list, tuple, range.

all( )

Return True if all elements of the iterable are true (or if the iterable is empty). "Are all elements in the iterable True".

any( )

Return True if any element of the iterable is true. If the iterable is empty, return False. "Is any of the elements in the iterable true"

callable( )

Return True if the object argument appears callable, False if not.

memoryview( )

Return a "memory view" object created from the given argument. See Memory Views for more information.

class - object

Return a new featureless object. object is a base for all classes. It has the methods that are common to all instances of Python classes. This function does not accept any arguments.

class set( )

Return a new set object, optionally with elements taken from iterable. set is a built-in class. See set and Set Types — set, frozenset for documentation about this class.

sorted( )

Return a new sorted list from the items in iterable.

super( )

Return a proxy object that delegates method calls to a parent or sibling class of type. This is useful for accessing inherited methods that have been overridden in a class. The search order is same as that used by getattr() except that the type itself is skipped.

reversed( )

Return a reverse iterator.

class - slice( start, stop[, step])

Return a slice object representing the set of indices specified by range(start, stop, step). The start and step arguments default to None.

class - str( )

Return a str version of object.

repr( )

Return a string containing a printable representation of an object.

iter( )

Return an iterator object.

map( )

Return an iterator that applies function to every item of iterable, yielding the results. If additional iterable arguments are passed, function must take that many arguments and is applied to the items from all iterables in parallel.

round( )

Return number rounded to ndigits precision after the decimal point.

abs( )

Return the absolute value of a number.

hash( )

Return the hash value of the object (if it has one). Hash values are integers. They are used to quickly compare dictionary keys during a dictionary lookup.

max( )

Return the largest item in an iterable or the largest of two or more arguments.

setattr( )

This is the counterpart of getattr()

len( )

Return the length (the number of items) of an object.

min( )

Return the smallest item in an iterable or the smallest of two or more arguments.

issubclass( )

Return true if class is a subclass (direct, indirect or virtual) of classinfo. A class is considered a subclass of itself.

isinstance( )

Return true if the object argument is an instance of the classinfo argument, or of a (direct, indirect or virtual) subclass thereof. If object is not an object of the given type, the function always returns false.

bytes( )

Returns a bytes object, which is immutable

breakpoint(*args, **kws)

This function drops you into the debugger at the call site.

__import__( )

This function is invoked by the import statement.

delattr( )

This is a relative of setattr(). The arguments are an object and a string. The string must be the name of one of the object's attributes. The function deletes the named attribute, provided the object allows it.

@classmethod

Transform a method into a class method.

class- type( )

With one argument, return the type of an object. The return value is a type object and generally the same object as returned by object.__class__.


संबंधित स्टडी सेट्स

TERRITORY MANAGEMENT : ALLOCATING CALLS FOR MAXIMUM PRODCTIVITY

View Set

Introduction to Neuroscience, Part 3

View Set