Jimmy Fikes

2K posts

Jimmy Fikes banner
Jimmy Fikes

Jimmy Fikes

@akajim

Christian, Septuagenarian, married since 1970, dad of 4, grandpa to 6, retired pastor, teacher, everything MS Excel, programmer, biblical studies, UAPs

ÜT: 29.575152,-95.577749 Katılım Mayıs 2009
278 Takip Edilen176 Takipçiler
Jimmy Fikes
Jimmy Fikes@akajim·
@r0ktech 38. a is a string ('3') and is then repeated twice. So after line 2, a is '33'. In the print statement a is cast as an int and then 33 is added to 5 -> so 38.
English
0
0
0
130
Jimmy Fikes
Jimmy Fikes@akajim·
@clcoding Error. Dictionary keys must be immutable. This snippet is trying to create a dictionary key with a list, which is mutable.
English
0
0
0
77
Python Coding
Python Coding@clcoding·
What will be the output of the following Python code? d = {} key = [1, 2] d[key] = "value" print(d)
English
6
1
18
5.6K
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr A. -1 refers to the last element in the list. Counting backwards to -3 points to the 2. Start with the 2 and step forward by one but stop before you get to -1 gives us [2,3].
English
0
0
1
74
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
14
1
40
4.7K
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr A. The original list, [1,2] is replicated twice and results in [1,2,1,2].
English
0
0
1
600
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
21
1
88
10.9K
Jimmy Fikes
Jimmy Fikes@akajim·
@Python_Dv The last line (as shown in this snippet) is not indented properly and should raise an indentation error. If the author meant for the last line to be on the left margin, the output would be A\nC.
English
0
0
1
185
Jimmy Fikes
Jimmy Fikes@akajim·
@Python_Dv B. b creates a shallow copy of a and the first item in b is changed to 100. If we print(b), we get [100,2,3] but the example asks for print(a) which is still [1,2,3]
English
0
0
0
51
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr 3. List range(5) uses the values 0,1,2,3,4 to create a list that results in [0,1,4,9,16] (each item being squared). Next, the List variable is reassigned to the pop() method of the original list and 16 is returned and added to 16. So, 16+16 is 32.
English
0
0
0
135
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
12
10
74
6.9K
Jimmy Fikes
Jimmy Fikes@akajim·
@clcoding Answer is 2. The reduce function acts on each item in an iterable. A function is applied that works through each item (in a list in this example) and returns a single result. 2-1 is 1, and 3-1 is 2.
English
0
0
0
58
Python Coding
Python Coding@clcoding·
What will be the output of the following Python code? from functools import reduce data = [1, 2, 3] result = reduce(lambda x, y: y - x, data) print(result)
English
7
6
29
5.6K
Jimmy Fikes
Jimmy Fikes@akajim·
@Python_Dv B. Replication before concatenation (works the same as multiplication before addition). So (3 * '2') is 222. Then, concatenate 1 to 222 to get 2221.
English
0
0
1
170
Jimmy Fikes
Jimmy Fikes@akajim·
@Python_Dv D. Sets can handle only immutable values and a list is mutable.
English
0
0
1
93
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr A. A string replicated twice is no different than the same string concatenated twice. This is True.
English
0
0
2
555
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
19
12
88
10.3K
Jimmy Fikes
Jimmy Fikes@akajim·
@Python_Dv 1. The result is 8. x and y are integers and they are easily added.
English
0
0
2
125
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr 544. Multiplication before addition. 4 is repeated and 5 is concatenated onto the beginning of 44.
English
0
0
6
845
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
30
11
118
14.2K
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
35
3
87
11.7K
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr 'Oops' will print. The first if statement is True since 3 is greater than 2. Then, the 2nd if statement can run (since the 1st one is True). However, the 2nd statement is False since 3 is not greater than 5. So, the else statement executes and prints 'Oops'
English
0
0
3
506
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
16
15
87
7.7K
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
20
7
64
7.7K
Jimmy Fikes
Jimmy Fikes@akajim·
@PythonPr This returns None because the sort() method changes the list x in place - it does not create a new list object as we would have it we used sorted() instead of sort(). If we change the list first, and then print(x), we will see the original list sorted by length of each element.
English
0
0
4
172
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
4
5
32
5.1K
Jimmy Fikes
Jimmy Fikes@akajim·
@Python_Dv C. Syntax error since the assignment operator (=) is used instead of the equality operator (==).
English
0
0
3
192