Prem Prakash

2.3K posts

Prem Prakash banner
Prem Prakash

Prem Prakash

@4EverPrem

Python Enthusiast, Runner YT: https://t.co/iDZxYqUWMt

India Katılım Mayıs 2014
49 Takip Edilen195 Takipçiler
Ruksana Ansar
Ruksana Ansar@RuksanaAnsar·
90% of people get this wrong! Can you find the three numbers?
Ruksana Ansar tweet media
English
642
143
393
40.2K
Prem Prakash
Prem Prakash@4EverPrem·
@Python_Dv Error. num is a local variable and exists only in the function fun1, therefore, when it is called outside the function, it will result in error.
English
0
0
1
140
Python Developer
Python Developer@Python_Dv·
What is the output? Write your answer in the comments and share it with your friends 👑👑
Python Developer tweet media
English
14
10
79
6.9K
Prem Prakash
Prem Prakash@4EverPrem·
@clcoding None. append method adds element at the end of the list but returns None. Below code will print [1, 2, 3, 4] a = [1,2,3] a.append(4) print(a)
English
0
0
1
47
Python Coding
Python Coding@clcoding·
What will be the output of the following Python code? a = [1, 2, 3] print(a.append(4))
English
14
7
34
7.7K
Prem Prakash
Prem Prakash@4EverPrem·
@Astro_Panditji_ So in this entire world, only Mukesh Ambani and Ratan Tata were born on these two dates ?? Not a single other person was born ???
English
0
0
0
36
Researcher of Astrology
Researcher of Astrology@Astro_Panditji_·
Mukesh Ambani = 19 April 1957 → 1+9+4+1+9+5+7 = 36 3 + 6 = 9 → Mars’ number (Empire builder) Ratan Tata = 28 December 1937 → 2+8+1+2+1+9+3+7 = 33 3 + 3 = 6 → Venus’ number (Legacy & influence) Drop your Date of Birth Find something about yourself. RT, Follow and Like.
English
4.1K
447
3.3K
653.6K
Prem Prakash
Prem Prakash@4EverPrem·
@Python_Dv No output. When 7 is divided by 2, the remainder is 1 and not 0, therefore, the if clause is not met. As a result, none of the print statements are executed. Mind it None is a keyword in Python so None is not the correct answer.
English
0
0
1
563
Prem Prakash
Prem Prakash@4EverPrem·
@RealBenjizo Error. Instance methods must always accept the instance as the first parameter. If we insert self in class X6, it will work.
English
1
0
3
761
Benjamin Bennett Alexander
Benjamin Bennett Alexander@RealBenjizo·
Python question: Do you know Python classes? What is the output of this code and why?
Benjamin Bennett Alexander tweet media
English
16
8
95
13.9K
Prem Prakash
Prem Prakash@4EverPrem·
@clcoding [-2, -1, 1, 2] Although not explicitly specified, filter will keep only those values from the nums list which are truthy in nature and filter out falsy values. Zeros are falsy and non-zeros truthy so it outputs [-2, -1, 1, 2]
English
0
0
1
88
Python Coding
Python Coding@clcoding·
What will be the output of the following Python code? nums = [-2, -1, 0, 1, 2] print(list(filter(lambda x: x, nums)))
English
7
6
28
5.7K
Python Developer
Python Developer@Python_Dv·
Comment your answer below! Think you know Python inside out? 🐍 Test your coding skills with these tricky Python output questions! Can you crack this code? Let’s find out!
Python Developer tweet media
English
13
7
39
4.8K
Prem Prakash
Prem Prakash@4EverPrem·
@clcoding [1]. items is a class attribute and not an instance attribute.
English
0
0
0
45
Prem Prakash
Prem Prakash@4EverPrem·
@clcoding 1 2 if the code is t = ((1,2),(3,4),(5,6)) for a, b in t: print(a, b) It prints 1 2 3 4 5 6 clearly, a is first element and b is second element of each individual tuple in t. Coming back to code in question, in 2nd iteration, a = 3 so loop breaks out and printing 1 2
English
0
0
2
387
Python Coding
Python Coding@clcoding·
What will be the output of the following Python code? t = ((1, 2), (3, 4), (5, 6)) for a, b in t: if a == 3: break print(a, b)
English
9
1
29
8.4K
Prem Prakash
Prem Prakash@4EverPrem·
@Python_Dv [1 3] => it will be without the commas in between 1 and 3 numpy array slicing is same as Python list slicing.
English
0
0
0
151
Python Developer
Python Developer@Python_Dv·
Comment your answer now ⬇️
Python Developer tweet media
English
14
6
65
7.8K
Prem Prakash
Prem Prakash@4EverPrem·
@clcoding 1 5 When t is instantiated, t.f is pointing to method f. t.f() -> method f is called -> self.f = 5 assigns 5 to f but return 1 overwrites it with 1. So t.f() = 1 t.f -> Now t.f is no longer a method after it and as previously is re-assigned to 5, so t.f = 5
English
0
0
1
108
Prem Prakash
Prem Prakash@4EverPrem·
@PythonPr 5. Python passes values to a variable by object reference. Since y is int, it is immutable, therefore, y is a new object different from x and allocated different memory. Therefore, changes in x does not impact y.
English
0
0
2
407
Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
28
6
61
10.2K
Python Programming
Python Programming@PythonPr·
What is The Difference ❓ Comment The Answer
Python Programming tweet media
English
14
3
71
19.4K
Prem Prakash
Prem Prakash@4EverPrem·
@RealBenjizo TypeError. print("Hello", + name) => either remove the comma or + sign, then it will work.
English
0
0
3
397
Prem Prakash
Prem Prakash@4EverPrem·
@clcoding 3 3 __getattr__(self, name) is called only when an attribute is NOT found normally. Initially, no attribute defined but when c.abc, it is set to c.__dict__["abc"] = 3, returning 3. Second time c.abc, __getattr__ is not run & directly returns 3
English
0
0
1
108
Prem Prakash
Prem Prakash@4EverPrem·
@PythonPr 30 since the if condition is true, values of x and y are re-assigned to 3 and 10 respectively. Therefore, 30
English
0
0
0
594
Python Programming
Python Programming@PythonPr·
Python Question / Quiz; What is the output of the following Python code, and why? Comment your answers below!
Python Programming tweet media
English
38
11
96
16.5K
Prem Prakash
Prem Prakash@4EverPrem·
@Python_Dv odd. Good question. a%2 = 4%2= 0. Now 0 is false in Python, therefore, else clause is executed and odd is printed.
English
0
0
7
3.5K
Prem Prakash
Prem Prakash@4EverPrem·
@Python_Dv F to be changed to lower case f. Correct code is import math print(math.factorial(5))
English
0
0
0
349
Prem Prakash
Prem Prakash@4EverPrem·
@clcoding 0 return is the end of the function and nothing gets executed after it. So in the first iteration when i is 0, it comes across return, thus exits and outputs 0, never going for subsequent loops.
English
0
0
2
278
Python Coding
Python Coding@clcoding·
What will be the output of the following Python code? def clcoding(): for i in range(3): return i print(clcoding())
English
7
3
17
7.8K