Top 10 Python Interview Questions 2021

# 1 What’s Pickling and Unpickling?

  • Pickling –  the process of a Python object hierarchy being converted into a byte stream
  • Unpickling – is the inverse operation, where a byte stream is converted back into an object hierarchy.

Pickling is also called serializationmarshalling, or flattening.

# 2 What Is the Difference Between range() and xrange() Functions in Python?

  • range() – range returns a Python list object. Range keeps the entire list of numbers in memory.
  • xrange() – returns an iterator and only keeps one number in memory at a time.

# 3 How to create a random number?

Use the random module. This module is used to generate random numbers.

# Import random 
import random 

# 4 How would you make a string all Upper Case?

var='codeit'
print(var.upper())

# 5 What is split used for?

split() method is used to separate a given string.

var="code it blog "
print(var.split())

# 6 How can files be deleted in Python?

 import the OS Module to delete a file.

import os
os.remove("File_Name.txt")

# 7 How do you calculate percentiles ?

import the module Numpy

import numpy as np
varArray = np.array([1,2,3,4,5,6,7,8,9,10])
p = np.percentile(varArray, 75) #Returns 75th percentile
print(p)

# 8 What is unittest in Python ?

Python unittest module is used to test a unit of source code.

# 9 What is a dictionary in Python and how do you create one?

 Dictionaries are used to store data values in key:value pairs

my_dict = {'Pet':'Dog', 'Size': 'Small'}
print(my_dict)

# 10 How many basic types of functions are available in Python?

Python has two types of functions.

1. Built-in

2. User-defined

Some Built-in functions include print(), len(),set() and int()

Android Studio Loading Animation Between Activities

Progress Dialog is dialog showing a progress indicator and an optional text message or view. The methods of Progress Dialog being used in this tutorial are: ProgressDialog.setTitle() – Used to set title of dialog box ProgressDialog.setMessage() – Used to set dialog message being displayed ProgressDialog.setProgressStyle() – Choose the style of indicator ProgressDialog.dismiss() – Dismiss the … Read more Android Studio Loading Animation Between Activities

Android Studio Tutorial SeekBar

SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch thumb and drag left or right to set the current progress level or various other task. In this example, the seekbar will be used to display a percentage. As the user moves the SeekBar left to right the percentage value … Read more Android Studio Tutorial SeekBar

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s