Search test library by skills or roles
⌘ K

Adaface Sample Python Questions

Here are some sample Python questions from our premium questions library (10273 non-googleable questions).

Skills

🧐 Question

Medium

ZeroDivisionError and IndexError
Exceptions
Solve
                                    What will the following Python code output?
                                    
 image

Options:

  • B C D E
  • B C E
  • C D E
  • C E
  • C
  • A D
  • A D E
  • A E

Hard

Session
File Handling
Dictionary
Solve
 image
                                    The function high_sess should compute the highest number of events per session of each user in the database by reading a comma-separated value input file of session data. The result should be returned from the function as a dictionary. The first column of each line in the input file is expected to contain the user’s name represented as a string. The second column is expected to contain an integer representing the events in a session. Here is an example input file:
                                    
                                    Tony,10
            Stark,12
            Black,25
            Your program should ignore a non-conforming line like this one.
            Stark,3
            Widow,6
            Widow,14
                                    
                                    The resulting return value for this file should be the following dictionary: { 'Stark':12, 'Black':25, 'Tony':10, 'Widow':14 }
                                    
                                    What should replace the CODE TO FILL line to complete the function?
                                    
 image

Options:

  • OPTION 1
  • OPTION 2
  • OPTION 3
  • OPTION 4

Easy

Max Code
Arrays
Solve
                                    Below are code lines to create a Python function. Ignoring indentation, what lines should be used and in what order for the following function to be complete:
                                    
 image

Options:

  • 2, 8, 4, 5, 6
  • 2, 3, 7, 5, 6
  • 3, 2, 7, 5, 9
  • 3, 2, 4, 5, 9
  • 2, 3, 4, 1, 6
  • 2, 3, 7, 1, 6
🧐 Question🔧 Skill

Medium

ZeroDivisionError and IndexError
Exceptions
2 mins
Python
Solve

Hard

Session
File Handling
Dictionary
2 mins
Python
Solve

Easy

Max Code
Arrays
2 mins
Python
Solve
🧐 Question🔧 Skill💪 Difficulty⌛ Time
ZeroDivisionError and IndexError
Exceptions
Python
Medium2 minsSolve
Session
File Handling
Dictionary
Python
Hard2 minsSolve
Max Code
Arrays
Python
Easy2 minsSolve

Adaface questions are trusted by enterprises globally

Amazon Morgan Stanley Vodafone United Nations HCL PayPal Bosch WeWork Optimum Solutions Deloitte Microsoft NCS Doubtnut Sokrati J&T Express Capegemini

We evaluated several of their competitors and found Adaface to be the most compelling. Great default library of questions that are designed to test for fit rather than memorization of algorithms.


Swayam Narain, CTO, Affable

hashtag image heart icon Swayam
Join 1200+ companies in 75+ countries.
Try the most candidate friendly skills assessment tool today.
Ready to streamline your recruitment efforts with Adaface?
Ready to streamline your recruitment efforts with Adaface?
Chat with us
40 min tests.
No trick questions.
Accurate shortlisting.