x = [1, 23, 'hello', 1]
type(x)
# What datatype of x? Explain?
type(x)
# What datatype of x? Explain?
Anonymous Quiz
5%
str
66%
list
6%
dict
8%
array
7%
tuple
4%
error
3%
Show me the answer
x=1.23456789
'%f | %e | %g' %(x, x, x)
#What is the result? Explain Why?
'%f | %e | %g' %(x, x, x)
#What is the result? Explain Why?
Anonymous Quiz
17%
1.23456789 | 1.23456789+00 | 1.234567
26%
1.234568 | 1.234568e+00 | 1.23457
19%
1.234567 | 1.234567e+00 | 1.234567
17%
Error
5%
None of the above
15%
Show the answer
x, y = 5, 6
x+y == _____
#Which of the following statements is equal to x+y?
x+y == _____
#Which of the following statements is equal to x+y?
Anonymous Quiz
21%
x.__add(y)
34%
x.__add__(y)
9%
x.__ADD__(y)
5%
x.__ADD(y)
18%
None of the above
13%
Show me the answer
x = "Python World"
x[3] = 's'
# What is the value of x? Can you explain Why?
x[3] = 's'
# What is the value of x? Can you explain Why?
Anonymous Quiz
13%
Python World
6%
python world
52%
Pytson World
8%
Pyshon World
17%
Error
5%
Show me the answer
print('*', "abcdef".center(7), '*')
# What is the output? Can you Explain?
# What is the output? Can you Explain?
Anonymous Quiz
17%
*abcdef*
18%
* abcdef *
18%
* abcdef *
17%
* abcdef *
16%
Error
14%
Show me the answer
https://t.me/python_interview_questions/117
Only 14% got this correct.
Only 14% got this correct.
None of the above
True, False and None are capitalized, that is the first letter in these keywords start with a Capital letter.
The rest of all the other keywords are in lower case.
Hence, the correct answer is "
".
Telegram
Python Questions
All keywords in Python are in?
lower case / UPPER CASE / snake_case / camel_case / Capitalized / None of the above / Show me the answer
lower case / UPPER CASE / snake_case / camel_case / Capitalized / None of the above / Show me the answer
print("abbcabcacabb".count('abb', 2, 11))
#What is the output of the above statement? Explain this statement?
#What is the output of the above statement? Explain this statement?
Anonymous Quiz
27%
2
24%
1
14%
0
21%
Error
14%
Show me the answer
x = “python”+1+2+3
# What is the value of x? Explain?
# What is the value of x? Explain?
Anonymous Quiz
27%
python123
11%
"python",1,2,3
21%
python6
34%
Error
3%
None of the above
4%
Show me the answer
print('xy'.isalpha())
#What is the output of the above code?
#What is the output of the above code?
Anonymous Quiz
8%
xy
51%
True
21%
False
10%
xy.isalpha
4%
Error
6%
Show me the answer
print('1.1'.isnumeric())
#What is the output? Explain this.
#What is the output? Explain this.
Anonymous Quiz
7%
1
11%
1.1
44%
True
27%
False
5%
Error
1%
None of the above
5%
Show me the answer
x = (round(4.5) - round(-4.5))
#What is the value of x
#What is the value of x
Anonymous Quiz
35%
0
28%
9
8%
-9
16%
8
2%
-8
4%
None of the Above
7%
Show me the answer
print(r"\npython")
#What is the output? Explain Why?
#What is the output? Explain Why?
Anonymous Quiz
39%
New line and 'python'
23%
\npython
10%
r\npython
6%
r,python
12%
Error
10%
Show me the answer
print('KLM'.maketrans('KLM', '123'))
What is the output? Explain the function maketrans()
What is the output? Explain the function maketrans()
Anonymous Quiz
11%
{65: 49, 66: 50, 67: 51}
26%
{75: 49, 76: 50, 77: 51}
14%
{75: 49, 66: 50, 77: 51}
17%
None of the above
31%
Show me the answer
print('iGnani'.translate({'i': '1', 'G': '2', 'n': '3', 'a': '4', 'i': '5'}))
#What is the output. Explain translate()
#What is the output. Explain translate()
Anonymous Quiz
39%
123435
20%
12345
16%
iGnani
9%
Error
5%
None of the above
12%
Show me the answer
print('pyypyypypyppy'.replace('py', 'iG', 3))
#What is the output?
#What is the output?
Anonymous Quiz
8%
pyypyypypyppy
25%
iGyiGyiGiGpiG
35%
iGyiGyiGpyppy
11%
Error
9%
None of the above
12%
Show me the answer
```
print('The sum of {0} and {1} is {2}'.format(5, 10, 15)) ``` What is the output?
print('The sum of {0} and {1} is {2}'.format(5, 10, 15)) ``` What is the output?
Anonymous Quiz
7%
The sum of 0 and 1 is 2
51%
The sum of 5 and 10 is 15
12%
The sum of {0} and {1} is {2}
17%
Syntax Error
3%
None of the above
10%
Show me the answer
Select the command that installs Django?
Anonymous Quiz
15%
pip Django
7%
pip create Django
7%
pip start Django
69%
pip install Django
3%
None of the above
:= which of the following is true about this operator
Anonymous Quiz
17%
Is available only in IronPython
21%
Not available in any Python versions
40%
New in Python 3.8 & above
23%
None of the above is true
Forwarded from Python Resources - Basic Python, ML, DataScience, BigData (Rustbot)
PyTip for the day:
Use the "enumerate" function to iterate over a sequence and get the index of each element.
Sometimes when you're iterating over a list or other sequence in Python, you need to keep track of the index of the current element. One way to do this is to use a counter variable and increment it on each iteration, but this can be tedious and error-prone.
A better way to get the index of each element is to use the built-in "enumerate" function. The "enumerate" function takes an iterable (such as a list or tuple) as its argument and returns a sequence of (index, value) tuples, where "index" is the index of the current element and "value" is the value of the current element. Here's an example:
The output of this code would be:
Use the "enumerate" function to iterate over a sequence and get the index of each element.
Sometimes when you're iterating over a list or other sequence in Python, you need to keep track of the index of the current element. One way to do this is to use a counter variable and increment it on each iteration, but this can be tedious and error-prone.
A better way to get the index of each element is to use the built-in "enumerate" function. The "enumerate" function takes an iterable (such as a list or tuple) as its argument and returns a sequence of (index, value) tuples, where "index" is the index of the current element and "value" is the value of the current element. Here's an example:
Iterate over a list of strings and print each string with its indexIn this example, we use the "enumerate" function to iterate over a list of strings. On each iteration, the "enumerate" function returns a tuple containing the index of the current string and the string itself. We use tuple unpacking to assign these values to the variables "i" and "s", and then print out the index and string on a separate line.
strings = ['apple', 'banana', 'cherry', 'date']
for i, s in enumerate(strings):
print(f"{i}: {s}")
The output of this code would be:
appleUsing the "enumerate" function can make your code more concise and easier to read, especially when you need to keep track of the index of each element in a sequence.
1: banana
2: cherry
3: date