exam questions

Exam 350-401 All Questions

View all questions & answers for the 350-401 exam

Exam 350-401 topic 1 question 736 discussion

Actual exam question from Cisco's 350-401
Question #: 736
Topic #: 1
[All 350-401 Questions]

Refer to the exhibit.



What is displayed when the code is run?

  • A. The answer is 100
  • B. The answer is 5
  • C. The answer is 25
  • D. The answer is 70
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
kmb192006
Highly Voted 2 years ago
Selected Answer: C
If num is not a number then the method will throw out exception then the answer will be 100, for example putting a character "a" in to method - magic("a") But the main() method has statically defined the num as 5 - magic(5), which will never throw out an exception. answer should always be num + 2 * 10, which is 25 in this program So the answer is C
upvoted 20 times
Leoveil
1 year, 10 months ago
good explanation thanks
upvoted 5 times
...
...
AbdullahMohammad251
Most Recent 7 months ago
Selected Answer: C
The except block is used for error handling. In this scenario, if an error occurs during the execution of the try block—such as when a string is passed as an argument to the magic function—the except block will execute. In this case, the variable answer will be assigned a value of 100, which will then be returned. def main(): print("The answer is " + str(magic("hi"))) def magic(num): try: answer = num + 2 * 10 except: answer = 100 return answer main() Output: The answer is 100 === Code Execution Successful === https://www.programiz.com/python-programming/online-compiler/ Since '5' is a valid input to the "magic" function the answer is (5 + 2 * 10 = 25) Output: The answer is 25 === Code Execution Successful ===
upvoted 3 times
...
[Removed]
11 months, 1 week ago
Selected Answer: C
C is correct num is 5, so answer = 5 + 2*10 = 25
upvoted 1 times
...
[Removed]
11 months, 3 weeks ago
C is correct
upvoted 1 times
...
slacker_at_work
1 year, 2 months ago
Inside the magic() function, it tries to perform the operation num + 2 * 10. In this case, num is 5, so answer = 5 + 2 * 10, resulting in answer = 25.
upvoted 1 times
...
cwauch
1 year, 3 months ago
Selected Answer: C
Just use PEMDAS people. Answer is 25
upvoted 3 times
...
Tadese
1 year, 4 months ago
Selected Answer: C
def main(): print("The answer is" +str(magic(5))) def magic(num): try: answer=num+2*10 except: answer=100 return answer main() Output is 25
upvoted 4 times
...
Entivo
1 year, 10 months ago
Selected Answer: C
It is C - I just tried it at programiz.com It adds the number (in this case, 5) to the calculated value of 2*10 (which is 20), hence 25.
upvoted 2 times
...
net_eng10021
1 year, 11 months ago
C def main(): print(str(magic(5))) def magic(num): try: answer = num+2*10 except: answer = 100 return answer main()
upvoted 1 times
net_eng10021
1 year, 11 months ago
Ran the above code and it does return 25
upvoted 1 times
...
...
Farida_Fathi
2 years ago
Selected Answer: C
Selected Answer: C
upvoted 2 times
...
Rman0059
2 years, 1 month ago
Selected Answer: C
choose C
upvoted 2 times
...
RayZheng
2 years, 1 month ago
Selected Answer: C
The answer should be C
upvoted 2 times
...
Nickplayany
2 years, 2 months ago
Selected Answer: C
answer = num + 2 * 10 5 + 20
upvoted 3 times
...
makarov_vg
2 years, 2 months ago
Answer C https://www.programiz.com/python-programming/online-compiler/ def main(): print (str(magic(5))) def magic(num): try: answer = num + 2 * 10 except: answer = 100 return answer main()
upvoted 2 times
XDR
2 years ago
Yes. The input could be a string.
upvoted 1 times
...
...
Symirnian
2 years, 2 months ago
Answer is 25, why is there an exception here otherwise?
upvoted 1 times
XDR
2 years ago
Yes. The input could be a string.
upvoted 1 times
RickAO76
1 year ago
- I do see what your saying - I tend to see and use input() as variables for change and anything else that in not for input is hard coded and not adjusted or seen by the user.
upvoted 1 times
...
RickAO76
1 year ago
Input is hard-coded as an integer, 5. How can it be a string ? string = "5", or str(5) Integer = 5
upvoted 1 times
RickAO76
1 year ago
The print statement - yes, the value is converted to a string. You can NOT add str() + int(), so it's just reverting the value back to string for a full print() statement.
upvoted 1 times
...
...
...
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago