![]() To use mean() function, statistics module is to be imported. To generate a random number in a sequence of values where two values have a difference a step value, randrange() or random.randrange() function is used. To generate a random integer in a range, randint() or random.randint() function is used. To generate a random floating number in the range 0 to 100, random() or random.random() function is used. To use function fabs( ), math module should be imported. To check if two objects reference the same memory address, is operator is used. The id of an object gives the memory location of the object. The tuple datatype is like lists but is not mutable. The set sequence type cannot store duplicate values. The division of two integers yields a result of floating-point type. The floor division of two integers yields a result of integer type. Three mutable types of Python are lists, dictionaries and sets. Python's floating point numbers have precision of 15 digits. Two forms of floating-point numbers are: fractional form and exponent notation. What will be the result of the expression 'false' or False ?īoolean data type is internally treated as integer data type. What will be the result of the expression 'false' and False ? What will be the result of the expression 'None' and 'a' ? What will be the result of the expression 'a' and 'None' ? What will be the result of the expression 'a' and 'x' ? What will be the result of the expression 'x' and 'a' ? What will be the result of the expression 'a' and " (" is an empty string) ? What will be the result of the expression 'a' or " (" is an empty string) ? What will be the result of the expression 15 and 10? What will be the result of the expression 5 and 10? What will be the result of the expression 5 or 10 ? What will be the result of the expression 10 or 0 ? To increase the value of x five times using an augmented assignment operator, the correct expression will be What is the value of the expression 10 + 3 ** 3 * 2? Which of the following operators has the lowest precedence ? Import math x = 100 print ( x > 0 and math. Is it safe to directly use the = operator to determine whether objects of type float are equal ? In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type. In Python, a variable is assigned a value of one type, and then later assigned a value of a different type. In Python, a variable must be declared before it is assigned a value. What is the value of the expression 100 // 25 ? What is the value of the expression 100 / 25 ? Python operator always yields the result of. Which of the following is not an immutable type in Python ? operator.įor two objects x and y, the expression x is y will yield True, if and only if The operator used to check if both the operands reference the same object memory, is the. Which Python built-in function returns the unique number assigned to an object? Which of the following are datatypes considered as Numbers in Python.Ĭonsider the following sequence of statements:įollowing the execution of these statements, Python has created how many objects and how many references ? ![]() MyLst.Which of the following are valid Python data types ? Print( valA) #Line1 print( valB) #Line2 print( 30 in myDict) #Line3 myLst = list( myDict. Hence, for dictionaries, the elements can be changed as dictionaries are mutable but for strings is cannot be changed as strings are immutable.ĭict = Question 7Ĭan you change an element of a sequence or collection? What if a collection is a dictionary? What if a sequence is a string?Įlements of a collection or sequence can be changed only if the collection or sequence is mutable. The following types can be used as keys of a dictionary because they are immutable:Īs lists and dictionaries are mutable so they cannot be used as keys of a dictionary. Which of the following types qualify to be the keys of a dictionary? Moreover, lists and strings are ordered set of elements but dictionaries are unordered set of elements so its elements cannot be accessed as per specific order. ![]() In lists or strings, the elements are accessed through their index where as in dictionaries, the elements are accessed through the keys defined in the key:value pairs. How is indexing of a dictionary different from that of a list or a string?
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |