What is Slicing in Python
What is Slicing in Python
Numeric Types:
There are three distinct numeric types - integers, floating-point numbers, and complex
numbers. Additionally, booleans are a sub-type of integers.
int Stores integer literals including hex, octal and binary numbers as integers
complex Stores complex numbers in the form (A + Bj) and has attributes: real and imag
Note: The standard library also includes fractions to store rational numbers and decimal to
store floating-point numbers with user-defined precision.
Sequence Types:
According to Python Docs, there are three basic Sequence Types - lists,
tuples, and range objects. Sequence types have the in and not in operators defined for
their traversing their elements. These operators share the same priority as the
comparison operations.
13.
Which is the correct operator for power(xy)?
A.X^y
B.X**y
C.X^^y
Answer: Option B
2.
What is the result of type(3.14) ?
A.float
B.int
C.double
D.numeric
Answer: Option A
Solution:
The type() function returns the data type of the argument.
3.
What data type is used to represent a sequence of characters in Python?
A.string
B.char
C.text
D.str
What is the purpose of the str() function in Python?
A.To convert a string to a number
B.To format strings
C.To concatenate strings
D.To convert a number to a string
Answer: Option D
The str() function converts a number or other data type to a string.
5.
Which of these in not a core data type?
A.Lists
B.Dictionary
C.Tuples
D.Class
Answer: Option D
6.
Given a function that does not return any value, What value is thrown by default when
executed in shell.
A.int
B.bool
C.void
D.None
Answer & Solution
Answer: Option D
What is the result of type(True) ?
A.true
B.bool
C.boolean
D.Boolean
Answer: Option B
Solution:
The data type for boolean values in Python is bool.
8.
In order to store values in terms of key and value we use what core data type.
A.list
B.tuple
C.class
D.dictionary
Answer: Option D
How do you create a floating-point number in Python?
A.5.0
B.5
C."5.0"
D.float(5)