Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Questions | Answers | Discussions | Knowledge sharing | Communities & more.
What are the generators in python?
Functions that return an iterable set of items are called generators.
Functions that return an iterable set of items are called generators.
See lessHow will you capitalize the first letter of string?
In Python, the capitalize() method capitalizes the first letter of a string. If the string already consists of a capital letter at the beginning, then, it returns the original string.
In Python, the capitalize() method capitalizes the first letter of a string. If the string already consists of a capital letter at the beginning, then, it returns the original string.
See lessWhat is pickling and unpickling?
Pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using dump function, this process is called pickling. While the process of retrieving original Python objects from the stored string representation is called unpickling.
Pickle module accepts any Python object and converts it into a string representation and dumps it into a file by using dump function, this process is called pickling. While the process of retrieving original Python objects from the stored string representation is called unpickling.
See lessWhat is the difference between range & xrange?
For the most part, xrange and range are the exact same in terms of functionality. They both provide a way to generate a list of integers for you to use, however you please. The only difference is that range returns a Python list object and x range returns an xrange object. This means that xrange doeRead more
For the most part, xrange and range are the exact same in terms of functionality. They both provide a way to generate a list of integers for you to use, however you please. The only difference is that range returns a Python list object and x range returns an xrange object.
This means that xrange doesn’t actually generate a static list at run-time like range does. It creates the values as you need them with a special technique called yielding. This technique is used with a type of object known as generators. That means that if you have a really gigantic range you’d like to generate a list for, say one billion, xrange is the function to use.
This is especially true if you have a really memory sensitive system such as a cell phone that you are working with, as range will use as much memory as it can to create your array of integers, which can result in a Memory Error and crash your program. It’s a memory hungry beast.
See lessHow do you write comments in python?
Comments in Python start with a # character. However, alternatively at times, commenting is done using docstrings(strings enclosed within triple quotes).
Comments in Python start with a # character. However, alternatively at times, commenting is done using docstrings(strings enclosed within triple quotes).
See lessHow can you generate random numbers in Python?
Random module is the standard module that is used to generate a random number. The method is defined as: 1 2 import random random.random The statement random.random() method return the floating-point number that is in the range of [0, 1). The function generates random float numbers. The methods thatRead more
Random module is the standard module that is used to generate a random number. The method is defined as:
1
2
import random
random.random
The statement random.random() method return the floating-point number that is in the range of [0, 1). The function generates random float numbers. The methods that are used with the random class are the bound methods of the hidden instances. The instances of the Random can be done to show the multi-threading programs that creates a different instance of individual threads. The other random generators that are used in this are:
1. randrange(a, b): it chooses an integer and define the range in-between [a, b). It returns the elements by selecting it randomly from the range that is specified. It doesn’t build a range object.
2. uniform(a, b): it chooses a floating point number that is defined in the range of [a,b).Iyt returns the floating point number
3. normalvariate(mean, sdev): it is used for the normal distribution where the mu is a mean and the sdev is a sigma that is used for standard deviation.
4. The Random class that is used and instantiated creates independent multiple random number generators.
See lessHow can you randomize the items of a list in place in Python?
Consider the example shown below: from random import shuffle x = ['Keep', 'The', 'Blue', 'Flag', 'Flying', 'High'] shuffle(x) print(x) The output of the following code is as below. ['Flying', 'Keep', 'Blue', 'High', 'The', 'Flag']
Consider the example shown below:
from random import shuffle
x = [‘Keep’, ‘The’, ‘Blue’, ‘Flag’, ‘Flying’, ‘High’]
shuffle(x)
print(x)
The output of the following code is as below.
[‘Flying’, ‘Keep’, ‘Blue’, ‘High’, ‘The’, ‘Flag’]
See lessWhat are python iterators?
Iterators are objects which can be traversed though or iterated upon.
Iterators are objects which can be traversed though or iterated upon.
See lessWhat is a lambda function?
An anonymous function is known as a lambda function. This function can have any number of parameters but, can have just one statement.
An anonymous function is known as a lambda function. This function can have any number of parameters but, can have just one statement.
See lessWhat does [::-1} do?
[::-1] is used to reverse the order of an array or a sequence.
[::-1] is used to reverse the order of an array or a sequence.
See less