PHP interview questions part 2

PHP interview questions part 2

Take as many assements as you can to improve your validate your skill rating

Total Questions: 20

1. What is the output of the following? x = 'abcd' for i in range(len(x)): print(x) x = 'a'

Correct Answer is : orangebanana

2. What is the output of the following? x = 123 for i in x: print(i)

Correct Answer is : prev()

3. What is the output of the following? d = {0: 'a', 1: 'b', 2: 'c'} for i in d: print(i)

Correct Answer is : 6

4. What is the output of the following? d = {0: 'a', 1: 'b', 2: 'c'} for x, y in d: print(x, y)

Correct Answer is : array_count_values()

5. What is the output of the following? d = {0: 'a', 1: 'b', 2: 'c'} for x, y in d.items(): print(x, y)

Correct Answer is : I like Toyota, BMW and Volvo

6. What is the output of the following? d = {0: 'a', 1: 'b', 2: 'c'} for x in d.keys(): print(d[x])

Correct Answer is : Array ( [35] => Peter [37] => Ben [43] => Joe )

7. What is the output of the following? d = {0: 'a', 1: 'b', 2: 'c'} for x in d.values(): print(x)

Correct Answer is : Array ( [A] => 5 [Cat] => 2 [Dog] => 2 [Tiger] => 1 )

8. What is the output of the following? d = {0: 'a', 1: 'b', 2: 'c'} for x in d.values(): print(d[x])

Correct Answer is : Array ( [d] => yellow )

9. What is the output of the following? d = {0, 1, 2} for x in d.values(): print(x)

Correct Answer is : Array ( [a] => red [b] => green [c] => blue [d] => yellow )

10. What is the output of the following? d = {0, 1, 2} for x in d: print(x)

Correct Answer is : india

11. What is the output of the following? d = {0, 1, 2} for x in d: print(d.add(x))

Correct Answer is : Array ( [1] => hello [2] => hello [3] => hello [4] => hello [5] => php )

12. What is the output of the following? for i in range(0): print(i)

Correct Answer is : Sam is the brother of Bob and Bob)

13. What is the output of the following? for i in range(2.0): print(i)

Correct Answer is : Error

14. What is the output of the following? for i in range(int(2.0)): print(i)

Correct Answer is : Array ( [0] => LA [1] => Paris [2] => Paris )

15. What is the output of the following? for i in range(float('inf')): print (i)

Correct Answer is : Array ( [HARRY] => 21 [RON] => 23 )

16. What is the output of the following? for i in range(int(float('inf'))): print (i)

Correct Answer is : Array ( [red] => a [green] => b [blue] => c [yellow] => d )

17. What is the output of the following? for i in [1, 2, 3, 4][::-1]: print (i)

Correct Answer is : Array ( [a] => red [b] => green [c] => blue )

18. What is the output of the following? for i in ''.join(reversed(list('abcd'))): print (i)

Correct Answer is : 120

19. What is the output of the following? for i in 'abcd'[::-1]: print (i)

Correct Answer is : c

20. What is the output of the following? for i in '': print (i)

Correct Answer is : Array ( [0] => Mumbai [1] => Beijing )

Similar Interview Questions

    Search for latest jobs

    Icon
    Icon