PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Thursday, August 18, 2022

[FIXED] What call to the function will result in the following output?

 August 18, 2022     dictionary, output, python, set     No comments   

Issue

def doh(a, b, c):
    if a[str(b)] + c == a[c + 'x']:
        print(b + 2)

expect output:

11

Where do I start to approach? And what are these variables type?


Solution

Solution

Pass these values for variable a,b,c

variable a must be a dictionary, variable b should be integer 9 and variable c should be a string or alphabet

#function defenition
def doh(a, b, c):
    if a[str(b)] + c == a[c + 'x']:
        print(b + 2)

a = {'9':'d','cx':'dc'}
b=9
c='c'
doh(a, b, c)

Result

11

Another Solution

a = {'9':'michael','hix':'michaelhi'}
b=9
c='hi'
doh(a, b, c)

So the relation should be like in the following figure. go to this link to see the relation

I hope this would be helpful



Answered By - Littin Rajan
Answer Checked By - Dawn Plyler (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing