JOBSEEKERS
Login
Sign Up
Jobseeker
Employer
Staffing Firm
Direct Client
PHP interview questions part 2
PHP interview questions part 2
Back
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'
A. orangebanana
B. appleorange
C. orangeorange
D. appleapple
Show Correct Answer
Correct Answer is :
orangebanana
2. What is the output of the following? x = 123 for i in x: print(i)
A. last()
B. before()
C. prev()
D. previous()
Show Correct Answer
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)
A. 3
B. 4
C. 5
D. 6
Show Correct Answer
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)
A. count()
B. array_count()
C. array_count_values()
D. count_values()
Show Correct Answer
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)
A. I like Volvo, Toyota and BMW
B. I like Volvo, BMW and Toyota
C. I like BMW, Volvo and Toyota
D. I like Toyota, BMW and Volvo
Show Correct Answer
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])
A. Array ( Peter Ben Joe )
B. Array ( [Peter] => 35 [Ben] => 37 [Joe] => 43 )
C. Array ( 35 37 43 )
D. Array ( [35] => Peter [37] => Ben [43] => Joe )
Show Correct Answer
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)
A. Array ( [A] => 5 [Cat] => 2 [Dog] => 2 [Tiger] => 1 )
B. Array ( [A] => 2 [Cat] => 2 [Dog] => 1 [Tiger] => 1 )
C. Array ( [A] => 6 [Cat] => 1 [Dog] => 2 [Tiger] => 1 )
D. Array ( [A] => 2 [Cat] => 1 [Dog] => 4 [Tiger] => 1 )
Show Correct Answer
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])
A. Array ( [d] => yellow )
B. Array ( [i] => orange )
C. Array ( [h] => orange )
D. Array ( [d] => yellow [h] => orange )
Show Correct Answer
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)
A. Array ( [a] => blue [b] => yellow [c] => red [d] => green )
B. Array ( [0] => blue [1] => yellow [2] => red [3] => green )
C. Array ( [0] => red [1] => green [2] => blue [3] => yellow )
D. Array ( [a] => red [b] => green [c] => blue [d] => yellow )
Show Correct Answer
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)
A. india
B. india
C. china
D. china
Show Correct Answer
Correct Answer is :
india
11. What is the output of the following? d = {0, 1, 2} for x in d: print(d.add(x))
A. Array ( [1] => hello [4] => hello [5] => php )
B. Array ( [1] => hello [2] => hello [3] => hello [4] => hello )
C. Array ( [1] => hello [2] => hello [3] => hello [4] => hello [5] => php )
D. Array ( [1] => hello [2] => hello [3] => hello [4] => hello )
Show Correct Answer
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)
A. Sam is the brother of Bob and Jack
B. Sam is the brother of Bob and Bob)
C. Sam is the brother of Jack and Bob)
D. Error
Show Correct Answer
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)
A. Sam is the brother of Bob and Bob) $brother
B. Sam is the brother of Bob and Bob)
C. $brother
D. Error
Show Correct Answer
Correct Answer is :
Error
14. What is the output of the following? for i in range(int(2.0)): print(i)
A. Array ( [0] => LA [1] => Paris [2] => Paris )
B. Array ( [0] => NYC [1] => LA [2] => Paris)
C. Array ( [0] => NYC [1] => LA [2] => Paris [3] => Paris )
D. None of the mentioned
Show Correct Answer
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)
A. Array ( [Harry] => 21 [Ron] => 23 [Malfoy] => 21 )
B. Array ( [HARRY] => 21 [RON] => 23 [MALFOY] => 21 )
C. Array ( [HARRY] => 21 [RON] => 23 )
D. Array ( [Harry] => 21 [Ron] => 23 )
Show Correct Answer
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)
A. Array ( [red] => red [green] => green [blue] => blue [yellow] => yellow )
B. Array ( [a] => a [b] => b [c] => c [d] => d )
C. Array ( [red] => a [green] => b [blue] => c [yellow] => d )
D. Array ( [a] => red [b] => green [c] => blue [d] => yellow )
Show Correct Answer
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)
A. Array ( [a] => red [b] => green [c] => blue )
B. Array ( [a] => red [b] => green [c] => blue [d] => yellow )
C. Array ( [e] => red [f] => green [g] => blue )
D. Array ( [a] => red [b] => green [c] => blue [d] => yellow [e] => red [f] => green [g] => blue )
Show Correct Answer
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)
A. 24
B. 120
C. 10
D. 60
Show Correct Answer
Correct Answer is :
120
19. What is the output of the following? for i in 'abcd'[::-1]: print (i)
A. a
B. b
C. c
D. d
Show Correct Answer
Correct Answer is :
c
20. What is the output of the following? for i in '': print (i)
A. Array ( [1] => Mumbai [0] => Beijing )
B. Array ( [0] => NYC [1] => London )
C. Array ( [1] => NYC [0] => London )
D. Array ( [0] => Mumbai [1] => Beijing )
Show Correct Answer
Correct Answer is :
Array ( [0] => Mumbai [1] => Beijing )
Similar Interview Questions
Search for latest jobs
Find Jobs