Byte Focus Tech

33 posts

Byte Focus Tech banner
Byte Focus Tech

Byte Focus Tech

@ByteFocusB

I'm a tech enthusiast focused on software development, programming, and digital trends. I share insights on web and emerging technologies to help others build.

World Newton, England Joined Mart 2022
570 Following30 Followers
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv Output: [1] [1, 2] The default argument b=[] is created once when the function is defined, not each time it’s called. On add(1): 1 is appended to the shared list → [1] On add(2): the same list is reused, so 2 is appended → [1, 2]
English
0
0
0
208
Python Developer
Python Developer@Python_Dv·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
21
2
80
9.8K
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv Answer: B) Odd num = 7 → 7 % 2 = 1 (not 0), so the if condition is false and the else block runs, printing "Odd".
English
0
0
0
69
Python Developer
Python Developer@Python_Dv·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
33
7
79
7.9K
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv "python"[2:5] uses string slicing in Python. Indexing starts at 0 p y t h o n 0 1 2 3 4 5 Slice [2:5] means: start at index 2 (t) stop before index 5 So it takes characters at indices 2, 3, 4 → t h o Output: tho
English
0
0
0
71
Python Developer
Python Developer@Python_Dv·
🤔🚀 Comment your answers below! 👇
Python Developer tweet media
English
74
14
145
19.1K
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv x = 5 is a class variable When you access self.x, Python first looks for x in the instance Not found → it falls back to the class So self.x resolves to A.x, which is 5
English
0
0
1
351
Python Developer
Python Developer@Python_Dv·
Comment below the output! 😃👇
Python Developer tweet media
English
14
8
58
9.5K
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv "python" and "3" become "python3" Len() count the characters of the final word Output:7
English
0
0
1
772
Python Developer
Python Developer@Python_Dv·
Comment below the output! 😃👇
Python Developer tweet media
English
39
7
122
13.9K
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv Default arguments are evaluated once at function definition. lst=[] is shared across calls unless a new list is passed. add(1) → [1], add(2) → [1,2] add(3, []) → [3] (new list) add(4) → [1,2,4] (original list resumes)
English
0
0
0
3
Python Developer
Python Developer@Python_Dv·
Comment below the output! 😃👇
Python Developer tweet media
English
17
5
86
7.7K
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv "5" is a string, multiplying a string by an integer repeat the string So: 555
English
0
0
0
280
Python Developer
Python Developer@Python_Dv·
Comment below the output! 😃👇
Python Developer tweet media
English
25
3
86
14.4K
Byte Focus Tech
Byte Focus Tech@ByteFocusB·
@Python_Dv X=[1,2,3,4,5] why x and y point to the same object in memory So y +=[4,5] is extending the list y.extend([4,5] Print(y is x) check the identity compares id(x) ==id(y) which reference the same object So : True
English
0
0
1
153
Python Developer
Python Developer@Python_Dv·
Comment below the output! 😃👇
Python Developer tweet media
English
18
4
78
12.4K