350-401 Exam QuestionsBrowse all questions from this exam

350-401 Exam - Question 851


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

Show Answer
Correct Answer: AB

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

10 comments
Sign in to comment
AlondrixOption: A
Nov 4, 2023

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
Jul 20, 2024

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

sharonmiller
Jul 20, 2024

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

gorillaenhancedOption: A
Feb 12, 2024

Answer is A

reheheeeeheOption: A
Dec 11, 2023

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

AM17212Option: A
Jan 28, 2024

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

BoyuanLIUOption: A
Oct 31, 2023

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.

Will_91Option: A
Nov 3, 2023

Tested its A

Osama_anwarOption: A
Mar 13, 2024

A is correct

Jakubu1
Dec 12, 2023

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
Jan 28, 2024

It is A

SeMo0o0oOption: A
May 25, 2024

i will also go with A, trusting the others

SeMo0o0oOption: A
Jun 13, 2024

i will also go with A, trusting the others