Exam 350-401 All QuestionsBrowse all questions from this exam
Question 851

Refer to the exhibit. What is the output of this code?

    Correct Answer: A

    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##

Discussion
AlondrixOption: A

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.

sharonmiller

.. the string is already 15 characters... so why is it adding all the '#'??

sharonmiller

nevermind... i blame cisco lol.. the key AND the value characters are counted... got it.

gorillaenhancedOption: A

Answer is A

AM17212Option: 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## >>>

reheheeeeheOption: A

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##

Osama_anwarOption: A

A is correct

Will_91Option: A

Tested its A

BoyuanLIUOption: 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.

SeMo0o0oOption: A

i will also go with A, trusting the others

SeMo0o0oOption: A

i will also go with A, trusting the others

Jakubu1

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.

Mizuchan

It is A