Refer to the exhibit. What is the output of this code?
Refer to the exhibit. What is the output of this code?
Given the format strings {'#:<15} and {'#:<10'}, the key and value are filled with '#' characters to make the lengths 15 and 10 characters, respectively. In this case, {:#<15} means the total field width is 15 characters filled with '#' for padding. Similarly, {:#<10} means the total field width is 10 characters filled with '#' for padding. For the '1st_item', the key is 8 characters long, so 7 '#' characters will be added to make it 15 characters long. The value '645298791871446' is already exactly 15 characters long, so it remains unchanged. For the '2nd_item_that_must_display', the key is longer than 15 characters, so it stays unchanged. The value 'jlugyydt' is 8 characters long, so 2 '#' characters will be added to make it 10 characters long. Therefore, the output is: 1st_item####### : 645298791871446 2nd_item_that_must_display : jlugyydt##
Answer is A. {:#<15} - This is adding # to the returned string to fill 15 characters. It does nothing if the string is greater than 15 characters. {:#<10} - This is adding # to the returned string to fill 10 characters. It does nothing if the string is greater than 10 characters.
.. the string is already 15 characters... so why is it adding all the '#'??
nevermind... i blame cisco lol.. the key AND the value characters are counted... got it.
Answer is A
I have applied the same script and the output is A: >>> args_dict = { ... '1st_item':'645298791871446', ... '2nd_item_that_must_display':'jlugyydt' ... } >>> for key,value in args_dict.items(): ... txt = '{:#<15} : {:#<10}'.format(key,str(value)) ... print(txt) ... 1st_item####### : 645298791871446 2nd_item_that_must_display : jlugyydt## >>>
https://www.online-python.com/ args_dict = { '1st_item':'645298791871446', '2nd_item_that_must_display':'jlugyydt' } for key,value in args_dict.items(): txt = '{:#<15} : {:#<10}'.format(key,str(value)) print(txt) Output: 1st_item####### : 645298791871446 2nd_item_that_must_display : jlugyydt##
A is correct
Tested its A
in "B" - The value '6452987918' is truncated to 10 characters, which does not happen in Python's string formatting; the entire string should be displayed even if it exceeds the specified width.
i will also go with A, trusting the others
i will also go with A, trusting the others
Did anyone take the exam and have this question? What was the answer? While Python's books may have one answer, Cisco's exam's decision for the correct answer is what decides the correct answer for Cisco unfortunately, so would love to now.
It is A