Killer Python Practice PDF With 3100+ Python Examples
Killer Python Practice PDF With 3100+ Python Examples
Killer Python Practice PDF With 3100+ Python Examples
1
29 Check the File Size RUN CODE >>
30 Perform basic arithmetic operations RUN CODE >>
31 Check if a number is even or odd RUN CODE >>
32 Convert temperature units (Celsius to Fahrenheit) RUN CODE >>
Generates a list of all possible permutations from a given collection of distinct
33 RUN CODE >>
numbers.
34 Check the priority of the four operators (+, -, *, /). RUN CODE >>
35 Find the median among three given numbers. RUN CODE >>
Finds the value of n when n degrees of number 2 are written sequentially on a line
36 RUN CODE >>
without spaces between them.
Find the number of zeros at the end of a factorial of a given positive number.
37 RUN CODE >>
Range of the number(n): (1 <= n <= 2*109).
Find the number of notes (Samples of notes: 10, 20, 50, 100, 200, 500) against an
38 RUN CODE >>
amount. Range - Number of notes(n) : n (1 <= n <= 1000000).
Accepts a positive number and subtracts from it the sum of its digits, and so on.
39 RUN CODE >>
Continue this operation until the number is positive.
40 Find the total number of even or odd divisors of a given integer. RUN CODE >>
41 Find the digits that are missing from a given mobile number. RUN CODE >>
42 Find common divisors between two numbers in a given pair. RUN CODE >>
43 Sum of Two Numbers in Python RUN CODE >>
44 Multiplication Table in Python RUN CODE >>
45 Subtract Two Numbers in Python RUN CODE >>
46 Division of Two Numbers in Python RUN CODE >>
47 Multiplication of Two Numbers in Python RUN CODE >>
48 Min and Max Numbers in Python Using a User-defined Function RUN CODE >>
49 Minimum And Maximum Of A List Of Numbers In Python RUN CODE >>
50 Generate a Random Number in Python RUN CODE >>
51 Convert Kilometers to Miles in Python RUN CODE >>
52 Print Output Without a Newline in Python RUN CODE >>
53 Make a Simple Calculator RUN CODE >>
54 Create Calculator using Eval in Python RUN CODE >>
55 Sum three given integers. However, if two values are equal, the sum will be zero. RUN CODE >>
56 Sum two given integers. However, if the sum is between 15 and 20 it will return 20. RUN CODE >>
Returns true if the two given integer values are equal or their sum or difference is
57 RUN CODE >>
5.
58 Add two objects if both objects are integers. RUN CODE >>
2
59 Displays your name, age, and address on three different lines. RUN CODE >>
60 Solve (x + y) * (x + y). RUN CODE >>
Compute the future value of a specified principal amount, rate of interest, and
61 RUN CODE >>
number of years.
62 Calculate the distance between the points (x1, y1) and (x2, y2). RUN CODE >>
63 Check whether a file exists. RUN CODE >>
64 Determine if a Python shell is executing in 32bit or 64bit mode on OS. RUN CODE >>
65 Get OS name, platform and release information. RUN CODE >>
66 Locate Python site packages. RUN CODE >>
67 Calls an external command. RUN CODE >>
68 Retrieve the path and name of the file currently being executed. RUN CODE >>
69 Find out the number of CPUs used. RUN CODE >>
70 Parse a string to float or integer. RUN CODE >>
71 List all files in a directory. RUN CODE >>
72 Print without a newline or space. RUN CODE >>
73 Determine the profiling of Python programs. RUN CODE >>
74 Print to STDERR. RUN CODE >>
75 Access environment variables. RUN CODE >>
76 Get the current username. RUN CODE >>
77 Find local IP addresses using Python's stdlib. RUN CODE >>
78 Get the height and width of the console window. RUN CODE >>
79 Convert height (in feet and inches) to centimeters. RUN CODE >>
80 Calculate the hypotenuse of a right angled triangle. RUN CODE >>
81 Convert the distance (in feet) to inches, yards, and miles. RUN CODE >>
82 Convert all units of time into seconds. RUN CODE >>
Write a Python function that takes a sequence of numbers and determines
83 RUN CODE >>
whether all the numbers are different from each other.
Creates all possible strings using the letters 'a', 'e', 'i', 'o', and 'I'. Ensure that each
84 RUN CODE >>
character is used only once.
Removes and prints every third number from a list of numbers until the list is
85 RUN CODE >>
empty.
Identify unique triplets whose three elements sum to zero from an array of n
86 RUN CODE >>
integers.
87 Make combinations of 3 digits. RUN CODE >>
Prints long text, converts it to a list, and prints all the words and the frequency of
88 RUN CODE >>
each word.
3
89 Count the number of each character in a text file. RUN CODE >>
90 Retrieves the top stories from Google News. RUN CODE >>
91 Get a list of locally installed Python modules. RUN CODE >>
92 Display some information about the OS where the script is running. RUN CODE >>
93 Get an absolute file path. RUN CODE >>
94 Retrieves the date and time of file creation and modification. RUN CODE >>
95 Converts seconds into days, hours, minutes, and seconds. RUN CODE >>
96 Calculate the body mass index. RUN CODE >>
Convert pressure in kilopascals to pounds per square inch, a millimeter of mercury
97 RUN CODE >>
(mmHg) and atmosphere pressure.
98 Calculate sum of digits of a number. RUN CODE >>
99 Sort three integers without using conditional statements and loops. RUN CODE >>
100 Sort files by date. RUN CODE >>
101 Get a directory listing, sorted by creation date. RUN CODE >>
102 Get the details of the math module. RUN CODE >>
103 Calculate the midpoints of a line. RUN CODE >>
104 Hash a word. RUN CODE >>
105 Get the copyright information and write Copyright information in Python code. RUN CODE >>
Get the command-line arguments (name of the script, the number of arguments,
106 RUN CODE >>
arguments) passed to a script.
107 Test whether the system is a big-endian platform or a little-endian platform. RUN CODE >>
108 Find the available built-in modules. RUN CODE >>
109 Get the size of an object in bytes. RUN CODE >>
110 Get the current value of the recursion limit. RUN CODE >>
111 Concatenate N strings. RUN CODE >>
112 Get the ASCII value of a character. RUN CODE >>
113 Test whether all numbers in a list are greater than a certain number. RUN CODE >>
114 Calculate the sum of all items of a container (tuple, list, set, dictionary). RUN CODE >>
115 Get the size of a file. RUN CODE >>
116 Given variables x=30 and y=20, print "30+20=50". RUN CODE >>
117 Count the number of occurrences of a specific character in a string. RUN CODE >>
118 Check whether a file path is a file or a directory. RUN CODE >>
119 Perform an action if a condition is true. RUN CODE >>
Given a variable name, if the value is 1, display the string "First day of a Month!"
120 RUN CODE >>
and do nothing if the value is not equal.
121 Create a copy of its own source code. RUN CODE >>
4
122 Swap two variables. RUN CODE >>
123 Define a string containing special characters in various forms. RUN CODE >>
124 Get the Identity, Type, and Value of an object. RUN CODE >>
125 Convert the bytes in a given string to a list of integers. RUN CODE >>
126 Check whether a string is numeric. RUN CODE >>
127 Print the current call stack. RUN CODE >>
128 List the special variables used in the language. RUN CODE >>
129 Get system time. RUN CODE >>
130 Clear the screen or terminal. RUN CODE >>
131 Get the name of the host on which the routine is running. RUN CODE >>
132 Access and print a URL's content to the console. RUN CODE >>
133 Get system command output. RUN CODE >>
134 Extract the filename from a given path. RUN CODE >>
Get the effective group id, effective user id, real group id, and a list of
135 RUN CODE >>
supplemental group ids associated with the current process.
136 Get the users environment. RUN CODE >>
137 Divide a path by the extension separator. RUN CODE >>
138 Retrieve file properties. RUN CODE >>
139 Find the path to a file or directory when you encounter a path name. RUN CODE >>
140 Find the path to a file or directory when you encounter a path name. RUN CODE >>
141 Get numbers divisible by fifteen from a list using an anonymous function. RUN CODE >>
142 Make file lists from the current directory using a wildcard. RUN CODE >>
143 Remove the first item from a specified list. RUN CODE >>
144 Inputs a number and generates an error message if it is not a number. RUN CODE >>
145 Filter positive numbers from a list. RUN CODE >>
146 Compute the product of a list of integers (without using a for loop). RUN CODE >>
147 Print Unicode characters. RUN CODE >>
Prove that two string variables of the same value point to the same memory
148 RUN CODE >>
location.
149 Create a bytearray from a list. RUN CODE >>
150 Round a floating-point number to a specified number of decimal places. RUN CODE >>
151 Format a specified string and limit the length of a string. RUN CODE >>
152 Determine if a variable is defined or not. RUN CODE >>
153 Empty a variable without destroying it. RUN CODE >>
154 Determine the largest and smallest integers, longs, and floats. RUN CODE >>
155 Check whether multiple variables have the same value. RUN CODE >>
5
156 Sum all counts in a collection. RUN CODE >>
157 Get the actual module object for a given object. RUN CODE >>
158 Check whether an integer fits in 64 bits. RUN CODE >>
159 Check whether lowercase letters exist in a string. RUN CODE >>
160 Add leading zeroes to a string. RUN CODE >>
161 Uses double quotes to display strings. RUN CODE >>
162 Split a variable length string into variables. RUN CODE >>
163 List the home directory without an absolute path. RUN CODE >>
164 Calculate the time runs (difference between start and current time) of a program. RUN CODE >>
165 Input two integers on a single line. RUN CODE >>
166 Print a variable without spaces between values. RUN CODE >>
167 Find files and skip directories in a given directory. RUN CODE >>
168 Extract a single key-value pair from a dictionary into variables. RUN CODE >>
169 Convert true to 1 and false to 0. RUN CODE >>
170 Validate an IP address. RUN CODE >>
171 Convert an integer to binary that keeps leading zeros. RUN CODE >>
172 Convert decimal to hexadecimal. RUN CODE >>
Check if every consecutive sequence of zeroes is followed by a consecutive
173 RUN CODE >>
sequence of ones of same length in a given string. Return True/False.
Determine if the Python shell is executing in 32-bit or 64-bit mode on the operating
174 RUN CODE >>
system.
175 Check whether a variable is an integer or string. RUN CODE >>
176 Test if a variable is a list, tuple, or set. RUN CODE >>
177 Find the location of Python module sources. RUN CODE >>
Write a Python function to check whether a number is divisible by another number.
178 RUN CODE >>
Accept two integer values from the user.
Write a Python function to find the maximum and minimum numbers from a
179 RUN CODE >>
sequence of numbers.
Write a Python function that takes a positive integer and returns the sum of the
180 RUN CODE >>
cube of all positive integers smaller than the specified number.
Write a Python function to check whether a distinct pair of numbers whose product
181 RUN CODE >>
is odd is present in a sequence of integer values.
Object Oriented
1 Get the Class Name of an Instance in Python RUN CODE >>
2 Differentiate Between Type() and Isinstance() in Python RUN CODE >>
6
Control Flow
1 Implement a simple calculator using if-else statements RUN CODE >>
2 Find the largest among three numbers RUN CODE >>
3 Write a program to check if a year is a leap year RUN CODE >>
4 Implement a guessing game RUN CODE >>
5 Write a program to print the Fibonacci sequence RUN CODE >>
Functions
1 Create a function to calculate the factorial of a number RUN CODE >>
2 Write a function to check if a number is prime RUN CODE >>
3 Implement a function to find the greatest common divisor (GCD) of two numbers RUN CODE >>
4 Create a function to generate the nth Fibonacci number RUN CODE >>
5 Write a function to check if a string is an anagram RUN CODE >>
6 Display Powers of 2 upto N numbers in python RUN CODE >>
7 Display Powers of 2 Using Normal Function in python RUN CODE >>
8 Display Powers of 2 Using Anonymous Function in python RUN CODE >>
9 Check Numbers Divisible by Another Number in Python RUN CODE >>
10 Convert Decimal to Binary, Octal and Hexadecimal in python RUN CODE >>
11 Find ASCII Value of Character in python RUN CODE >>
12 Shuffle Deck of Cards in Python RUN CODE >>
13 Display Calendar in python RUN CODE >>
14 GCD of Two Numbers in Python Using Recursion RUN CODE >>
15 GCD of two numbers in python using In-Build Function RUN CODE >>
16 LCM Of Two Numbers In Python Using While Loop RUN CODE >>
17 LCM Of Two Numbers In Python Using Recursion RUN CODE >>
18 Find Sum of Natural Numbers in python Using Recursion RUN CODE >>
19 Find Factorial of Number in python Using Recursion RUN CODE >>
7
20 Convert Decimal to Binary in Python Using Recursion RUN CODE >>
21 Return Multiple Values From a Function in python RUN CODE >>
22 Temperature Conversion Program in Python RUN CODE >>
23 Quadratic Equation in Python Without Lambda RUN CODE >>
24 Leap Year Program In Python Using If Else RUN CODE >>
25 Binary to Decimal Conversion in Python RUN CODE >>
File Handling
1 Read data from a text file and display it RUN CODE >>
2 Write a program to copy content from one file to another RUN CODE >>
3 Parse a CSV file and perform operations on the data RUN CODE >>
4 Serialize and deserialize a Python object to/from a file RUN CODE >>
5 Implement a simple log file generator RUN CODE >>
Web Development
1 Create a basic Flask web application RUN CODE >>
2 Build a web scraper using BeautifulSoup RUN CODE >>
3 Implement a simple REST API using Flask RUN CODE >>
4 Connect to an external API and display the data RUN CODE >>
5 Create a basic Django project with a database model RUN CODE >>
Data Structures:
1 Implement a stack using a list RUN CODE >>
2 Create a queue using a linked list RUN CODE >>
3 Implement a binary search tree RUN CODE >>
4 Write a program to check for balanced parentheses in an expression RUN CODE >>
5 Implement a basic graph representation and traversal RUN CODE >>
Advanced Topics:
1 Perform matrix multiplication RUN CODE >>
2 Implement a basic neural network from scratch RUN CODE >>
3 Write a program for parallel processing using multiprocessing RUN CODE >>
4 Create a basic chat application using sockets RUN CODE >>
5 Implement a basic machine learning algorithm (e.g., linear regression) RUN CODE >>
8
Python JSON Exercises
1 Convert JSON data to Python object. RUN CODE >>
2 Convert Python object to JSON data. RUN CODE >>
3 Convert Python objects into JSON strings. Print all the values. RUN CODE >>
Convert Python dictionary object (sort by key) to JSON data. Print the object
4
members with indent level 4. RUN CODE >>
5 Convert JSON encoded data into Python objects. RUN CODE >>
6 Create a new JSON file from an existing JSON file. RUN CODE >>
7 Check whether an instance is complex or not. RUN CODE >>
8 Check whether a JSON string contains complex object or not. RUN CODE >>
9 Access only unique key value of a Python object. RUN CODE >>
Recursion
1 Calculate the sum of a list of numbers. RUN CODE >>
2 Convert an integer to a string in any base. RUN CODE >>
3 Sum recursion lists. RUN CODE >>
4 Get the factorial of a non-negative integer. RUN CODE >>
5 Solve the Fibonacci sequence using recursion. RUN CODE >>
6 Get the sum of a non-negative integer. RUN CODE >>
7 Calculate the sum of the positive integers of n+(n-2)+(n-4)... (until n-x =< 0). RUN CODE >>
8 Calculate the harmonic sum of n-1. RUN CODE >>
9 Calculate the geometric sum of n-1. RUN CODE >>
10 Calculate the value of 'a' to the power of 'b'. RUN CODE >>
11 Find the greatest common divisor (GCD) of two integers. RUN CODE >>
9
Add 'ing' at the end of a given string (length should be at least 3). If the given
6 string already ends with 'ing', add 'ly' instead. If the string length of the given string RUN CODE >>
is less than 3, leave it unchanged.
Find the first appearance of the substrings 'not' and 'poor' in a given string. If 'not'
7 follows 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the RUN CODE >>
resulting string.
Write a Python function that takes a list of words and return the longest word and
8 RUN CODE >>
the length of the longest one.
9 Remove the nth index character from a nonempty string. RUN CODE >>
Change a given string to a newly string where the first and last chars have been
10 RUN CODE >>
exchanged.
11 Remove characters that have odd index values in a given string. RUN CODE >>
12 Count the occurrences of each word in a given sentence. RUN CODE >>
Write a Python script that takes input from the user and displays that input back in
13 RUN CODE >>
upper and lower cases.
Accepts a comma-separated sequence of words as input and prints the distinct
14 RUN CODE >>
words in sorted form (alphanumerically).
15 Write a Python function to create an HTML string with tags around the word(s). RUN CODE >>
16 Write a Python function to insert a string in the middle of a string. RUN CODE >>
Write a Python function to get a string made of 4 copies of the last two characters
17 RUN CODE >>
of a specified string (length must be at least 2).
Write a Python function to get a string made of the first three characters of a
18 RUN CODE >>
specified string. If the length of the string is less than 3, return the original string.
19 Get the last part of a string before a specified character. RUN CODE >>
20 Write a Python function to reverse a string if its length is a multiple of 4. RUN CODE >>
Write a Python function to convert a given string to all uppercase if it contains at
21 RUN CODE >>
least 2 uppercase characters in the first 4 characters.
22 Sort a string lexicographically. RUN CODE >>
23 Remove a newline in Python. RUN CODE >>
24 Check whether a string starts with specified characters. RUN CODE >>
25 Display formatted text (width=50) as output. RUN CODE >>
26 Remove existing indentation from all of the lines in a given text. RUN CODE >>
27 Add prefix text to all of the lines in a string. RUN CODE >>
28 Set the indentation of the first line. RUN CODE >>
29 Print the following numbers up to 2 decimal places. RUN CODE >>
30 Print the following numbers up to 2 decimal places with a sign. RUN CODE >>
31 Print the following positive and negative numbers with no decimal places. RUN CODE >>
10
32 Print the following integers with zeros to the left of the specified width. RUN CODE >>
33 Print the following integers with '*' to the right of the specified width. RUN CODE >>
34 Display a number with a comma separator. RUN CODE >>
35 Format a number with a percentage. RUN CODE >>
36 Display a number in left, right, and center aligned with a width of 10. RUN CODE >>
37 Count occurrences of a substring in a string. RUN CODE >>
38 Reverse a string. RUN CODE >>
39 Reverse words in a string. RUN CODE >>
40 Strip a set of characters from a string. RUN CODE >>
41 Count repeated characters in a string. RUN CODE >>
Print the square and cube symbols in the area of a rectangle and the volume of a
42 RUN CODE >>
cylinder.
43 Print the index of a character in a string. RUN CODE >>
44 Check whether a string contains all letters of the alphabet. RUN CODE >>
45 Convert a given string into a list of words. RUN CODE >>
46 Lowercase the first n characters in a string. RUN CODE >>
47 Count and display vowels in text. RUN CODE >>
48 Split a string on the last occurrence of the delimiter. RUN CODE >>
49 Find the first non-repeating character in a given string. RUN CODE >>
Print all permutations with a given repetition number of characters of a given
50 RUN CODE >>
string.
51 Find the first repeated character in a given string. RUN CODE >>
Find the first repeated character in a given string where the index of the first
52 RUN CODE >>
occurrence is smallest.
53 Find the first repeated word in a given string. RUN CODE >>
54 Find the second most repeated word in a given string. RUN CODE >>
55 Remove spaces from a given string. RUN CODE >>
56 Move spaces to the front of a given string. RUN CODE >>
57 Find the maximum number of characters in a given string. RUN CODE >>
58 Capitalize the first and last letters of each word in a given string. RUN CODE >>
59 Remove duplicate characters from a given string. RUN CODE >>
60 Compute the sum of the digits in a given string. RUN CODE >>
61 Remove leading zeros from an IP address. RUN CODE >>
62 Find the maximum length of consecutive 0's in a given binary string. RUN CODE >>
Find all the common characters in lexicographical order from two given lower case
63 RUN CODE >>
strings. If there are no similar letters print "No common characters".
11
Make two given strings (lower case, may or may not be of the same length)
64 RUN CODE >>
anagrams without removing any characters from any of the strings.
Generate two strings from a given string. For the first string, use the characters
65 that occur only once, and for the second, use the characters that occur multiple RUN CODE >>
times in the said string.
66 Find the longest common sub-string from two given strings. RUN CODE >>
67 Concatenates uncommon characters from two strings. RUN CODE >>
68 Move all spaces to the front of a given string in a single traversal. RUN CODE >>
69 Remove all characters except a specified character from a given string. RUN CODE >>
Count Uppercase, Lowercase, special characters and numeric values in a given
70 RUN CODE >>
string.
Find the minimum window in a given string that will contain all the characters of
71 RUN CODE >>
another given string.
72 Find the smallest window that contains all characters in a given string. RUN CODE >>
Count the number of substrings from a given string of lowercase alphabets with
73 RUN CODE >>
exactly k distinct (given) characters.
74 Count the number of non-empty substrings of a given string. RUN CODE >>
Count characters at the same position in a given string (lower and uppercase
75 RUN CODE >>
characters) as in the English alphabet.
76 Find the smallest and largest words in a given string. RUN CODE >>
Count the number of substrings with the same first and last characters in a given
77 RUN CODE >>
string.
Determine the index of a given string at which a certain substring starts. If the
78 RUN CODE >>
substring is not found in the given string return 'Not found'.
79 Wrap a given string into a paragraph with a given width. RUN CODE >>
Print four integer values - decimal, octal, hexadecimal (capitalized), binary - in a
80 RUN CODE >>
single line.
81 Swap cases in a given string. RUN CODE >>
82 Convert a given Bytearray to a Hexadecimal string. RUN CODE >>
83 Delete all occurrences of a specified character in a given string. RUN CODE >>
84 Find the common values that appear in two given strings. RUN CODE >>
Check whether a given string contains a capital letter, a lower case letter, a
85 RUN CODE >>
number and a minimum length.
86 Remove unwanted characters from a given string. RUN CODE >>
87 Remove duplicate words from a given string. RUN CODE >>
88 Convert a given heterogeneous list of scalars into a string. RUN CODE >>
89 Find string similarity between two given strings. RUN CODE >>
12
90 Extract numbers from a given string. RUN CODE >>
Convert a hexadecimal color code to a tuple of integers corresponding to its RGB
91 RUN CODE >>
components.
92 Convert the values of RGB components to a hexadecimal color code. RUN CODE >>
93 Convert a given string to Camelcase. RUN CODE >>
94 Convert a given string to Snake case. RUN CODE >>
95 Decapitalize the first letter of a given string. RUN CODE >>
96 Split a multi-line string into a list of lines. RUN CODE >>
Check whether any word in a given string contains duplicate characters or not.
97 RUN CODE >>
Return True or False.
Add two strings as if they were numbers (positive integer values). Return a
98 RUN CODE >>
message if the numbers are strings.
99 Remove punctuation from a given string. RUN CODE >>
Replace each character of a word of length five and more with a hash character
100 RUN CODE >>
(#).
101 Capitalizes the first letter and lower cases the remaining letters in a given string. RUN CODE >>
102 Extract and display the name from a given Email address. RUN CODE >>
Remove repeated consecutive characters and replace them with single letters and
103 RUN CODE >>
print a updated string.
Takes two strings. Count the number of times each string contains the same three
104 RUN CODE >>
letters at the same index.
105 Takes a string and returns # on both sides of each element, which are not vowels. RUN CODE >>
Counts the number of leap years within the range of years. Ranges of years
106 RUN CODE >>
should be accepted as strings.
107 Insert space before every capital letter appears in a given word. RUN CODE >>
108 Takes a string and replaces all the characters with their respective numbers. RUN CODE >>
Calculate the sum of two numbers given as strings. Return the result in the same
109 RUN CODE >>
string representation.
Returns a string sorted alphabetically by the first character of a given string of
110 RUN CODE >>
words.
13
Decision Making and Loops
1 Factorial of the Number in Python using in-built Function RUN CODE >>
2 Factorial of the Number in Python using While Loop RUN CODE >>
3 Factorial of the Number in Python using For Loop RUN CODE >>
4 Factorial of a Number in Python using Recursion RUN CODE >>
5 Check if a Number is Positive, Negative or 0 in python RUN CODE >>
6 Find the Largest Among Three Numbers in python RUN CODE >>
7 Print All Prime Numbers in a Range Using Python RUN CODE >>
8 Find the Factorial of a Number in python RUN CODE >>
9 Print the Fibonacci sequence in python using While Loop RUN CODE >>
10 Print the Fibonacci sequence in python using For Loop RUN CODE >>
11 Display Fibonacci Sequence in python Using Recursion RUN CODE >>
12 Check Armstrong Number in Python Using Function RUN CODE >>
13 Check Armstrong Number in Python Using Recursion RUN CODE >>
14 Find the Sum of Natural Numbers in python RUN CODE >>
15 Iterate Over Dictionaries in Python Using Keys() Function RUN CODE >>
16 Iterate Over Dictionaries in Python Using for Loop RUN CODE >>
17 Iterate Over Dictionaries in Python Using Values() Function RUN CODE >>
18 Iterate Over Dictionaries in Python Using Items() Function RUN CODE >>
19 Iterate Over Dictionaries in Python Using Both Key() & Value() Function RUN CODE >>
20 Iterate Over Dictionaries in Python and Print Items in Key-value in Pair RUN CODE >>
21 Iterate Over Dictionaries in Python & Unpack the Dictionaries RUN CODE >>
22 Reverse a Number in python using for Loop RUN CODE >>
23 Reverse a Number in Python Using While Loop RUN CODE >>
24 Reverse a Number in python Using String slicing RUN CODE >>
25 Reverse a Number in python Using recursion RUN CODE >>
26 Compute the Power of a Number in python RUN CODE >>
27 Star Patterns (Pyramid Patterns) in Python RUN CODE >>
28 Printing Number Patterns in Python RUN CODE >>
29 Alphabet Pattern Programs in Python RUN CODE >>
30 Count Vowels in a string python in python RUN CODE >>
31 Count Vowels From a String In Python Using Comprehension Method RUN CODE >>
32 Count Vowels From a String In Python Using Recursive Method RUN CODE >>
33 Count Vowels From a String in Python Using Iterative Method RUN CODE >>
14
34 Count Alphabets in a String in python RUN CODE >>
Native Datatypes
1 Add Two Matrices in python RUN CODE >>
2 Transpose a Matrix in Python RUN CODE >>
3 Multiply Two Matrices in Python RUN CODE >>
4 Check Whether a String is Palindrome or Not in python RUN CODE >>
5 Remove Punctuations From a String in python RUN CODE >>
6 Remove Punctuations From a String in python using String Package RUN CODE >>
7 Remove Punctuations From a String in python using Regular expressions RUN CODE >>
8 Sort Words in Alphabetic Order in python RUN CODE >>
9 Illustrate Different Set Operations in python RUN CODE >>
10 Merge Two Dictionaries in Python RUN CODE >>
11 Access Index of a List in Python Using for Loop RUN CODE >>
12 Flatten a Nested List in Python Using a List Comprehension RUN CODE >>
13 Flatten a Nested List in python Using Nested for Loops RUN CODE >>
14 Flatten a Nested List in Python Using Itertools Package RUN CODE >>
15 Flatten a Nested List in python Using In-build sum() method RUN CODE >>
16 Flatten a Nested List in python Using lambda and reduce() RUN CODE >>
17 Slice Lists in python RUN CODE >>
18 Sort a Dictionary by Value in python RUN CODE >>
19 Check if a List is Empty or Not in Python RUN CODE >>
20 Check if a List is Empty or Not in Python Using len() Function RUN CODE >>
21 Check if a List is Empty or Not in Python by Comparing an Empty List RUN CODE >>
22 Check if a List is Empty or Not in Python Using _len_() RUN CODE >>
23 Check if a List is Empty or Not in Python Using NumPy Module RUN CODE >>
24 Concatenate Two Lists in Python Using + Operator RUN CODE >>
25 Concatenate Two Lists in Python Using Iterable Unpacking * Operator RUN CODE >>
26 Combine Two Lists in Python With Unique Values RUN CODE >>
27 Concatenate Two Lists in Python Using Extend() RUN CODE >>
28 Check if Key Exists in Dictionary Python RUN CODE >>
29 Check if Key Exists in Dictionary Python Using Keys() RUN CODE >>
30 Check if Key Exists in Dictionary Python Using Get() RUN CODE >>
31 Check if Key Exists in Dictionary Python Using Count() RUN CODE >>
32 Split a List Into Evenly Sized Chunks in Python Using Yield RUN CODE >>
15
33 Split a List Into Evenly Sized Chunks in Python Using for Loop RUN CODE >>
34 Split a List Into Evenly Sized Chunks in Python Using List Comprehension RUN CODE >>
35 Split a List Into Evenly Sized Chunks in Python Using Numpy RUN CODE >>
36 Split a List Into Evenly Sized Chunks in Python Using itertool RUN CODE >>
37 Split a List Into Evenly Sized Chunks in Python Using Collections RUN CODE >>
38 Split a List Into Evenly Sized Chunks Using Partial assignment in python RUN CODE >>
39 Convert String to Float in Python RUN CODE >>
40 Convert String Float Numeral Into Float in Python RUN CODE >>
41 Convert a String Into an Integer in Python RUN CODE >>
42 Convert a String Float Numeral Into an Integer in Python RUN CODE >>
43 Print Colored Text to the Terminal in python RUN CODE >>
44 Convert String to Date Time in Python RUN CODE >>
45 Find the Last Element of a List in Python Using Negative Indexing RUN CODE >>
46 Find the Last Element of a List in Python Using Slicing RUN CODE >>
47 Find the Last Element of a List in Python Using pop() Function RUN CODE >>
48 Find the Last Element of a List in Python Using for Loop RUN CODE >>
49 Get a Substring of a String in python RUN CODE >>
50 Randomly Select Element From List in Python Using randrange() RUN CODE >>
51 Randomly Select Element From List in Python Using sample() RUN CODE >>
52 Randomly Select Element From List in Python Using choices() RUN CODE >>
53 Check if a String is a Float Number in Python RUN CODE >>
54 Count Occurrences of Items in a Python List Using Loop RUN CODE >>
55 Count Occurrences of Items in a Python List Using count() RUN CODE >>
56 Count Occurrences of Items in a Python List Using counter() RUN CODE >>
57 Count Occurrences of Items in a Python List Using countof() RUN CODE >>
58 Count Occurrences of Items in a Python List Using Comprehension RUN CODE >>
59 Count Occurrences of Items in a Python List Using Pandas Library RUN CODE >>
60 Delete an Element From a Dictionary in Python Using Del Statement RUN CODE >>
61 Delete an Element From a Dictionary in Python Using clear() RUN CODE >>
62 Create a Long Multiline String in Python Using Triple Quotes RUN CODE >>
Create a Long Multiline String in Python Using Parentheses & Single/Double
63 RUN CODE >>
Quotes
64 Create a Long Multiline String in Python Using \ (Backslash) RUN CODE >>
65 Convert Two Lists Into a Dictionary in Python Using for Loop RUN CODE >>
66 Convert Two Lists Into a Dictionary in Python Using Dictionary Comprehension RUN CODE >>
16
67 Convert Two Lists Into a Dictionary in Python Using zip() Function RUN CODE >>
68 Convert Two Lists Into a Dictionary Using map() in python RUN CODE >>
69 Convert Two Lists Into a Dictionary Using enumerate() in python RUN CODE >>
70 Trim Whitespace From a String in Python RUN CODE >>
71 Iterate Through Two Lists in Parallel in python RUN CODE >>
72 Count the Number of Digits Present In a Number in python RUN CODE >>
73 Check If Two Strings are Anagram in python RUN CODE >>
74 Capitalize the First Character of a String in python RUN CODE >>
75 Compute all the Permutation of the String in python RUN CODE >>
76 Count the Number of Occurrence of a Character in String using python RUN CODE >>
77 Remove Duplicate Element From a List in python RUN CODE >>
Files
1 Copy a File in python RUN CODE >>
2 Append to a File in python RUN CODE >>
3 Find Hash of File in python RUN CODE >>
4 Get the File Name From the File Path in python RUN CODE >>
5 Get Line Count of a File in python RUN CODE >>
6 Check the File Size in python RUN CODE >>
7 Catch Multiple Exceptions in One Line in python RUN CODE >>
8 Merge Mails in python RUN CODE >>
9 Python Program Read a File Line by Line Into a List in python RUN CODE >>
10 Find the Size (Resolution) of an Image in python RUN CODE >>
11 Extract Extension From the File Name in python RUN CODE >>
12 Find All Files with .txt Extension Present Inside a Directory in python RUN CODE >>
13 Get File Creation and Modification Date in python RUN CODE >>
14 Get the Full Path of the Current Working Directory in python RUN CODE >>
Advanced
1 Measure the Elapsed Time in Python RUN CODE >>
2 Represent enum in python RUN CODE >>
3 Create a Countdown Timer in python RUN CODE >>
4 Convert Bytes to a String in python RUN CODE >>
17
Python OOPS
Create a class representing a Circle. Include methods to calculate its area and
1 RUN CODE >>
perimeter.
Create a person class. Include attributes like name, country and date of birth.
2 RUN CODE >>
Implement a method to determine the person's age.
3 Create a calculator class. Include methods for basic arithmetic operations. RUN CODE >>
Create a class that represents a shape. Include methods to calculate its area and
4 perimeter. Implement subclasses for different shapes like circle, triangle, and RUN CODE >>
square
Create a class representing a binary search tree. Include methods for inserting
5 RUN CODE >>
and searching for elements in the binary tree.
Create a class representing a stack data structure. Include methods for pushing
6 RUN CODE >>
and popping elements.
Create a class representing a linked list data structure. Include methods for
7 RUN CODE >>
displaying linked list data, inserting and deleting nodes.
Create a class representing a shopping cart. Include methods for adding and
8 RUN CODE >>
removing items, and calculating the total price.
Create a class representing a stack data structure. Include methods for pushing,
9 RUN CODE >>
popping and displaying elements.
Create a class representing a queue data structure. Include methods for
10 RUN CODE >>
enqueueing and dequeueing elements.
Create a class representing a bank. Include methods for managing customer
11
accounts and transactions. RUN CODE >>
18
Accepts a sequence of comma separated 4 digit binary numbers as its input. The
10 program will print the numbers that are divisible by 5 in a comma separated RUN CODE >>
sequence.
11 Accepts a string and calculates the number of digits and letters. RUN CODE >>
12 Check the validity of passwords input by users. RUN CODE >>
Find numbers between 100 and 400 (both included) where each digit of a number
13 is an even number. The numbers obtained should be printed in a RUN CODE >>
comma-separated sequence.
14 Print the alphabet pattern 'A'. RUN CODE >>
15 Check whether an alphabet is a vowel or consonant. RUN CODE >>
16 Convert a month name to a number of days. RUN CODE >>
17 Sum two integers. However, if the sum is between 15 and 20 it will return 20. RUN CODE >>
18 Checks whether a string represents an integer or not. RUN CODE >>
19 Check if a triangle is equilateral, isosceles or scalene. RUN CODE >>
Reads two integers representing a month and day and prints the season for that
20 RUN CODE >>
month and day.
21 Display the astrological sign for a given date of birth. RUN CODE >>
22 Display the sign of the Chinese Zodiac for the given year in which you were born. RUN CODE >>
23 Find the median of three values. RUN CODE >>
24 Get the next day of a given date. RUN CODE >>
Calculate the sum and average of n integer numbers (input from the user). Input 0
25 RUN CODE >>
to finish.
26 Create the multiplication table (from 1 to 10) of a number. RUN CODE >>
27 Construct the following pattern, using a nested loop number. RUN CODE >>
Exception Handling
1 Handle a ZeroDivisionError exception when dividing a number by zero. RUN CODE >>
Prompts the user to input an integer and raises a ValueError exception if the input
2 RUN CODE >>
is not a valid integer.
3 Opens a file and handles a FileNotFoundError exception if the file does not exist. RUN CODE >>
Prompts the user to input two numbers and raises a TypeError exception if the
4 RUN CODE >>
inputs are not numerical.
Opens a file and handles a PermissionError exception if there is a permission
5 RUN CODE >>
issue.
Executes an operation on a list and handles an IndexError exception if the index is
6 RUN CODE >>
out of range.
19
Prompts the user to input a number and handles a KeyboardInterrupt exception if
7 RUN CODE >>
the user cancels the input.
Executes division and handles an ArithmeticError exception if there is an
8 RUN CODE >>
arithmetic error.
Opens a file and handles a UnicodeDecodeError exception if there is an encoding
9 RUN CODE >>
issue.
Executes a list operation and handles an AttributeError exception if the attribute
10 RUN CODE >>
does not exist.
Uncategorized
Find those numbers which are divisible by 7 and multiples of 5, between 1500 and
1 RUN CODE >>
2700
2 Prints all the numbers from 0 to 6 except 3 and 6 using continue statement. RUN CODE >>
3 Display the astrological sign for a given date of birth. RUN CODE >>
4 Display the sign of the Chinese Zodiac for the given year in which you were born. RUN CODE >>
5 Get the sum of a non-negative integer. RUN CODE >>
6 Remove a specific item from a given list of lists. RUN CODE >>
7 Extract every first or specified element from a given two-dimensional list. RUN CODE >>
8 Combine two lists into another list randomly. RUN CODE >>
9 Interleave lists of varying lengths. RUN CODE >>
10 Find the maximum and minimum values in a given list of tuples. RUN CODE >>
11 Append the same value/a list multiple times to a list/list-of-lists RUN CODE >>
Check if a given list increases strictly. Moreover, if removing only one element from
12 RUN CODE >>
the list results in a strictly increasing list, we still consider the list true
13 Convert a given list of tuples to a list of strings. RUN CODE >>
14 Sort a given list of tuples by a specified element. RUN CODE >>
15 Find the indexes of all None items in a given list. RUN CODE >>
16 Join adjacent members of a given list. RUN CODE >>
17 Remove additional spaces from a given list. RUN CODE >>
18 Find the common tuples between two given lists. RUN CODE >>
Sum a list of numbers. sum the first number with the second and divide it by 2,
19 RUN CODE >>
then sum the second with the third and divide by 2, and so on.
Compute the sum of non-zero groups (separated by zeros) of a given list of
20 RUN CODE >>
numbers.
Merge two or more lists into a list of lists, combining elements from each of the
21 RUN CODE >>
input lists based on their positions.
22 Randomize the order of the values of a list, returning a new list. RUN CODE >>
20
Get the difference between two given lists, after applying the provided function to
23 RUN CODE >>
each list element of both.
24 Create a list with non-unique values filtered out. RUN CODE >>
25 Create a list with unique values filtered out. RUN CODE >>
Get every element that exists in any of the two given lists once, after applying the
26 RUN CODE >>
provided function to each element of both.
Find the index of the first element in the given list that satisfies the provided testing
27 RUN CODE >>
function.
28 Chunk a given list into smaller lists of a specified size. RUN CODE >>
29 Convert a given number (integer) to a list of digits. RUN CODE >>
Calculate the average of a given list, after mapping each element to a value using
30 RUN CODE >>
the provided function.
31 Get the 4th element from the last element of a tuple. RUN CODE >>
32 Check whether an element exists within a tuple. RUN CODE >>
34 Replace the last value of tuples in a list. RUN CODE >>
35 Calculate the product, multiplying all the numbers in a given tuple RUN CODE >>
Find all the unique combinations of 3 numbers from a given list of numbers,
36 RUN CODE >>
adding up to a target number.
Remove all duplicates from a given list of strings and return a list of unique strings.
37 RUN CODE >>
Use the Python set data type.
Accepts some words and counts the number of distinct words. Print the number of
38 distinct words and the number of occurrences of each distinct word according to RUN CODE >>
their appearance.
39 Add more elements to a deque object from an iterable object. RUN CODE >>
Find the majority element from a given array of size n using the Collections
40 RUN CODE >>
module.
Create an instance of an OrderedDict using a given dictionary. Sort the dictionary
41
during the creation and print the members of the dictionary in reverse order. RUN CODE >>
Get the current memory address and the length in elements of the buffer used to
42 RUN CODE >>
hold an array's contents. Also, find the size of the memory buffer in bytes.
43 Reads a string and interprets it as an array of machine values. RUN CODE >>
44 Get the array size of types unsigned integer and float. RUN CODE >>
Write a Python class to check the validity of a string of parentheses, '(', ')', '{', '}', '['
45 and ']. These brackets must be closed in the correct order, for example "()" and RUN CODE >>
"()[]{}" are valid but "[)", "({[)]" and "{{{" are invalid
46 Write a Python function that prints out the first n rows of Pascal's triangle. RUN CODE >>
21
find the second lowest total marks of any student(s) from the given names and
47 marks of each student using lists and lambda. Input the number of students, the RUN CODE >>
names and grades of each student.
22
27 Find the second smallest number in a list. RUN CODE >>
28 Find the second largest number in a list. RUN CODE >>
29 Get unique values from a list. RUN CODE >>
30 Get the frequency of elements in a list. RUN CODE >>
31 Count the number of elements in a list within a specified range. RUN CODE >>
32 Check whether a list contains a sublist. RUN CODE >>
33 Generate all sublists of a list. RUN CODE >>
Uses the Sieve of Eratosthenes method to compute prime numbers up to a
34 RUN CODE >>
specified number.
35 Create a list by concatenating a given list with a range from 1 to n. RUN CODE >>
36 Get a variable with an identification number or string. RUN CODE >>
37 Find common items in two lists. RUN CODE >>
38 Change the position of every n-th value to the (n+1)th in a list. RUN CODE >>
39 Convert a list of multiple integers into a single integer. RUN CODE >>
40 Split a list based on the first character of a word. RUN CODE >>
41 Create multiple lists. RUN CODE >>
42 Split a list into different variables. RUN CODE >>
43 Generate groups of five consecutive numbers in a list. RUN CODE >>
44 Convert a pair of values into a sorted unique array. RUN CODE >>
45 Select the odd items from a list. RUN CODE >>
46 Insert an element before each element of a list. RUN CODE >>
47 Print nested lists (each list on a new line) using the print() function. RUN CODE >>
48 Convert a list to a list of dictionaries. RUN CODE >>
49 Sort a list of nested dictionaries. RUN CODE >>
50 Split a list every Nth element. RUN CODE >>
51 Compute the difference between two lists. RUN CODE >>
52 Create a list with infinite elements. RUN CODE >>
53 Concatenate elements of a list. RUN CODE >>
54 Remove key-value pairs from a list of dictionaries. RUN CODE >>
55 Convert a string to a list. RUN CODE >>
56 Check if all items in a given list of strings are equal to a given string. RUN CODE >>
57 Replace the last element in a list with another list. RUN CODE >>
58 Check whether the n-th element exists in a given list. RUN CODE >>
59 Find a tuple, the smallest second index value from a list of tuples. RUN CODE >>
60 Create a list of empty dictionaries. RUN CODE >>
23
61 Print a list of space-separated elements. RUN CODE >>
62 Insert a given string at the beginning of all items in a list. RUN CODE >>
63 Iterate over two lists simultaneously. RUN CODE >>
64 Move all zero digits to the end of a given list of numbers. RUN CODE >>
65 Find the list in a list of lists whose sum of elements is the highest. RUN CODE >>
66 Find all the values in a list that are greater than a specified number. RUN CODE >>
67 Extend a list without appending. RUN CODE >>
68 Remove duplicates from a list of lists. RUN CODE >>
69 Find items starting with a specific character from a list. RUN CODE >>
70 Check whether all dictionaries in a list are empty or not. RUN CODE >>
71 Flatten a given nested list structure. RUN CODE >>
Remove consecutive (following each other continuously) duplicates (elements)
72 RUN CODE >>
from a given list.
73 Pack consecutive duplicates of a given list of elements into sublists. RUN CODE >>
Create a list reflecting the run-length encoding from a given list of integers or a
74 RUN CODE >>
given list of characters.
Create a list reflecting the modified run-length encoding from a given list of
75 RUN CODE >>
integers or a given list of characters.
76 Decode a run-length message. RUN CODE >>
77 Split a given list into two parts where the length of the first part of the list is given. RUN CODE >>
78 Remove the K'th element from a given list, and print the updated list. RUN CODE >>
79 Insert an element at a specified position into a given list. RUN CODE >>
80 Extract a given number of randomly selected elements from a given list. RUN CODE >>
81 Generate combinations of n distinct objects taken from the elements of a given list. RUN CODE >>
Round every number in a given list of numbers and print the total sum multiplied
82
by the length of the list. RUN CODE >>
Round the numbers in a given list, print the minimum and maximum numbers and
83 multiply the numbers by 5. Print the unique numbers in ascending order separated RUN CODE >>
by space.
84 Create a multidimensional list (lists of lists) with zeros. RUN CODE >>
85 Create a 3X3 grid with numbers. RUN CODE >>
Read a matrix from the console and print the sum for each column. As input from
86 the user, accept matrix rows, columns, and elements separated by a space (each RUN CODE >>
row).
Read a square matrix from the console and print the sum of the matrix's primary
87 diagonal. Accept the size of the square matrix and elements for each column RUN CODE >>
separated with a space (for every row) as input from the user.
24
89 Zip two given lists of lists. RUN CODE >>
90 Count the number of lists in a given list of lists. RUN CODE >>
91 Find a list with maximum and minimum lengths. RUN CODE >>
92 Check if a nested list is a subset of another nested list. RUN CODE >>
93 Count the number of sublists that contain a particular element. RUN CODE >>
94 Count the number of unique sublists within a given list. RUN CODE >>
95 Sort each sublist of strings in a given list of lists. RUN CODE >>
96 Sort a given list of lists by length and value. RUN CODE >>
Remove sublists from a given list of lists that contain an element outside a given
97 RUN CODE >>
range.
98 Scramble the letters of a string in a given list. RUN CODE >>
99 Find the maximum and minimum values in a given heterogeneous list. RUN CODE >>
100 Extract common index elements from more than one given list. RUN CODE >>
101 Sort a given matrix in ascending order according to the sum of its rows. RUN CODE >>
102 Extract specified size of strings from a give list of string values. RUN CODE >>
Extract specified number of elements from a given list, which follows each other
103 RUN CODE >>
continuously.
104 Find the difference between consecutive numbers in a given list. RUN CODE >>
105 Compute average of two given lists. RUN CODE >>
106 Count integers in a given mixed list. RUN CODE >>
107 Remove a specified column from a given nested list. RUN CODE >>
108 Extract a specified column from a given nested list. RUN CODE >>
109 Rotate a given list by a specified number of items in the right or left direction. RUN CODE >>
110 Find the item with the most occurrences in a given list. RUN CODE >>
111 Access multiple elements at a specified index from a given list. RUN CODE >>
112 Check whether a specified list is sorted or not. RUN CODE >>
113 Remove duplicate dictionary entries from a given list. RUN CODE >>
114 Extract the nth element from a given list of tuples. RUN CODE >>
115 Check if the elements of a given list are unique or not. RUN CODE >>
116 Sort a list of lists by a given index of the inner list. RUN CODE >>
117 Remove all elements from a given list that are present in another list. RUN CODE >>
Find the difference between elements (n+1th - nth) of a given list of numeric
118 RUN CODE >>
values.
119 Check if a substring appears in a given list of string values. RUN CODE >>
120 Create a list taking alternate elements from a given list. RUN CODE >>
121 Find nested list elements that are present in another list. RUN CODE >>
25
122 Find common elements in a nested list. RUN CODE >>
123 Reverse strings in a given list of string values. RUN CODE >>
124 Find the maximum and minimum product of pairs of tuples within a given list. RUN CODE >>
125 Calculate the product of the unique numbers in a given list. RUN CODE >>
126 Interleave multiple lists of the same length. RUN CODE >>
127 Remove words from a given list of strings containing a character or string. RUN CODE >>
Calculate the sum of the numbers in a list between the indices of a specified
128 RUN CODE >>
range.
129 Reverse each list in a given list of lists. RUN CODE >>
130 Count the same pair in three given lists. RUN CODE >>
131 Count the frequency of consecutive duplicate elements in a given list of numbers. RUN CODE >>
Find all index positions of the maximum and minimum values in a given list of
132 RUN CODE >>
numbers.
133 Check if two lists have the same elements in them in same order or not. RUN CODE >>
134 Find the difference between two lists including duplicate elements. RUN CODE >>
135 Iterate over all pairs of consecutive items in a given list. RUN CODE >>
136 Remove duplicate words from a given list of strings. RUN CODE >>
137 Find the first even and odd number in a given list of numbers. RUN CODE >>
Sort a given mixed list of integers and strings. Numbers must be sorted before
138 RUN CODE >>
strings.
139 Sort a given list of strings(numbers) numerically. RUN CODE >>
140 Remove a specific item from a given list of lists. RUN CODE >>
141 Remove empty lists from a given list of lists. RUN CODE >>
142 Sum a specific column of a list in a given list of lists. RUN CODE >>
143 Get the frequency of elements in a given list of lists. RUN CODE >>
144 Extract every first or specified element from a given two-dimensional list. RUN CODE >>
145 Generate a number in a specified range except for some specific numbers. RUN CODE >>
146 Generate a number in a specified range (1, 10) except [2, 9, 10] RUN CODE >>
147 Generate a number in a specified range (-5, 5) except [-5,0,4,3,2] RUN CODE >>
148 Compute the sum of digits of each number in a given list. RUN CODE >>
149 Combine two lists into another list randomly. RUN CODE >>
150 Remove specific words from a given list. RUN CODE >>
151 Get all possible combinations of the elements of a given list. RUN CODE >>
152 Reverse a given list of lists. RUN CODE >>
Find the maximum and minimum values in a given list within a specified index
153 RUN CODE >>
range.
26
154 Combine two sorted lists using the heapq module. RUN CODE >>
155 Check if a given element occurs at least n times in a list. RUN CODE >>
156 Join two given list of lists of the same length, element wise. RUN CODE >>
157 Add two given lists of different lengths, starting on the left. RUN CODE >>
158 Add two given lists of different lengths, starting on the right. RUN CODE >>
159 Interleave lists of varying lengths. RUN CODE >>
160 Find the maximum and minimum values in a given list of tuples. RUN CODE >>
161 Append the same value/a list multiple times to a list/list-of-lists. RUN CODE >>
Remove the first specified number of elements from a given list satisfying a
162 RUN CODE >>
condition.
Check if a given list increases strictly. Moreover, if removing only one element from
163 RUN CODE >>
the list results in a strictly increasing list, we still consider the list true.
164 Find the last occurrence of a specified item in a given list. RUN CODE >>
165 Get the index of the first element that is greater than a specified element. RUN CODE >>
166 Get items from a given list with specific conditions. RUN CODE >>
167 Split a given list into specified-sized chunks. RUN CODE >>
168 Remove the None value from a given list. RUN CODE >>
169 Convert a given list of strings into a list of lists. RUN CODE >>
170 Display vertically each element of a given list, list of lists. RUN CODE >>
171 Convert a given list of strings and characters to a single list of characters. RUN CODE >>
172 Insert an element in a given list after every nth position. RUN CODE >>
173 Concatenate element-wise three given lists. RUN CODE >>
174 Remove the last N number of elements from a given list. RUN CODE >>
175 Merge some list items in a given list using the index value. RUN CODE >>
176 Add a number to each element in a given list of numbers. RUN CODE >>
Find the minimum and maximum value for each tuple position in a given list of
177 RUN CODE >>
tuples.
178 Create a new list by dividing two given lists of numbers. RUN CODE >>
179 Find common elements in a given list of lists. RUN CODE >>
180 Insert a specified element in a given list after every nth element. RUN CODE >>
Create the largest possible number using the elements of a given list of positive
181 RUN CODE >>
integers.
Create the smallest possible number using the elements of a given list of positive
182 RUN CODE >>
integers.
183 Iterate a given list cyclically at a specific index position. RUN CODE >>
184 Calculate the maximum and minimum sum of a sublist in a given list of lists. RUN CODE >>
27
185 Get the unique values in a given list of lists. RUN CODE >>
186 Generate Bigrams of words from a given list of strings. RUN CODE >>
187 Convert a given decimal number to a binary list. RUN CODE >>
188 Swap two sublists in a given list. RUN CODE >>
189 Convert a given list of tuples to a list of strings. RUN CODE >>
190 Sort a given list of tuples by a specified element. RUN CODE >>
191 Shift last element to first position and first element to last position in a given list. RUN CODE >>
Find the specified number of largest products from two given lists, multiplying an
192 RUN CODE >>
element from each list.
193 Find the maximum and minimum values of the three given lists. RUN CODE >>
194 Remove all strings from a given list of tuples. RUN CODE >>
195 Find the dimension of a given matrix. RUN CODE >>
196 Sum two or more lists. The lengths of the lists may be different. RUN CODE >>
Traverse a given list in reverse order, and print the elements with the original
197 RUN CODE >>
index.
198 Move a specified element in a given list. RUN CODE >>
Compute the average of the n-th element in a given list of lists with different
199 RUN CODE >>
lengths.
200 Compare two given lists and find the indices of the values present in both lists. RUN CODE >>
201 Convert a Unicode list to a list of strings. RUN CODE >>
202 Pair consecutive elements of a given list. RUN CODE >>
203 Check if a given string contains an element that is present in a list. RUN CODE >>
204 Find the indexes of all None items in a given list. RUN CODE >>
205 Join adjacent members of a given list. RUN CODE >>
206 Check if the first digit or character of each element in a list is the same. RUN CODE >>
207 Find the indices of elements in a given list that are greater than a specified value. RUN CODE >>
208 Remove additional spaces from a given list. RUN CODE >>
209 Find the common tuples between two given lists. RUN CODE >>
Sum a list of numbers. sum the first number with the second and divide it by 2,
210 RUN CODE >>
then sum the second with the third and divide by 2, and so on.
Count the number of groups of non-zero numbers separated by zeros in a given
211 RUN CODE >>
list of numbers.
Compute the sum of non-zero groups (separated by zeros) of a given list of
212 RUN CODE >>
numbers.
213 Remove an element from a given list. RUN CODE >>
214 Remove all values except integer values from a given array of mixed values. RUN CODE >>
28
215 Calculate the sum of two lowest negative numbers in a given array of integers. RUN CODE >>
216 Sort a given positive number in descending/ascending order. RUN CODE >>
Merge two or more lists into a list of lists, combining elements from each of the
217 RUN CODE >>
input lists based on their positions.
Group the elements of a list based on the given function and return the count of
218 RUN CODE >>
elements in each group.
219 Split values into two groups, based on the result of the given filtering function. RUN CODE >>
220 Sort one list based on another list containing the desired indexes. RUN CODE >>
221 Build a list, using an iterator function and an initial seed value. RUN CODE >>
Map the values of a list to a dictionary using a function, where the key-value pairs
222 RUN CODE >>
consist of the original value as the key and the result of the function as the value.
223 Randomize the order of the values of a list, returning a new list. RUN CODE >>
Get the difference between two given lists, after applying the provided function to
224 RUN CODE >>
each list element of both.
225 Create a list with non-unique values filtered out. RUN CODE >>
226 Create a list with unique values filtered out. RUN CODE >>
Retrieve the value of the nested key indicated by the given selector list from a
227 RUN CODE >>
dictionary or list.
Get a list of elements that exist in both lists, after applying the provided function to
228 RUN CODE >>
each list element of both.
Get the symmetric difference between two lists, after applying the provided
229 RUN CODE >>
function to each list element of both.
Get every element that exists in any of the two given lists once, after applying the
230 RUN CODE >>
provided function to each element of both.
Find the index of the first element in the given list that satisfies the provided testing
231 RUN CODE >>
function.
Find the indexes of all elements in the given list that satisfy the provided testing
232 RUN CODE >>
function.
233 Split values into two groups, based on the result of the given filter list. RUN CODE >>
234 Chunk a given list into smaller lists of a specified size. RUN CODE >>
235 Chunk a given list into n smaller lists. RUN CODE >>
236 Convert a given number (integer) to a list of digits. RUN CODE >>
Find the index of the last element in the given list that satisfies the provided testing
237 RUN CODE >>
function.
238 Find items that are parity outliers in a given list. RUN CODE >>
Convert a given list of dictionaries into a list of values corresponding to the
239 RUN CODE >>
specified key.
29
Calculate the average of a given list, after mapping each element to a value using
240 RUN CODE >>
the provided function.
Find the value of the last element in the given list that satisfies the provided testing
241 RUN CODE >>
function.
Create a dictionary with the unique values of a given list as keys and their
242 RUN CODE >>
frequencies as values.
Get the symmetric difference between two iterables, without filtering out duplicate
243 RUN CODE >>
values.
244 Check if a given function returns True for every element in a list. RUN CODE >>
Initialize a list containing the numbers in the specified range where start and end
245 are inclusive and the ratio between two terms is step. Return an error if step RUN CODE >>
equals 1.
Takes any number of iterable objects or objects with a length property and returns
246 RUN CODE >>
the longest one.
247 Check if a given function returns True for at least one element in the list. RUN CODE >>
248 Calculate the difference between two iterables, without filtering duplicate values. RUN CODE >>
Get the maximum value of a list, after mapping each element to a value using a
249 RUN CODE >>
given function.
Get the minimum value of a list, after mapping each element to a value using a
250 RUN CODE >>
given function.
Calculate the sum of a list, after mapping each element to a value using the
251 RUN CODE >>
provided function.
252 Fills a list with the specified value. RUN CODE >>
253 Get the n maximum elements from a given list of numbers. RUN CODE >>
254 Get the n minimum elements from a given list of numbers. RUN CODE >>
255 Get the weighted average of two or more numbers. RUN CODE >>
256 Perform a deep flattening of a list. RUN CODE >>
257 Get the powerset of a given iterable. RUN CODE >>
258 Check if two given lists contain the same elements regardless of order. RUN CODE >>
259 Create a flat list of all the keys in a flat dictionary. RUN CODE >>
260 Check if a given function returns True for at least one element in the list. RUN CODE >>
261 Check if all the elements of a list are included in another given list. RUN CODE >>
262 Get the most frequent element in a given list of numbers. RUN CODE >>
263 Move the specified number of elements to the end of the given list. RUN CODE >>
264 Move the specified number of elements to the start of the given list. RUN CODE >>
265 Create a two-dimensional list from a given list of lists. RUN CODE >>
266 Generate a list containing the Fibonacci sequence, up until the nth term. RUN CODE >>
30
267 Cast the provided value as a list if it's not one. RUN CODE >>
268 Get the cumulative sum of the elements of a given list. RUN CODE >>
269 Get a list with n elements removed from the left and right. RUN CODE >>
270 Get every nth element in a given list. RUN CODE >>
Check if the elements of the first list are contained in the second one regardless of
271 RUN CODE >>
order.
272 Check if there are duplicate values in a given flat list. RUN CODE >>
Generate a list of numbers in the arithmetic progression starting with the given
273 RUN CODE >>
positive integer and up to the specified limit.
274 Find an element that divides a given list of integers with the same sum value. RUN CODE >>
275 Count the lowercase letters in a given list of words. RUN CODE >>
Add all elements of a list of integers except the number at index. Return the
276 RUN CODE >>
updated string.
277 Find the largest odd number in a given list of integers. RUN CODE >>
Calculate the largest and smallest gap between sorted elements of a list of
278 RUN CODE >>
integers.
279 Sum the missing numbers in a given list of integers. RUN CODE >>
Extract the first specified number of vowels from a given string. If the specified
280 number is less than the number of vowels present in the string then display "n is RUN CODE >>
less than the number of vowels present in the string".
31
12 Find the first non-repeated element in a list. RUN CODE >>
13 Write a Python a function to implement a LRU cache. RUN CODE >>
14 Write a Python function to sort a list of dictionaries based on values of a key. RUN CODE >>
15 Find all the pairs in a list whose sum is equal to a given value. RUN CODE >>
Dictionary
1 Write a Python script to sort (ascending and descending) a dictionary by value. RUN CODE >>
2 Write a Python script to add a key to a dictionary. RUN CODE >>
3 Write a Python script to concatenate the following dictionaries to create a new one. RUN CODE >>
4 Write a Python script to check whether a given key already exists in a dictionary. RUN CODE >>
5 iterate over dictionaries using for loops. RUN CODE >>
Write a Python script to generate and print a dictionary that contains a number
6 RUN CODE >>
(between 1 and n) in the form (x, x*x).
Write a Python script to print a dictionary where the keys are numbers between 1
7 RUN CODE >>
and 15 (both included) and the values are the square of the keys.
8 Write a Python script to merge two Python dictionaries. RUN CODE >>
9 Iterate over dictionaries using for loops. RUN CODE >>
10 Sum all the items in a dictionary. RUN CODE >>
11 Multiply all the items in a dictionary. RUN CODE >>
12 Remove a key from a dictionary. RUN CODE >>
13 Map two lists into a dictionary. RUN CODE >>
14 Sort a given dictionary by key. RUN CODE >>
15 Get the maximum and minimum values of a dictionary. RUN CODE >>
16 Get a dictionary from an object's fields. RUN CODE >>
17 Check if a dictionary is empty or not. RUN CODE >>
18 Combine two dictionary by adding values for common keys. RUN CODE >>
19 Print all distinct values in a dictionary. RUN CODE >>
Create and display all combinations of letters, selecting each letter from a different
20 RUN CODE >>
key in a dictionary.
21 Find the highest 3 values of corresponding keys in a dictionary. RUN CODE >>
22 Combine values in a list of dictionaries. RUN CODE >>
23 Create a dictionary from a string. RUN CODE >>
24 Print a dictionary in table format. RUN CODE >>
25 Count the values associated with a key in a dictionary. RUN CODE >>
26 Convert a list into a nested dictionary of keys. RUN CODE >>
27 Sort a list alphabetically in a dictionary. RUN CODE >>
32
28 Remove spaces from dictionary keys. RUN CODE >>
29 Get the top three items in a shop. RUN CODE >>
30 Get the key, value and item in a dictionary. RUN CODE >>
31 Print a dictionary line by line. RUN CODE >>
32 Check if multiple keys exist in a dictionary. RUN CODE >>
33 Count the number of items in a dictionary value that is a list. RUN CODE >>
34 Sort Counter by value. RUN CODE >>
35 Create a dictionary from two lists without losing duplicate values. RUN CODE >>
36 Replace dictionary values with their sums. RUN CODE >>
37 Match key values in two dictionaries. RUN CODE >>
38 Store dictionary data in a JSON file. RUN CODE >>
Create a dictionary of keys x, y, and z where each key has as value a list from
39 11-20, 21-30, and 31-40 respectively. Access the fifth value of each key from the RUN CODE >>
dictionary.
40 Drop empty items from a given dictionary. RUN CODE >>
41 Filter a dictionary based on values. RUN CODE >>
42 Convert more than one list to a nested dictionary. RUN CODE >>
43 Filter the height and width of students, which are stored in a dictionary. RUN CODE >>
44 Verify that all values in a dictionary are the same. RUN CODE >>
Create a dictionary grouping a sequence of key-value pairs into a dictionary of
45 RUN CODE >>
lists.
46 Split a given dictionary of lists into lists of dictionaries. RUN CODE >>
47 Remove a specified dictionary from a given list. RUN CODE >>
48 Convert string values of a given dictionary into integer/float datatypes. RUN CODE >>
A Python dictionary contains List as a value. clear the list values in the said
49 RUN CODE >>
dictionary.
A Python Dictionary contains List as a value. update the list values in the said
50 RUN CODE >>
dictionary.
51 Extract a list of values from a given list of dictionaries. RUN CODE >>
52 Find the length of a dictionary of values. RUN CODE >>
53 Get the depth of a dictionary. RUN CODE >>
54 Access dictionary key's element by index. RUN CODE >>
55 Convert a dictionary into a list of lists. RUN CODE >>
56 Filter even numbers from a dictionary of values. RUN CODE >>
57 Get all combinations of key-value pairs in a given dictionary. RUN CODE >>
58 Find the specified number of maximum values in a given dictionary. RUN CODE >>
33
59 Find the shortest list of values for the keys in a given dictionary. RUN CODE >>
60 Count the frequency of a dictionary. RUN CODE >>
61 Extract values from a given dictionary and create a list of lists from those values. RUN CODE >>
62 Convert a given list of lists to a dictionary. RUN CODE >>
63 Creates key-value list pairings within a dictionary. RUN CODE >>
64 Check if a specific key and a value exist in a dictionary. RUN CODE >>
65 Invert a given dictionary with non-unique hashable values. RUN CODE >>
66 Combine two or more dictionaries, creating a list of values for each key. RUN CODE >>
67 Group the elements of a given list based on the given function. RUN CODE >>
Map the values of a given list to a dictionary using a function, where the key-value
68 pairs consist of the original value as the key and the result of the function as the RUN CODE >>
value.
Retrieve the value of the nested key indicated by the given selector list from a
69 RUN CODE >>
dictionary or list.
70 Invert a dictionary with unique hashable values. RUN CODE >>
71 Convert a list of dictionaries into a list of values corresponding to the specified key. RUN CODE >>
Create a dictionary with the same keys as the given dictionary and values
72 RUN CODE >>
generated by running the given function for each value.
73 Find all keys in a dictionary that have the given value. RUN CODE >>
Combine two lists into a dictionary. The elements of the first one serve as keys
74 and the elements of the second one serve as values. Each item in the first list RUN CODE >>
must be unique and hashable.
75 Transform a dictionary into a list of tuples. RUN CODE >>
76 Create a flat list of all the keys in a flat dictionary. RUN CODE >>
77 Create a flat list of all the values in a flat dictionary. RUN CODE >>
78 Find the key of the maximum value in a dictionary. RUN CODE >>
Python Tuple
1 Create a tuple. RUN CODE >>
2 Create a tuple with different data types. RUN CODE >>
3 Create a tuple of numbers and print one item. RUN CODE >>
4 Unpack a tuple into several variables. RUN CODE >>
5 Add an item to a tuple. RUN CODE >>
6 Convert a tuple to a string. RUN CODE >>
7 Get the 4th element from the last element of a tuple. RUN CODE >>
8 Create the colon of a tuple. RUN CODE >>
34
9 Find repeated items in a tuple. RUN CODE >>
10 Check whether an element exists within a tuple. RUN CODE >>
11 Convert a list to a tuple. RUN CODE >>
12 Remove an item from a tuple. RUN CODE >>
13 Slice a tuple. RUN CODE >>
14 Find the index of an item in a tuple. RUN CODE >>
15 Find the length of a tuple. RUN CODE >>
16 Convert a tuple to a dictionary. RUN CODE >>
17 Unzip a list of tuples into individual lists. RUN CODE >>
18 Reverse a tuple. RUN CODE >>
19 Convert a list of tuples into a dictionary. RUN CODE >>
20 Print a tuple with string formatting. RUN CODE >>
21 Replace the last value of tuples in a list. RUN CODE >>
22 Remove an empty tuple(s) from a list of tuples. RUN CODE >>
23 Sort a tuple by its float element. RUN CODE >>
24 Count the elements in a list until an element is a tuple. RUN CODE >>
25 Convert a given string list to a tuple. RUN CODE >>
26 Calculate the product, multiplying all the numbers in a given tuple. RUN CODE >>
27 Calculate the average value of the numbers in a given tuple of tuples. RUN CODE >>
28 Convert a tuple of string values to a tuple of integer values. RUN CODE >>
29 Convert a given tuple of positive integers into an integer. RUN CODE >>
30 Check if a specified element appears in a tuple of tuples. RUN CODE >>
31 Compute the element-wise sum of given tuples. RUN CODE >>
32 Compute the sum of all the elements of each tuple stored inside a list of tuples. RUN CODE >>
32 Convert a given list of tuples to a list of ists. RUN CODE >>
Python Sets
1 Create a set. RUN CODE >>
2 Iterate over sets. RUN CODE >>
3 Add member(s) to a set. RUN CODE >>
4 Remove item(s) from a given set. RUN CODE >>
5 Remove an item from a set if it is present in the set. RUN CODE >>
6 Create an intersection of sets. RUN CODE >>
7 Create a union of sets. RUN CODE >>
8 Create set difference. RUN CODE >>
35
9 Create a symmetric difference. RUN CODE >>
10 Check if a set is a subset of another set. RUN CODE >>
11 Create a shallow copy of sets. RUN CODE >>
12 Remove all elements from a given set. RUN CODE >>
13 Uses frozen sets. RUN CODE >>
14 Find the maximum and minimum values in a set. RUN CODE >>
15 Find the length of a set. RUN CODE >>
16 Check if a given value is present in a set or not. RUN CODE >>
17 Check if two given sets have no elements in common. RUN CODE >>
18 Check if a given set is a superset of itself and a superset of another given set. RUN CODE >>
19 Find elements in a given set that are not in another set. RUN CODE >>
20 Remove the intersection of a second set with a first set. RUN CODE >>
Find all the unique words and count the frequency of occurrence from a given list
21 RUN CODE >>
of strings. Use Python set data type.
22 Finds all pairs of elements in a list whose sum is equal to a given value. RUN CODE >>
23 Find the longest common prefix of all strings. Use the Python set. RUN CODE >>
Find the two numbers whose product is maximum among all the pairs in a given
24 RUN CODE >>
list of numbers. Use the Python set.
Given two sets of numbers, find the missing numbers in the second set as
25 RUN CODE >>
compared to the first and vice versa. Use the Python set.
Find all the anagrams and group them together from a given list of strings. Use the
26 RUN CODE >>
Python data type.
Find all the anagrams in a given list of strings and then group them together. Use
27 RUN CODE >>
the Python data type.
Find all the unique combinations of 3 numbers from a given list of numbers,
28 RUN CODE >>
adding up to a target number.
Find the third largest number from a given list of numbers.Use the Python set data
29 RUN CODE >>
type.
Remove all duplicates from a given list of strings and return a list of unique strings.
30 RUN CODE >>
Use the Python set data type.
Python Collections
1 Iterates over elements as many times as its count. RUN CODE >>
2 Find the most common elements and their counts in a specified text. RUN CODE >>
3 Create a new deque with three items and iterate over the deque's elements. RUN CODE >>
4 Find the occurrences of the 10 most common words in a given text. RUN CODE >>
36
Accepts some words and counts the number of distinct words. Print the number of
5 distinct words and the number of occurrences of each distinct word according to RUN CODE >>
their appearance.
Accepts the number of subjects, subject names and marks. Input the number of
6 subjects and then the subject name and marks separated by a space on the next RUN CODE >>
line. Print the subject name and marks in order of appearance.
Create a deque and append a few elements to the left and right. Next, remove
7 RUN CODE >>
some elements from the left and right sides and reverse the deque.
8 Create a deque from an existing iterable object. RUN CODE >>
9 Add more elements to a deque object from an iterable object. RUN CODE >>
10 Remove all the elements of a given deque object. RUN CODE >>
11 Copies a deque object and verifies shallow copying. RUN CODE >>
12 Count the number of times a specific element appears in a deque object. RUN CODE >>
13 Rotate a Deque Object a specified number (positive) of times. RUN CODE >>
14 Rotate a deque Object a specified number (negative) of times. RUN CODE >>
15 Find the most common element in a given list. RUN CODE >>
Find the second lowest total marks of any student(s) from the given names and
16 marks of each student using lists and lambda. Input number of students, names RUN CODE >>
and grades of each student.
Find the majority element from a given array of size n using the Collections
17 RUN CODE >>
module.
18 Merge more than one dictionary into a single expression. RUN CODE >>
Break a given list of integers into sets of a given positive number. Return true or
19 RUN CODE >>
false.
20 Find the item with the highest frequency in a given list. RUN CODE >>
21 Count the most and least common characters in a given string. RUN CODE >>
22 Insert an element at the beginning of a given Ordered Dictionary. RUN CODE >>
23 Get the frequency of the tuples in a given list. RUN CODE >>
24 Calculate the maximum aggregate from the list of tuples (pairs). RUN CODE >>
25 Find the characters in a list of strings that occur more or less than a given number. RUN CODE >>
Find the difference between two lists including duplicate elements. Use the
26 RUN CODE >>
collections module.
27 Remove duplicate words from a given string. Use the collections module. RUN CODE >>
Create a dictionary grouping a sequence of key-value pairs into a dictionary of
28 RUN CODE >>
lists. Use the collections module.
29 Get the frequency of elements in a given list of lists. Use the collections module. RUN CODE >>
30 Count the occurrences of each element in a given list. RUN CODE >>
37
31 Count the most common words in a dictionary. RUN CODE >>
32 Find the class wise roll number from a tuple-of-tuples. RUN CODE >>
33 Count the number of students in an individual class. RUN CODE >>
Create an instance of an OrderedDict using a given dictionary. Sort the dictionary
34 RUN CODE >>
during the creation and print the members of the dictionary in reverse order.
35 Group a sequence of key-value pairs into a dictionary of lists. RUN CODE >>
36 Compare two unordered lists (not sets). RUN CODE >>
Python Array
Create an array of 5 integers and display the array items. Access individual
1 RUN CODE >>
elements through indexes
2 Append a new item to the end of the array. RUN CODE >>
3 Reverse the order of the items in the array. RUN CODE >>
4 Get the length in bytes of one array item in the internal representation. RUN CODE >>
Get the current memory address and the length in elements of the buffer used to
5 RUN CODE >>
hold an array's contents. Also, find the size of the memory buffer in bytes.
6 Get the number of occurrences of a specified element in an array. RUN CODE >>
7 Append items from inerrable to the end of the array. RUN CODE >>
Convert an array to an array of machine values and return the bytes
8 RUN CODE >>
representation.
9 Append items to a specified list. RUN CODE >>
10 Insert a newly created item before the second element in an existing array. RUN CODE >>
11 Remove a specified item using the index of an array. RUN CODE >>
12 Remove the first occurrence of a specified element from an array. RUN CODE >>
13 Convert an array to an ordinary list with the same items. RUN CODE >>
Find out if a given array of integers contains any duplicate elements. Return true if
14 any value appears at least twice in the array, and return false if every element is RUN CODE >>
distinct.
Find the first duplicate element in a given array of integers. Return -1 if there are
15 RUN CODE >>
no such elements.
16 Check whether it follows the sequence given in the patterns array. RUN CODE >>
17 Find a pair with the highest product from a given array of integers. RUN CODE >>
18 Create an array of six integers. Print all members of the array. RUN CODE >>
19 Get array buffer information. RUN CODE >>
20 Get the length of an array. RUN CODE >>
21 Get the array size of types unsigned integer and float. RUN CODE >>
38
22 Reads a string and interprets it as an array of machine values. RUN CODE >>
23 Removes all duplicate elements from an array and returns a new array. RUN CODE >>
24 Find the missing number in a given array of numbers between 10 and 20. RUN CODE >>
Python Enum
1 Create an Enum object and display a member name and value. RUN CODE >>
2 Iterates over an enum class and displays each member and their value. RUN CODE >>
3 Display all the member names of an enum class ordered by their values. RUN CODE >>
4 Get all values from an enum class. RUN CODE >>
Basic exercises
1 Import a built-in array module and display the namespace of the said module. RUN CODE >>
2 Create a class and display the namespace of that class. RUN CODE >>
Create an instance of a specified class and display the namespace of the said
3 RUN CODE >>
instance.
Imports the abs() function using the builtins module, displays the documentation of
4 RUN CODE >>
the abs() function and finds the absolute value of -155
Define a Python function student(). Using function attributes display the names of
5 RUN CODE >>
all arguments.
Write a Python function student_data () that will print the ID of a student
6 (student_id). If the user passes an argument student_name or student_class the RUN CODE >>
function will print the student name and class.
Write a simple Python class named Student and display its type. Also, display the
7 __dict__ attribute keys and the value of the __module__ attribute of the Student RUN CODE >>
class
create two empty classes, Student and Marks. Now create some instances and
8 check whether they are instances of the said classes or not. Also, check whether RUN CODE >>
the said classes are subclasses of the built-in object class or not.
create two empty classes, Student and Marks. Now create some instances and
9 check whether they are instances of the said classes or not. Also, check whether RUN CODE >>
the said classes are subclasses of the built-in object class or not.
Write a Python class named Student with two attributes student_id, student_name.
Add a new attribute student_class and display the entire attribute and the values
10 RUN CODE >>
of the class. Now remove the student_name attribute and display the entire
attribute with values.
Write a Python class named Student with two attributes: student_id,
11 student_name. Add a new attribute: student_class. Create a function to display all RUN CODE >>
attributes and their values in the Student class.
39
Write a Python class named Student with two instances student1, student2 and
12 assign values to the instances' attributes. Print all the attributes of the student1, RUN CODE >>
student2 instances with their values in the given format
Basic application
1 Write a Python class to convert an integer to a Roman numeral. RUN CODE >>
2 Write a Python class to convert a Roman numeral to an integer RUN CODE >>
Write a Python class to check the validity of a string of parentheses, '(', ')', '{', '}', '['
3 and ']. These brackets must be closed in the correct order, for example "()" and RUN CODE >>
"()[]{}" are valid but "[)", "({[)]" and "{{{" are invalid.
Write a Python class to get all possible unique subsets from a set of distinct
4 RUN CODE >>
integers.
Write a Python class to find a pair of elements (indices of the two numbers) from a
5 RUN CODE >>
given array whose sum equals a specific target number.
Write a Python class to find the three elements that sum to zero from a set of n
6 RUN CODE >>
real numbers.
7 Write a Python class to implement pow(x, n). RUN CODE >>
8 Write a Python class to reverse a string word by word. RUN CODE >>
Write a Python class that has two methods: get_String and print_String ,
9 get_String accept a string from the user and print_String prints the string in upper RUN CODE >>
case.
Write a Python class named Rectangle constructed from length and width and a
10 RUN CODE >>
method that will compute the area of a rectangle.
Write a Python class named Circle constructed from a radius and two methods
11 RUN CODE >>
that will compute the area and the perimeter of a circle.
12 Get the class name of an instance in Python. RUN CODE >>
life problems
Write a Python class Employee with attributes like emp_id, emp_name,
1 emp_salary, and emp_department and methods like calculate_emp_salary, RUN CODE >>
emp_assign_department, and print_employee_details.
Write a Python class Restaurant with attributes like menu_items, book_table, and
2 customer_orders, and methods like add_item_to_menu, book_tables, and RUN CODE >>
customer_order.
Write a Python class BankAccount with attributes like account_number, balance,
3 date_of_opening and customer_name, and methods like deposit, withdraw, and RUN CODE >>
check_balance.
40
Write a Python class Inventory with attributes like item_id, item_name,
4 stock_count, and price, and methods like add_item, update_item, and RUN CODE >>
check_item_details.
41
Python OOP
Create a class representing a Circle. Include methods to calculate its area and
1 RUN CODE >>
perimeter.
Create a person class. Include attributes like name, country and date of birth.
2
Implement a method to determine the person's age. RUN CODE >>
3 Create a calculator class. Include methods for basic arithmetic operations. RUN CODE >>
Create a class that represents a shape. Include methods to calculate its area and
4 perimeter. Implement subclasses for different shapes like circle, triangle, and RUN CODE >>
square.
Create a class representing a binary search tree. Include methods for inserting
5 RUN CODE >>
and searching for elements in the binary tree.
Create a class representing a stack data structure. Include methods for pushing
6 RUN CODE >>
and popping elements.
Create a class representing a linked list data structure. Include methods for
7 RUN CODE >>
displaying linked list data, inserting and deleting nodes.
Create a class representing a shopping cart. Include methods for adding and
8 RUN CODE >>
removing items, and calculating the total price.
Create a class representing a stack data structure. Include methods for pushing,
9 RUN CODE >>
popping and displaying elements.
Create a class representing a queue data structure. Include methods for
10 RUN CODE >>
enqueueing and dequeueing elements.
Create a class representing a bank. Include methods for managing customer
11 RUN CODE >>
accounts and transactions.
Python Decorator
1 Create a decorator that logs the arguments and return value of a function. RUN CODE >>
2 Create a decorator function to measure the execution time of a function. RUN CODE >>
Create a decorator to convert the return value of a function to a specified data
3 RUN CODE >>
type.
4 Implements a decorator to cache the result of a function. RUN CODE >>
Implements a decorator to validate function arguments based on a given
5 RUN CODE >>
condition.
6 Implements a decorator to retry a function multiple times in case of failure. RUN CODE >>
7 Implements a decorator to enforce rate limits on a function RUN CODE >>
8 Implements a decorator to add logging functionality to a function. RUN CODE >>
Implements a decorator to handle exceptions raised by a function and provide a
9 RUN CODE >>
default response.
42
10 Implements a decorator to enforce type checking on the arguments of a function. RUN CODE >>
11 Implements a decorator to measure the memory usage of a function. RUN CODE >>
12 Implements a decorator to provide caching with expiration time for a function. RUN CODE >>
Python functions
1 Write a Python function to find the maximum of three numbers. RUN CODE >>
2 Write a Python function to sum all the numbers in a list. RUN CODE >>
3 Write a Python function to multiply all the numbers in a list. RUN CODE >>
4 reverse a string. RUN CODE >>
Write a Python function to calculate the factorial of a number (a non-negative
5 RUN CODE >>
integer). The function accepts the number as an argument.
6 Write a Python function to check whether a number falls within a given range RUN CODE >>
Write a Python function that accepts a string and counts the number of upper and
7 RUN CODE >>
lower case letters.
Write a Python function that takes a list and returns a new list with distinct
8
elements from the first list. RUN CODE >>
Write a Python function that takes a number as a parameter and checks whether
9 RUN CODE >>
the number is prime or not.
Write a Python function that takes a number as a parameter and checks whether
10 RUN CODE >>
the number is prime or not.
11 Write a Python function to check whether a number is "Perfect" or not. RUN CODE >>
Write a Python function that checks whether a passed string is a palindrome or
12 RUN CODE >>
not.
13 Write a Python function that prints out the first n rows of Pascal's triangle. RUN CODE >>
14 Write a Python function to check whether a string is a pangram or not. RUN CODE >>
Accepts a hyphen-separated sequence of words as input and prints the words in a
15 RUN CODE >>
hyphen-separated sequence after sorting them alphabetically.
Write a Python function to create and print a list where the values are the squares
16 RUN CODE >>
of numbers between 1 and 30 (both included).
17 Create a chain of function decorators (bold, italic, underline etc.). RUN CODE >>
18 Create a chain of function decorators (bold, italic, underline etc.). RUN CODE >>
19 Access a function inside a function. RUN CODE >>
20 Detect the number of local variables declared in a function. RUN CODE >>
21 Invokes a function after a specified period of time. RUN CODE >>
43
Python Lambda
Create a lambda function that adds 15 to a given number passed in as an
1 argument, also create a lambda function that multiplies argument x with argument RUN CODE >>
y and prints the result.
Create a function that takes one argument, and that argument will be multiplied
2 RUN CODE >>
with an unknown given number.
3 Sort a list of tuples using Lambda. RUN CODE >>
4 Sort a list of dictionaries using Lambda. RUN CODE >>
5 Filter a list of integers using Lambda. RUN CODE >>
6 Square and cube every number in a given list of integers using Lambda. RUN CODE >>
7 Find if a given string starts with a given character using Lambda. RUN CODE >>
8 Extract year, month, date and time using Lambda. RUN CODE >>
9 Extract year, month, date and time using Lambda. RUN CODE >>
10 Create Fibonacci series up to n using Lambda. RUN CODE >>
11 Find the intersection of two given arrays using Lambda. RUN CODE >>
12 Rearrange positive and negative numbers in a given array using Lambda. RUN CODE >>
13 Count the even and odd numbers in a given array of integers using Lambda. RUN CODE >>
Filter a given list to determine if the values in the list have a length of 6 using
14 RUN CODE >>
Lambda.
15 Add two given lists using map and lambda. RUN CODE >>
Find the second lowest total marks of any student(s) from the given names and
16 RUN CODE >>
marks of each student using lists and lambda.
Find numbers divisible by nineteen or thirteen from a list of numbers using
17 RUN CODE >>
Lambda
18 Find palindromes in a given list of strings using Lambda. RUN CODE >>
19 Find all anagrams of a string in a given list of strings using Lambda. RUN CODE >>
20 Find the numbers in a given string and store them in a list. RUN CODE >>
21 Find the numbers in a given string and store them in a list. RUN CODE >>
Sums the length of a list of names after removing those that start with lowercase
22 RUN CODE >>
letters
Calculate the sum of the positive and negative numbers of a given list of numbers
23 RUN CODE >>
using the lambda function.
Find numbers within a given range where every number is divisible by every digit it
24 RUN CODE >>
contains
25 Create the next bigger number by rearranging the digits of a given number. RUN CODE >>
26 Find a list with maximum and minimum length using lambda. RUN CODE >>
27 Sort each sublist of strings in a given list of lists using lambda. RUN CODE >>
44
28 Sort a given list of lists by length and value using lambda. RUN CODE >>
29 Find the maximum value in a given heterogeneous list using lambda. RUN CODE >>
Sort a given matrix in ascending order according to the sum of its rows using
30 RUN CODE >>
lambda.
31 Extract a specified size of strings from a given list of string values using lambda RUN CODE >>
32 Count float values in a mixed list using lambda RUN CODE >>
Check whether a given string contains a capital letter, a lower case letter, a
33 RUN CODE >>
number and a minimum length using lambda.
Filter the height and width of students, which are stored in a dictionary using
34 RUN CODE >>
lambda.
35 Check whether a specified list is sorted or not using lambda. RUN CODE >>
36 Check whether a specified list is sorted or not using lambda. RUN CODE >>
37 Sort a list of lists by a given index of the inner list using lambda. RUN CODE >>
38 Remove all elements from a given list present in another list using lambda. RUN CODE >>
Find the elements of a given list of strings that contain a specific substring using
39 RUN CODE >>
lambda.
40 Find the nested list elements, which are present in another list using lambda. RUN CODE >>
41 Reverse strings in a given list of string values using lambda. RUN CODE >>
42 Calculate the product of a given list of numbers using lambda. RUN CODE >>
43 Multiply all the numbers in a given list using lambda. RUN CODE >>
Calculate the average value of the numbers in a given tuple of tuples using
44 RUN CODE >>
lambda.
45 Convert string elements to integers inside a given tuple using lambda. RUN CODE >>
46 Convert string elements to integers inside a given tuple using lambda. RUN CODE >>
47 Sort a given mixed list of integers and strings using lambda. RUN CODE >>
48 Sort a given list of strings (numbers) numerically using lambda. RUN CODE >>
49 Count the occurrences of items in a given list using lambda. RUN CODE >>
50 Remove specific words from a given list using lambda. RUN CODE >>
Find the maximum and minimum values in a given list of tuples using the lambda
51 RUN CODE >>
function.
52 Remove None values from a given list using the lambda function. RUN CODE >>
Python Map
1 Triple all numbers in a given list of integers. Use Python map. RUN CODE >>
2 Add three given lists using Python map and lambda. RUN CODE >>
3 Listify the list of given strings individually using Python map. RUN CODE >>
45
Create a list containing the power of said number in bases raised to the
4 RUN CODE >>
corresponding number in the index using Python map.
5 Square the elements of a list using the map() function. RUN CODE >>
Convert all the characters into uppercase and lowercase and eliminate duplicate
6 RUN CODE >>
letters from a given sequence. Use the map() function.
7 Add two given lists and find the difference between them. Use the map() function. RUN CODE >>
8 Add two given lists and find the difference between them. Use the map() function. RUN CODE >>
9 Add two given lists and find the difference between them. Use the map() function. RUN CODE >>
Compute the square of the first N Fibonacci numbers, using the map function and
10 RUN CODE >>
generate a list of the numbers.
Compute the square of the first N Fibonacci numbers, using the map function and
11 RUN CODE >>
generate a list of the numbers.
Compute the square of the first N Fibonacci numbers, using the map function and
12 RUN CODE >>
generate a list of the numbers.
13 Count the same pair in two given lists. use map() function. RUN CODE >>
14 Count the same pair in two given lists. use map() function. RUN CODE >>
15 Split a given dictionary of lists into list of dictionaries using the map function. RUN CODE >>
16 Convert a given list of strings into a list of lists using the map function. RUN CODE >>
17 Convert a given list of strings into a list of lists using the map function. RUN CODE >>
Python Itertools
Create an iterator from several iterables in a sequence and display the type and
1
elements of the new iterator. RUN CODE >>
2 Generates the running product of elements in an iterable. RUN CODE >>
3 Generate the maximum and minimum values of the elements of an iterable. RUN CODE >>
Construct an infinite iterator that returns evenly spaced values starting with a
4 RUN CODE >>
specified number and step.
5 Generate an infinite cycle of elements from an iterable. RUN CODE >>
6 Generate an infinite cycle of elements from an iterable. RUN CODE >>
Make an iterator that drops elements from the iterable as long as the elements are
7 RUN CODE >>
negative; afterwards, it returns every element.
8 Create an iterator that returns consecutive keys and groups from an iterable. RUN CODE >>
9 Split an iterable and generate iterables a specified number of times. RUN CODE >>
10 Create an iterator to get a specified number of permutations of elements RUN CODE >>
11 Generate combinations of a given length of a given iterable. RUN CODE >>
12 Generate combinations of a given length of a given iterable. RUN CODE >>
13 Generate combinations of a given length of a given iterable. RUN CODE >>
46
14 Generate permutations of specified elements drawn from specified values. RUN CODE >>
15 Generate all possible permutations of n different objects. RUN CODE >>
16 Find the sorted sequence from a set of permutations of a given input. RUN CODE >>
Read a given string character by character and compress repeated characters by
17 RUN CODE >>
storing the length of those character(s).
Generate permutations of n items in which successive permutations differ from
18 RUN CODE >>
each other by the swapping of any two items.
Iterates the integers from 1 to a given number and prints "Fizz" for multiples of
19 three, prints "Buzz" for multiples of five, and prints "FizzBuzz" for multiples of both RUN CODE >>
three and five using the itertools module.
20 Find the factorial of a number using the itertools module. RUN CODE >>
21 Find the years between 2000 and 2150 when the 25th of December is a Sunday. RUN CODE >>
22 Find the years between 2000 and 2150 when the 25th of December is a Sunday. RUN CODE >>
Find the shortest distance from a specified character in a given string. Return the
23 shortest distances through a list and use an itertools component to solve the RUN CODE >>
problem.
Find the maximum length of a substring in a given string where all the characters
24 RUN CODE >>
of the substring are the same. Use the itertools module to solve the problem.
Find the first two elements of a given list whose sum is equal to a given value. Use
25 RUN CODE >>
the itertools module to solve the problem.
26 Find the nth Hamming number. Use the itertools module. RUN CODE >>
Create a Python program that chooses a specified number of colors from three
27 RUN CODE >>
different colors and generates unique combinations.
Create a Python program that chooses a specified number of colors from three
28 RUN CODE >>
different colors and generates unique combinations.
29 interleave multiple lists of the same length. Use the itertools module. RUN CODE >>
Create non-repeated combinations of the Cartesian product of a given list of four
30 RUN CODE >>
numbers.
Count the frequency of consecutive duplicate elements in a given list of numbers.
31 RUN CODE >>
Use the itertools module.
32 Count the frequency of the elements of a given unordered list. RUN CODE >>
Find pairs of maximum and minimum products from a given list. Use the itertools
33 RUN CODE >>
module.
34 Compute the sum of digits of each number in a given list of positive integers. RUN CODE >>
35 Compute the sum of digits of each number in a given list of positive integers. RUN CODE >>
Add two given lists of different lengths, starting from the right, using the itertools
36 RUN CODE >>
module.
47
Add two given lists of different lengths, starting from the left, using the itertools
37 RUN CODE >>
module.
38 Interleave a number of lists of different lengths using the itertools module. RUN CODE >>
Get the index of the first element that is greater than a specified element using the
39 RUN CODE >>
itertools module.
40 Split a given list into specified sized chunks using the itertools module RUN CODE >>
41 Find all lower and upper mixed case combinations of a given string. RUN CODE >>
42 Create groups of similar items from a given list. RUN CODE >>
43 Find the maximum difference between pairs in a given list. RUN CODE >>
44 Extract a non-zero block from a given integer list. RUN CODE >>
Python datetime
1 Write a Python script to display the various Date Time formats - RUN CODE >>
2 Determine whether a given year is a leap year. RUN CODE >>
48
3 Convert a string to datetime. RUN CODE >>
4 Get the current time in Python. RUN CODE >>
5 Subtract five days from the current date. RUN CODE >>
6 Subtract five days from the current date. RUN CODE >>
7 Print yesterday, today, tomorrow. RUN CODE >>
8 Convert the date to datetime (midnight of the date) in Python. RUN CODE >>
9 Print the next 5 days starting today. RUN CODE >>
10 Add 5 seconds to the current time. RUN CODE >>
11 Convert Year/Month/Day to Day of Year in Python. RUN CODE >>
12 Get the current time in milliseconds in Python. RUN CODE >>
13 Get the week number. RUN CODE >>
14 Find the date of the first Monday of a given week. RUN CODE >>
15 Select all the Sundays in a specified year. RUN CODE >>
16 Add year(s) to a given date and display the updated date. RUN CODE >>
17 Drop microseconds from datetime. RUN CODE >>
18 Get days between two dates. RUN CODE >>
19 Get the date of the last Tuesday. RUN CODE >>
20 Test the third Tuesday of a month RUN CODE >>
21 Get the last day of a specified year and month. RUN CODE >>
22 Get the number of days in a given month and year. RUN CODE >>
23 Add a month to a specified date. RUN CODE >>
24 Count the number of Mondays on the 1st day of the month from 2015 to 2016. RUN CODE >>
25 Print a string five times, with a delay of three seconds.. RUN CODE >>
26 Calculates the date six months from the current date using the datetime module. RUN CODE >>
Create 12 fixed dates from a specified date over a given period. The difference
27
between two dates is 20. RUN CODE >>
28 Get the dates 30 days before and after today. RUN CODE >>
29 Get GMT and the local time. RUN CODE >>
30 Convert a date to a timestamp. RUN CODE >>
31 Convert a string date to a timestamp. RUN CODE >>
32 Calculate the number of days between two dates. RUN CODE >>
33 Calculate the number of days between two date times. RUN CODE >>
34 Calculate the number of days between two date times. RUN CODE >>
35 Calculate the number of days between two date times. RUN CODE >>
36 Calculate the number of days between two date times. RUN CODE >>
49
37 Convert difference of two dates into days, hours, minutes, and seconds. RUN CODE >>
38 Convert difference of two dates into days, hours, minutes, and seconds. RUN CODE >>
39 Convert difference of two dates into days, hours, minutes, and seconds. RUN CODE >>
40 Convert difference of two dates into days, hours, minutes, and seconds. RUN CODE >>
41 Generate a date and time as a string. RUN CODE >>
42 Display formatted text output of a month and start the week on Sunday. RUN CODE >>
43 Display formatted text output of a month and start the week on Sunday. RUN CODE >>
44 Display a calendar for a locale. RUN CODE >>
45 Get the current week. RUN CODE >>
46 Create a HTML calendar with data for a specific year and month. RUN CODE >>
Write a Python program display a list of the dates for the 2nd Saturday of every
47 RUN CODE >>
month for a given year.
48 Display a simple, formatted calendar of a given year and month. RUN CODE >>
49 Convert a string into datetime RUN CODE >>
50 Get a list of dates between two dates. RUN CODE >>
51 Generate RFC 3339 timestamp. RUN CODE >>
52 Get the first and last second. RUN CODE >>
Validate a Gregorian date. The month is between 1 and 12 inclusive, the day is
53 RUN CODE >>
within the allowed number of days for the given month
54 Set the default timezone used by all date/time functions. RUN CODE >>
The epoch is the point where time starts, and is platform dependent. For Unix, the
55 epoch is January 1, 1970, 00:00:00 (UTC). find out what the epoch is on a given RUN CODE >>
platform. Convert a given time in seconds since the epoch.
56 Get time values with components using local time and gmtime. RUN CODE >>
Get different time values with components timezone, timezone abbreviations, the
57 offset of the local (non-DST) timezone, DST timezone and time of different RUN CODE >>
timezones.
58 Can suspend execution of a given script for a given number of seconds. RUN CODE >>
Convert a given time in seconds since the epoch to a string representing local
59 RUN CODE >>
time.
Prints the time, names, representation format, and the preferred date time format
60
in a simple format. RUN CODE >>
Takes a given number of seconds and passes since the epoch as an argument.
61 RUN CODE >>
Print structure time in local time.
Takes a tuple containing 9 elements corresponding to structure time as an
62 RUN CODE >>
argument and returns a string representing it
63 Parse a string representing time and return the time structure. RUN CODE >>
50
Python File Input Output
1 Read an entire text file. RUN CODE >>
2 Read first n lines of a file. RUN CODE >>
3 Append text to a file and display the text. RUN CODE >>
4 Read last n lines of a file. RUN CODE >>
5 Read a file line by line and store it into a list. RUN CODE >>
6 Read a file line by line store it into a variable. RUN CODE >>
7 Read a file line by line store it into an array. RUN CODE >>
8 Find the longest words. RUN CODE >>
9 Count the number of lines in a text file. RUN CODE >>
10 Count the frequency of words in a file. RUN CODE >>
11 Get the file size of a plain file. RUN CODE >>
12 Write a list to a file. RUN CODE >>
13 Copy the contents of a file to another file . RUN CODE >>
14 Combine each line from first file with the corresponding line in second file. RUN CODE >>
15 Read a random line from a file. RUN CODE >>
16 Assess if a file is closed or not. RUN CODE >>
17 Remove newline characters from a file. RUN CODE >>
18 Takes a text file as input and returns the number of words of a given text file. RUN CODE >>
19 Extract characters from various text files and puts them into a list. RUN CODE >>
20 Generate 26 text files named A.txt, B.txt, and so on up to Z.txt. RUN CODE >>
Create a file where all letters of English alphabet are listed by specified number of
21 RUN CODE >>
letters on each line.
51
Reads each row of a given csv file and skip the header of the file. Also print the
8 RUN CODE >>
number of rows and the field names.
9 Create an object for writing and iterate over the rows to print the values. RUN CODE >>
Write a Python list of lists to a csv file. After writing the CSV file read the CSV file
10 RUN CODE >>
and display the content.
Write a Python dictionary to a csv file. After writing the CSV file read the CSV file
11 RUN CODE >>
and display the content.
52
25 Convert a date of yyyy-mm-dd format to dd-mm-yyyy format. RUN CODE >>
26 Match if two words from a list of words start with the letter 'P'. RUN CODE >>
27 Separate and print the numbers in a given string RUN CODE >>
28 Find all words starting with 'a' or 'e' in a given string. RUN CODE >>
29 Separate and print the numbers and their position in a given string. RUN CODE >>
30 Abbreviate 'Road' as 'Rd.' in a given string. RUN CODE >>
31 Replace all occurrences of a space, comma, or dot with a colon RUN CODE >>
32 Replace maximum 2 occurrences of space, comma, or dot with a colon. RUN CODE >>
33 Find all five-character words in a string. RUN CODE >>
34 Find all three, four, and five character words in a string. RUN CODE >>
35 Find all words that are at least 4 characters long in a string. RUN CODE >>
36 Convert a camel-case string to a snake-case string. RUN CODE >>
37 Extract values between quotation marks of a string. RUN CODE >>
38 Convert snake-case string to camel-case string. RUN CODE >>
39 Remove multiple spaces from a string. RUN CODE >>
40 Remove all whitespaces from a string. RUN CODE >>
41 Remove everything except alphanumeric characters from a string. RUN CODE >>
42 Find URLs in a string. RUN CODE >>
43 Split a string into uppercase letters. RUN CODE >>
44 Do case-insensitive string replacement. RUN CODE >>
45 Split a string into uppercase letters. RUN CODE >>
46 Find all adverbs and their positions in a given sentence. RUN CODE >>
47 Split a string with multiple delimiters. RUN CODE >>
48 Check a decimal with a precision of 2. RUN CODE >>
49 Remove words from a string of length between 1 and a given number. RUN CODE >>
50 Rite a remove the parenthesis area in a string. RUN CODE >>
51 Insert spaces between words starting with capital letters. RUN CODE >>
52 Rite a Python program that reads a given expression and evaluates it. RUN CODE >>
53 Remove lowercase substrings from a given string. RUN CODE >>
54 Concatenate the consecutive numbers in a given string. RUN CODE >>
55 Convert a given string to snake case. RUN CODE >>
Takes any number of iterable objects or objects with a length property and returns
56 RUN CODE >>
the longest one.
Checks whether a word starts and ends with a vowel in a given string. Return true
57 RUN CODE >>
if a word matches the condition; otherwise, return false.
53
Takes a string with some words. For two consecutive words in the said string,
check whether the first word ends with a vowel and the next word begins with a
58 RUN CODE >>
vowel. If the program meets the condition, return true, otherwise false. Only one
space is allowed between the words.
54
Sort a given collection of numbers and their length in ascending order using
30 RUN CODE >>
Recursive Insertion Sort.
Sort unsorted numbers using Random Pivot Quick Sort. Pick a random index as
31 RUN CODE >>
the pivot.
32 Sort unsorted numbers using Multi-key quicksort. RUN CODE >>
33 Sort unsorted numbers using Pigeonhole sorting. RUN CODE >>
34 Sort unsorted numbers using patience sorting. RUN CODE >>
35 Sort an odd-even sort or odd-even transposition sort. RUN CODE >>
Sort unsorted numbers using non-parallelized implementation of odd-even
36 RUN CODE >>
transposition sort.
37 Sort unsorted numbers using Odd Even Transposition Parallel sort. RUN CODE >>
38 Sort unsorted strings using natural sort. RUN CODE >>
39 Sort unsorted numbers using Merge-insertion sort. RUN CODE >>
Linked List
1 Create a singly linked list, append some items and iterate through the list. RUN CODE >>
2 Find the size of a singly linked list. RUN CODE >>
Search a specific item in a singly linked list and return true if the item is found
3 RUN CODE >>
otherwise return false.
4 Access a specific item in a singly linked list using index value. RUN CODE >>
5 Set a new value of an item in a singly linked list using index value. RUN CODE >>
6 Delete the first item from a singly linked list. RUN CODE >>
7 Delete the last item from a singly linked list RUN CODE >>
Create a doubly linked list, append some items and iterate through the list (print
8 RUN CODE >>
forward).
9 Create a doubly linked list and print nodes from current position to first node. RUN CODE >>
10 Count the number of items of a given doubly linked list. RUN CODE >>
11 Print a given doubly linked list in reverse order. RUN CODE >>
12 Insert an item in front of a given doubly linked list. RUN CODE >>
Search a specific item in a given doubly linked list and return true if the item is
13 RUN CODE >>
found otherwise return false.
14 Delete a specific item from a given doubly linked list. RUN CODE >>
55
Find the closest value to a given target value in a given non-empty Binary Search
2 RUN CODE >>
Tree (BST) of unique values.
3 Check whether a given binary tree is a valid binary search tree (BST) or not. RUN CODE >>
4 Delete a node with the given key in a given binary search tree (BST). RUN CODE >>
5 Convert a given array of elements to a height balanced Binary Search Tree (BST). RUN CODE >>
6 Find the kth smallest element in a given binary search tree. RUN CODE >>
56
Adds integer numbers from the data stream to a heapq and computes the median
16 RUN CODE >>
of all elements. Use the heap queue algorithm.
You have two integer arrays sorted in ascending order and an integer k. find k
17 number of pairs (u, v) which consist of one element from the first array and one RUN CODE >>
element from the second array using the heap queue algorithm.
18 Find the nth ugly number using the heap queue algorithm. RUN CODE >>
19 Print a heap as a tree-like data structure. RUN CODE >>
20 Write a combine two sorted lists using the heapq module. RUN CODE >>
21 Write a push three items into the heap and print the items from the heap. RUN CODE >>
Push three items into a heap and return the smallest item from the heap. Also, pop
22 RUN CODE >>
and return the smallest item from the heap.
23 Push an item on the heap, then pop and return the smallest item from the heap. RUN CODE >>
Create a heapsort, pushing all values onto a heap and then popping off the
24 RUN CODE >>
smallest values one at a time.
25 Get the two largest and three smallest items from a dataset. RUN CODE >>
26 Create a queue and display all the members and the size of the queue. RUN CODE >>
27 Find out whether a queue is empty or not RUN CODE >>
28 Create a FIFO queue. RUN CODE >>
29 Create a LIFO queue. RUN CODE >>
Python Bisect
1 Locate the left insertion point for a specified value in sorted order. RUN CODE >>
2 Locate the right insertion point for a specified value in sorted order. RUN CODE >>
3 Insert items into a list in sorted order. RUN CODE >>
Find the first occurrence of a given number in a sorted list using Binary Search
4 RUN CODE >>
(bisect).
Find the index position of the largest value smaller than a given number in a
5 RUN CODE >>
sorted list using Binary Search (bisect).
Find the index position of the last occurrence of a given number in a sorted list
6 RUN CODE >>
using Binary Search (bisect).
Find three integers which give the sum of zero in a given array of integers using
7 RUN CODE >>
Binary Search (bisect).
Find a triplet in an array such that the sum is closest to a given number. Return the
8 RUN CODE >>
sum of the three integers.
Find four elements from a given array of integers whose sum is equal to a given
9 RUN CODE >>
number. The solution set must not contain duplicate quadruplets.
57
Python Boolean Data Type
1 Check if a given number is even or odd using boolean variables. RUN CODE >>
Write a Python function that takes two boolean values as input and returns the
2 RUN CODE >>
logical AND and OR of those values.
Write a program that calculates whether a person is eligible for voting based on
3 RUN CODE >>
their age using boolean conditions.
Write a Python function that checks if a given list is empty or not using boolean
4 RUN CODE >>
logic.
5 Checks whether a given year is a leap year or not using boolean logic. RUN CODE >>
Write a Python function that checks if a given string is a palindrome (reads the
6 RUN CODE >>
same backward as forward) using boolean values.
Implements a program that validates a user's password based on certain criteria
7 (length, containing numbers and special characters etc.) using boolean RUN CODE >>
expressions.
Implements a function to check if a given string is a valid email address format
8 RUN CODE >>
using boolean logic.
Creates a function that determines if a given point (x, y) is within a specified circle
9 RUN CODE >>
area using boolean conditions.
Checks a simple authentication system. The program verifies the provided
10 username and password against predefined usernames and passwords by using RUN CODE >>
boolean checks.
58
Write a Python function that takes a list and returns a new list with None inserted
9 RUN CODE >>
between each element.
Write a Python function that replaces all occurrences of a substring in a string with
10 RUN CODE >>
another substring. Returns None if the original string is empty.
59
Python Frozenset Views Data Type
Performs common set operations like union, intersection, and difference of two
1 RUN CODE >>
frozensets.
Converts a "frozen set" to a regular set and vice versa. Compare the differences
2 RUN CODE >>
between these two data types
Converts a "frozen set" to a regular set and vice versa. Compare the differences
3 RUN CODE >>
between these two data types
Implements a function to generate the power set (set of all subsets) of a given
4 RUN CODE >>
frozenset.
5 Creates a frozenset with unique elements of a list RUN CODE >>
6 Creates a frozenset with unique elements of a list RUN CODE >>
7 Check if two frozensets are disjoint (set has no elements in common with other). RUN CODE >>
Demonstrates the immutability of a frozenset by attempting to add or remove
8 RUN CODE >>
elements from it.
Uses a frozenset as a key in a dictionary to create a hashable composite key for
9 RUN CODE >>
more complex data structures.
Generates a frozenset containing the squares of all odd numbers from 1 to 15
10 RUN CODE >>
using set comprehension.
60
Defines a NamedTuple named "Car" with fields 'make', 'model', 'year', and 'engine'
9 (a NamedTuple representing engine details). Create an instance of the "Car" RUN CODE >>
NamedTuple and print its attributes.
61
Python ellipsis (...) Data Type
Write a Python function that takes an arbitrary number of arguments using *args
1
and prints each argument. Use ... to represent unspecified arguments. RUN CODE >>
Write a Python function that takes a function as an argument and calls it with any
2 RUN CODE >>
number of arguments.
Write a Python function that takes a multidimensional array and slices the first two
3 RUN CODE >>
elements from the third dimension.
Creates a list containing numbers from 1 to 10, but leaves a gap at even positions
4 RUN CODE >>
using ellipsis.
Creates a list containing numbers from 1 to 10, but leaves a gap at even positions
5 RUN CODE >>
using ellipsis.
6 Uses 'Ellipsis' to create a multidimensional array with unspecified dimensions. RUN CODE >>
Create a generator expression that generates a sequence of numbers with ellipsis
7 RUN CODE >>
representing skipped values.
8 Uses Ellipsis to extend a sequence with another sequence. RUN CODE >>
Creates a custom class with an 'init' method. Use 'ellipsis' to indicate that some
9 RUN CODE >>
attributes may be added dynamically.
62
Merges multiple sorted inputs into a single sorted iterator (over the sorted values)
11 RUN CODE >>
using the heap queue algorithm.
Given a n x n matrix where each of the rows and columns is sorted in ascending
12 RUN CODE >>
order, find the kth smallest element in the matrix using the heap queue algorithm.
Find the nth super ugly number from a given prime list of size k using the heap
13 RUN CODE >>
queue algorithm.
Find the nth super ugly number from a given prime list of size k using the heap
14 RUN CODE >>
queue algorithm.
Check if the letters in a given string can be rearranged. This is to make sure that
15 two characters that are adjacent to each other are different using the heap queue RUN CODE >>
algorithm.
Adds integer numbers from the data stream to a heapq and computes the median
16 RUN CODE >>
of all elements. Use the heap queue algorithm.
You have two integer arrays sorted in ascending order and an integer k. find k
17 number of pairs (u, v) which consist of one element from the first array and one RUN CODE >>
element from the second array using the heap queue algorithm.
18 Find the nth ugly number using the heap queue algorithm. RUN CODE >>
19 Print a heap as a tree-like data structure. RUN CODE >>
20 Write a combine two sorted lists using the heapq module. RUN CODE >>
21 Write a push three items into the heap and print the items from the heap. RUN CODE >>
Push three items into a heap and return the smallest item from the heap. Also, pop
22 RUN CODE >>
and return the smallest item from the heap.
23 Push an item on the heap, then pop and return the smallest item from the heap. RUN CODE >>
Create a heapsort, pushing all values onto a heap and then popping off the
24 RUN CODE >>
smallest values one at a time.
25 Get the two largest and three smallest items from a dataset. RUN CODE >>
26 Create a queue and display all the members and the size of the queue. RUN CODE >>
27 Find out whether a queue is empty or not RUN CODE >>
28 Create a FIFO queue. RUN CODE >>
29 Create a LIFO queue. RUN CODE >>
Python Bisect
1 Locate the left insertion point for a specified value in sorted order. RUN CODE >>
2 Locate the right insertion point for a specified value in sorted order. RUN CODE >>
3 Insert items into a list in sorted order. RUN CODE >>
Find the first occurrence of a given number in a sorted list using Binary Search
4 RUN CODE >>
(bisect).
63
Find the index position of the largest value smaller than a given number in a
5 RUN CODE >>
sorted list using Binary Search (bisect).
Find the index position of the last occurrence of a given number in a sorted list
6 RUN CODE >>
using Binary Search (bisect).
Find three integers which give the sum of zero in a given array of integers using
7 RUN CODE >>
Binary Search (bisect).
Find a triplet in an array such that the sum is closest to a given number. Return the
8 RUN CODE >>
sum of the three integers.
Find four elements from a given array of integers whose sum is equal to a given
9 RUN CODE >>
number. The solution set must not contain duplicate quadruplets.
64
Iterates through a list of strings and prints each string. If a string is empty, print
3 RUN CODE >>
"Empty string" instead.
Write a Python function that checks if a given list is sorted in descending order.
4 RUN CODE >>
Return None if the list is empty.
Takes a user's input and converts it to uppercase. If the input is empty, return
5 RUN CODE >>
None.
Defines a dictionary and retrieves a value using a key. If the key is not found,
6 RUN CODE >>
return None.
Write a Python function that counts None values in a list recursively. Return 0 if the
7 RUN CODE >>
list is empty.
Write a Python function that takes two arguments and returns their sum if both
8 RUN CODE >>
aren't None, otherwise return None.
Write a Python function that takes a list and returns a new list with None inserted
9 RUN CODE >>
between each element.
Write a Python function that replaces all occurrences of a substring in a string with
10 RUN CODE >>
another substring. Returns None if the original string is empty.
65
5 Reads a binary file into a memory view and saves a modified copy. RUN CODE >>
Write a Python function that takes two memory views and concatenates them.
6 RUN CODE >>
Print the concatenated memory view.
7 Iterates over a memory view and increment each element by 10 using a loop. RUN CODE >>
Creates a memory view from a bytearray, reverses the order using slicing, and
8
converts back to a bytearray. RUN CODE >>
9 Takes a slice of a memory view using indexing syntax and prints the slice. RUN CODE >>
Creates a memory view from a list of integers and print the hex values of each
10 RUN CODE >>
element.
66
Write a Python function that takes a namedtuple as input of the item's name and
5 RUN CODE >>
price. Returns the item's name and price.
Write a Python function that takes a Student named tuple as an argument and
6 RUN CODE >>
calculates the average grade.
Defines a NamedTuple named "Circle" with fields 'radius' and 'center' (a Point
7 NamedTuple representing the coordinates of the center of the circle). Create an RUN CODE >>
instance of the "Circle" NamedTuple and print its attributes.
Defines a NamedTuple named "Triangle" with fields 'side1', 'side2', and 'side3'.
8 Now write a function that takes a "Triangle" NamedTuple as input and calculates RUN CODE >>
its area.
Defines a NamedTuple named "Car" with fields 'make', 'model', 'year', and 'engine'
9 (a NamedTuple representing engine details). Create an instance of the "Car" RUN CODE >>
NamedTuple and print its attributes.
67
Creates a counter of the words in a sentence and prints the words in ascending
5 RUN CODE >>
and descending order of their frequency.
6 Write a function that takes two 'Counter' objects and returns their sum. RUN CODE >>
Creates a 'Counter' for a list of items and converts it to a list of unique items with
7 RUN CODE >>
their counts.
Creates a 'Counter' for a list of words and removes all items with a count less than
8 RUN CODE >>
a certain value..
9 Find the Jaccard similarity coefficient between two lists using 'Counter' objects. RUN CODE >>
Creates a 'Counter' for a list of items and uses dictionary-style access to update
10 RUN CODE >>
the count of specific items.
68
7 Write a Python program that performs concurrent HTTP requests using threads. RUN CODE >>
69
Write a Python program to generate a float between 0 and 1, inclusive and
7 RUN CODE >>
generate a random float within a specific range. Use random.uniform()
Write a Python program to create a list of random integers and randomly select
8 RUN CODE >>
multiple items from the said list. Use random.sample()
Write a Python program to set a random seed and get a random number between
9 RUN CODE >>
0 and 1. Use random.random.
B. Module - types
Write a Python program to check if a function is a user-defined function or not. Use
1 RUN CODE >>
types.FunctionType, types.LambdaType()
Write a Python program to check if a given value is a method of a user-defined
2 RUN CODE >>
class. Use types.MethodType()
Write a Python program to check if a given function is a generator or not. Use
3 RUN CODE >>
types.GeneratorType()
Write a Python program to check if a given value is compiled code or not. Also
4 check if a given value is a module or not. Use types.CodeType, RUN CODE >>
types.ModuleType()
C. Module - decimal
Write a Python program to construct a Decimal from a float and a Decimal from a
1 RUN CODE >>
string. Also represent the decimal value as a tuple. Use decimal.Decimal
Write a Python program to configure rounding to round up and round down a given
2 RUN CODE >>
decimal value. Use decimal.Decimal
Write a Python program to round a decimal value to the nearest multiple of 0.10,
3 RUN CODE >>
unless already an exact multiple of 0.05. Use decimal.Decimal
Write a Python program to configure the rounding to round to the floor, ceiling. Use
4 RUN CODE >>
decimal.ROUND_FLOOR, decimal.ROUND_CEILING
Write a Python program that can be configured to round to the nearest - with ties
5 going towards 0 and ties going away from 0. Use decimal.ROUND_HALF_DOWN, RUN CODE >>
decimal.ROUND_HALF_UP
Write a Python program to configure rounding to round to the nearest integer, with
6 RUN CODE >>
ties going to the nearest even integer. Use decimal.ROUND_HALF_EVEN
Write a Python program to display a given decimal value in scientific notation. Use
7 RUN CODE >>
decimal.Decimal
D. Module - copy
1 Write a Python program to create a shallow copy of a given list. Use copy.copy RUN CODE >>
2 Write a Python program to create a deep copy of a given list. Use copy.copy RUN CODE >>
70
Write a Python program to create a shallow copy of a given dictionary. Use
3 RUN CODE >>
copy.copy
Write a Python program to create a deep copy of a given dictionary. Use
4 RUN CODE >>
copy.copy
E. Module - csv
Write a Python program to read and display the content of a given CSV file. Use
1 RUN CODE >>
csv.reader
Write a Python program to count the number of lines in a given CSV file. Use
2 RUN CODE >>
csv.reader
Write a Python program to parse a given CSV string and get a list of lists of string
3 RUN CODE >>
values. Use csv.reader
Write a Python program to read the current line from a given CSV file. Use
4 RUN CODE >>
csv.reader
5 Write a Python program to skip the headers of a given CSV file. Use csv.reader RUN CODE >>
Write a Python program to write (without writing separate lines between rows) and
6 RUN CODE >>
read a CSV file with a specified delimiter. Use csv.reader
Write a Python program to write dictionaries and a list of dictionaries to a given
7 RUN CODE >>
CSV file. Use csv.reader
Python OS Services
Write a Python program to get the name of the operating system (Platform
independent), information of the current operating system, current working
1 RUN CODE >>
directory, print files and directories in the current directory, and raise errors if the
path or file name is invalid.
Write a Python program to list only directories, files and all directories, files in a
2 RUN CODE >>
specified path.
Write a Python program to scan a specified directory and identify the
3 RUN CODE >>
subdirectories and files.
Write a Python program to check access to a specified path. Test the existence,
4 RUN CODE >>
readability, writability and executability of the specified path.
Write a Python program to get the size, permissions, owner, device, created, last
5 RUN CODE >>
modified and last accessed date and time of a specified path.
Write a Python program to create a symbolic link and read it to determine the
6 RUN CODE >>
original file pointed to by the link.
Write a Python program to create a file and write some text and rename the file
7 RUN CODE >>
name.
Write a Python program to find the parent's process ID, real user ID of the current
8 RUN CODE >>
process and change the real user ID.
71
Write a Python program to retrieve the current working directory and change the
9 RUN CODE >>
dir (move up one).
Write a Python program to access environment variables and the value of the
10 RUN CODE >>
environment variable.
Write a Python program to iterate over a root level path and print all its
11 RUN CODE >>
sub-directories and files, as well as loop over specified dirs and files.
Write a Python program to test whether a given path exists or not. Find the
12 RUN CODE >>
filename and directory portion of the path if it exists.
Write a Python program to join one or more path components together and split a
13 RUN CODE >>
given path into directories and files.
14 Write a Python program to alter the owner and the group ID of a specified file. RUN CODE >>
Write a Python program to get information about the file pertaining to file mode.
Print the information - ID of device containing file, inode number, protection,
15 RUN CODE >>
number of hard links, user ID of owner, group ID of owner, total size (in bytes),
time of last access, time of last modification and time of last status change.
Write a Python program to write a string to a buffer and retrieve the value written,
16 RUN CODE >>
at the end discard buffer memory.
Write a Python program to run an operating system command using the OS
17 RUN CODE >>
module.
18 Write a Python program to start a new process replacing the current process. RUN CODE >>
Python Math
1 Write a Python program to convert degrees to radians. RUN CODE >>
2 Write a Python program to convert radians to degrees. RUN CODE >>
3 Write a Python program to calculate the area of a trapezoid. RUN CODE >>
4 Write a Python program to calculate the area of a parallelogram. RUN CODE >>
5 Write a Python program to calculate the surface volume and area of a cylinder. RUN CODE >>
6 Write a Python program to calculate the surface volume and area of a sphere. RUN CODE >>
7 Write a Python program to calculate the arc length of an angle. RUN CODE >>
8 Write a Python program to calculate the area of the sector. RUN CODE >>
9 Write a Python program to calculate the discriminant value. RUN CODE >>
Write a Python program to find the smallest multiple of the first n numbers. Also,
10 RUN CODE >>
display the factors.
Write a Python program to calculate the difference between the squared sum of
11 RUN CODE >>
the first n natural numbers and the sum of squared first n natural numbers.
Write a Python program to calculate the sum of all digits of the base to the
12 RUN CODE >>
specified power.
13 Write a Python program to find out if the given number is abundant. RUN CODE >>
72
14 Write a Python program to find out if the given number is abundant. RUN CODE >>
15 Write a Python program to return the sum of all divisors of a number. RUN CODE >>
Write a Python program to print all permutations of a given string (including
16 RUN CODE >>
duplicates).
17 Write a Python program to print the first n lucky numbers. RUN CODE >>
18 Write a Python program to compute square roots using the Babylonian method. RUN CODE >>
19 Write a Python program to multiply two integers without using the * operator. RUN CODE >>
20 Write a Python program to calculate the magic square. RUN CODE >>
Write a Python program to print all primes (Sieve_of_Eratosthenes) smaller than
21 RUN CODE >>
or equal to a specified number.
Write a Python program to find the next smallest palindrome of a specified
22 RUN CODE >>
number.
Write a Python program to find the next and previous palindromes of a specified
23 RUN CODE >>
number.
24 Write a Python program to convert a float to ratio. RUN CODE >>
25 Write a Python program for the nth Catalan numbers. RUN CODE >>
26 Write a Python program to display numbers separated by commas as thousands. RUN CODE >>
Write a Python program to calculate the distance between two points using latitude
27 RUN CODE >>
and longitude.
28 Write a Python program to calculate the area of a regular polygon. RUN CODE >>
29 Write a Python program to calculate the wind chill index. RUN CODE >>
30 Write a Python program to find the roots of a quadratic function. RUN CODE >>
31 Write a Python program to convert a decimal number to a binary number. RUN CODE >>
Write a Python program to print a complex number and its real and imaginary
32 RUN CODE >>
parts.
Write a Python program to add, subtract, multiply, and divide two complex
33 RUN CODE >>
numbers.
34 Write a Python program to get the length and the angle of a complex number. RUN CODE >>
35 Write a Python program to convert Polar coordinates to rectangular coordinates. RUN CODE >>
Write a Python program to find the maximum and minimum numbers from the
36 RUN CODE >>
specified decimal numbers.
Write a Python program to find the sum of the following decimal numbers and
37 RUN CODE >>
display the numbers in sorted order.
Write a Python program to get the square root and exponential of a given decimal
38 RUN CODE >>
number.
Write a Python program to retrieve the current global context (public properties) for
39 RUN CODE >>
all decimal.
73
Write a Python program to round a specified decimal by setting precision (between
40 RUN CODE >>
1 and 4).
Write a Python program to round a specified number upwards towards infinity and
41 RUN CODE >>
down towards negative infinity with precision 4.
42 Write a Python program to get the local and default precision. RUN CODE >>
Write a Python program to display fraction instances of the string representation of
43 RUN CODE >>
a number.
44 Write a Python program to create fraction instances of float numbers. RUN CODE >>
45 Write a Python program to create fraction instances of decimal numbers. RUN CODE >>
46 Write a Python program to add, subtract, multiply and divide two fractions. RUN CODE >>
Write a Python program to convert a floating point number (PI) to an approximate
47 RUN CODE >>
rational value on the various denominators.
Write a Python program to generate random floating numbers in a specific
48 RUN CODE >>
numerical range.
49 Write a Python program to generate random integers in a specific numerical range RUN CODE >>
Write a Python program to generate random even integers in a specific numerical
50 RUN CODE >>
range.
51 Write a Python program to get a single random element from a specified string. RUN CODE >>
52 Write a Python program to shuffle the following elements randomly. RUN CODE >>
53 Write a Python program to flip a coin 1000 times and count heads and tails. RUN CODE >>
Write a Python program to print a random sample of words from the system
54 RUN CODE >>
dictionary.
55 Write a Python program to randomly select an item from a list. RUN CODE >>
56 Write a Python program to calculate the absolute value of a floating point number. RUN CODE >>
57 Write a Python program to calculate the standard deviation of the following data. RUN CODE >>
58 Write a Python program to print the floating point of the mantissa, exponent pair. RUN CODE >>
Write a Python program to split the fractional and integer parts of a floating point
59
number. RUN CODE >>
Write a Python program to parse math formulas and put parentheses around
60 RUN CODE >>
multiplication and division.
61 Write a Python program to describe linear regression. RUN CODE >>
Write a Python program to calculate a grid of hexagon coordinates of the given
radius given lower-left and upper-right coordinates. The function will return a list of
62 RUN CODE >>
lists containing 6 tuples of x, y point coordinates. These can be used to construct
valid regular hexagonal polygons.
63 Write a Python program to create a simple math quiz. RUN CODE >>
64 Write a Python program to calculate the volume of a tetrahedron. RUN CODE >>
74
Write a Python program to compute the value of e(2.718281827...) using an
65 RUN CODE >>
infinite series.
66 Write a Python program to create an ASCII waveform. RUN CODE >>
67 Write a Python program to create a dot string. RUN CODE >>
68 Write a Python program to create a Pythagorean theorem calculator. RUN CODE >>
69 Write a Python function to round up a number to specified digits. RUN CODE >>
70 Write a Python program for a casino simulation. RUN CODE >>
71 Write a Python program to reverse a range. RUN CODE >>
72 Write a Python program to create a range for floating numbers. RUN CODE >>
Write a Python program to generate (given an integer n) a square matrix filled with
73 RUN CODE >>
elements from 1 to n raised to the power of 2 in spiral order.
74 Write a Python program to select a random date in the current year. RUN CODE >>
Write a Python program to calculate clusters using the Hierarchical Clustering
75 RUN CODE >>
method.
Write a Python program to implement the Euclidean Algorithm to compute the
76 RUN CODE >>
greatest common divisor (GCD).
77 Write a Python program to convert RGB color to HSV color. RUN CODE >>
78 Write a Python program to find perfect squares between two given numbers. RUN CODE >>
79 Write a Python program to compute Euclidean distances. RUN CODE >>
80 Write a Python program to convert an integer to a 2 byte Hex value. RUN CODE >>
81 Write a Python program to generate a series of distinct random numbers. RUN CODE >>
82 Write a Python program to convert a given float value to a ratio. RUN CODE >>
83 Write a Python program to calculate the aliquot sum of a given number. RUN CODE >>
Write a Python program to get the nth tetrahedral number from a given integer(n)
84 RUN CODE >>
value.
Write a Python program to get the sum of the powers of all the numbers from start
85 RUN CODE >>
to end (both inclusive).
Write a Python program to calculate the Hamming distance between two given
86
values. RUN CODE >>
Write a Python program to cap a number within the inclusive range specified by
87 RUN CODE >>
the given boundary values x and y.
Write a Python program to check whether a given number is a Disarium number or
88 RUN CODE >>
an unhappy number.
Write a Python program to check if a given number is a repdigit number or not. If
89 RUN CODE >>
the given number is repdigit return true otherwise false.
Write a Python program that accepts an integer number with distinct digits and
90 RUN CODE >>
displays the next number containing only distinct digits.
75
Write a Python program to check if a given number is a Harshad number or not.
91 RUN CODE >>
Return True if the number is Harshad otherwise False.
Write a Python program that checks whether the absolute difference between two
92 RUN CODE >>
consecutive digits is two or not. Return true otherwise false.
Write a Python program that takes an integer and rearranges the digits to create
93 RUN CODE >>
two maximum and minimum numbers.
Write a Python program to calculate the sum of all prime numbers in a given list of
94 RUN CODE >>
positive integers.
Python Requests
Write a Python program to find the Requests module version, licence, copyright
1 RUN CODE >>
information, author, author email, document url, title and description.
Write a Python program to check the status code issued by a server in response to
2 a client's request made to the server. Print all of the methods and attributes RUN CODE >>
available to objects on a successful request.
Write a Python program to send a request to a web page, and print the response
3 RUN CODE >>
text and content. Also get the raw socket response from the server.
Write a Python program to send a request to a web page, and print the header
4 information. Also parse these values and print key-value pairs holding various RUN CODE >>
information.
Write a Python program to send a request to a web page, and print the JSON
5 RUN CODE >>
value of the response. Print each key value in the response.
Write a Python program to send a request to a web page and stop waiting for a
6 response after a given number of seconds. If a request times out, raise a Timeout RUN CODE >>
exception.
7 Write a Python program to send some sort of data in the URL's query string. RUN CODE >>
Write a Python program to send cookies to a given server and access cookies
8 RUN CODE >>
from the response of a server.
9 Write a Python program to verify the SSL certificate for a website that is certified. RUN CODE >>
76
Write a Python program to create a table and insert some records in that table.
5 RUN CODE >>
Finally selects all rows from the table and display the records.
6 Write a Python program to insert a list of records into a given SQLite table. RUN CODE >>
7 Write a Python program to insert values to a table from user input. RUN CODE >>
8 Write a Python program to count the number of rows of a given SQLite table. RUN CODE >>
Write a Python program to update a specific column value of a given table and
9 RUN CODE >>
select all rows before and after updating the said table.
Write a Python program to update a specific column value of a given table and
10 RUN CODE >>
select all rows before and after updating the said table.
11 Write a Python program to delete a specific row from a given SQLite table RUN CODE >>
12 Write a Python program to alter a given SQLite table. RUN CODE >>
13 Write a Python program to create a backup of a SQLite database. RUN CODE >>
77
Write a Python program to delete an order from the 'Order' table by its id. Use the
13 RUN CODE >>
SQLAlchemy model.
Write a Python program that performs aggregation queries to get the total number
14 of orders, total sales amount, minimum item price, maximum item price and RUN CODE >>
average order quantity using SQLAlchemy.
Python pprint
Write a Python program to print a dictionary, nested dictionary, list of dictionaries
1 RUN CODE >>
of dictionaries using the print module.
Write a Python program to sort the keys of a dictionary before printing it using the
2 RUN CODE >>
print module.
Write a Python program that specifies the width of the output while printing a list,
3 RUN CODE >>
dictionary usinprint module.
Write a Python program that specifies the indentation while printing a nested
4 RUN CODE >>
dictionary using the print module.
Write a Python program to fetch information about a project (from PyPI) using
5 RUN CODE >>
pprint() function.
Write a Python program to fetch information about a project (i.e. PyPI) using
6 pprint() function. Limit the result to a certain level and specify the width of the RUN CODE >>
content.
78
Pwned" API (https://haveibeenpwned.com/API/v3) to check if a password has
been leaked.
Write a Python program that creates a password strength meter. The program
should prompt the user to enter a password and check its strength based on
7 RUN CODE >>
criteria such as length, complexity, and randomness. Afterwards, the program
should provide suggestions for improving the password's strength.
Write a Python program that generates a password using a random combination of
8 RUN CODE >>
words from a dictionary file.
Write a Python program that simulates a dictionary attack on a password by trying
9 RUN CODE >>
out a list of commonly used passwords and their variations.
Write a Python program that simulates a brute-force attack on a password by
10 RUN CODE >>
trying out all possible character combinations.
79
Write a Python program to create a generator that generates the square, cube
13 RUN CODE >>
roots of numbers from 1 to n.
Write a Python program to implement a generator that generates the next
14 RUN CODE >>
Armstrong number after a given number.
Write a Python program to create a generator function that generates all factors of
15 RUN CODE >>
a given number.
Write a Python program to implement a generator function that generates the
16 RUN CODE >>
running average of a sequence of numbers.
Write a Python program to implement a generator function that generates the
17
running average of a sequence of numbers. RUN CODE >>
80
Write a Pandas program to calculate the frequency counts of each unique value of
19 RUN CODE >>
a given series.
Write a Pandas program to display most frequent value in a given series and
20 RUN CODE >>
replace everything else as 'Other' in the series.
Write a Pandas program to find the positions of numbers that are multiples of 5 of
21 RUN CODE >>
a given series.
22 Write a Pandas program to extract items at given positions of a given series. RUN CODE >>
Write a Pandas program to get the positions of items of a given series in another
23 RUN CODE >>
given series.
Write a Pandas program convert the first and last character of each word to upper
24 RUN CODE >>
case in each word of a given series.
Write a Pandas program to calculate the number of characters in each word in a
25 RUN CODE >>
given series.
Write a Pandas program to compute difference of differences between
26 RUN CODE >>
consecutive numbers of a given series.
27 Write a Pandas program to convert a series of date strings to a timeseries. RUN CODE >>
Write a Pandas program to get the day of month, day of year, week number and
28 RUN CODE >>
day of week from a given series of date strings.
Write a Pandas program to convert year-month string to dates adding a specified
29 RUN CODE >>
day of the month.
Write a Pandas program to filter words from a given series that contain atleast two
30 RUN CODE >>
vowels.
Write a Pandas program to compute the Euclidean distance between two given
31 RUN CODE >>
series.
Write a Pandas program to find the positions of the values neighboured by smaller
32 RUN CODE >>
values on both sides in a given series.
Write a Pandas program to replace missing white spaces in a given string with the
33 RUN CODE >>
least frequent character.
Write a Pandas program to compute the autocorrelations of a given numeric
34 RUN CODE >>
series.
Write a Pandas program to create a TimeSeries to display all the Sundays of given
35 RUN CODE >>
year.
Write a Pandas program to convert given series into a dataframe with its index as
36 RUN CODE >>
another column on the dataframe.
37 Write a Pandas program to stack two given series vertically and horizontally. RUN CODE >>
38 Write a Pandas program to check the equality of two given series. RUN CODE >>
Write a Pandas program to find the index of the first occurrence of the smallest
39 RUN CODE >>
and largest value of a given series.
81
Write a Pandas program to check inequality over the index axis of a given
40 RUN CODE >>
dataframe and a given series.
Pandas DataFrame
1 Write a Pandas program to create a dataframe from a dictionary and display it. RUN CODE >>
Write a Pandas program to create and display a DataFrame from a specified
2 RUN CODE >>
dictionary data which has the index labels.
Write a Pandas program to display a summary of the basic information about a
3 RUN CODE >>
specified DataFrame and its data.
4 Write a Pandas program to get the first 3 rows of a given DataFrame. RUN CODE >>
Write a Pandas program to select the 'name' and 'score' columns from the
5 RUN CODE >>
following DataFrame.
Write a Pandas program to select the specified columns and rows from a given
6 RUN CODE >>
data frame.
Write a Pandas program to select the rows where the number of attempts in the
7 RUN CODE >>
examination is greater than 2.
Write a Pandas program to count the number of rows and columns of a
8 RUN CODE >>
DataFrame.
9 Write a Pandas program to select the rows where the score is missing, i.e. is NaN. RUN CODE >>
Write a Pandas program to select the rows the score is between 15 and 20
10 RUN CODE >>
(inclusive).
Write a Pandas program to select the rows where number of attempts in the
11 RUN CODE >>
examination is less than 2 and score greater than 15.
12 Write a Pandas program to change the score in row 'd' to 11.5. RUN CODE >>
Write a Pandas program to calculate the sum of the examination attempts by the
13 RUN CODE >>
students.
Write a Pandas program to calculate the mean of all students' scores. Data is
14 RUN CODE >>
stored in a dataframe.
Write a Pandas program to append a new row 'k' to data frame with given values
15 RUN CODE >>
for each column. Now delete the new row and return the original DataFrame.
Write a Pandas program to sort the DataFrame first by 'name' in descending order,
16 RUN CODE >>
then by 'score' in ascending order.
Write a Pandas program to replace the 'qualify' column contains the values 'yes'
17 RUN CODE >>
and 'no' with True and False.
Write a Pandas program to change the name 'James' to 'Suresh' in name column
18 RUN CODE >>
of the DataFrame.
19 Write a Pandas program to delete the 'attempts' column from the DataFrame. RUN CODE >>
20 Write a Pandas program to insert a new column in existing DataFrame. RUN CODE >>
82
21 Write a Pandas program to iterate over rows in a DataFrame. RUN CODE >>
22 Write a Pandas program to get list from DataFrame column headers. RUN CODE >>
23 Write a Pandas program to rename columns of a given DataFrame RUN CODE >>
Write a Pandas program to select rows from a given DataFrame based on values
24 RUN CODE >>
in some columns.
25 Write a Pandas program to change the order of a DataFrame columns. RUN CODE >>
26 Write a Pandas program to add one row in an existing DataFrame. RUN CODE >>
27 Write a Pandas program to write a DataFrame to CSV file using tab separator. RUN CODE >>
Write a Pandas program to count city wise number of people from a given of data
28 RUN CODE >>
set (city, name of the person).
Write a Pandas program to delete DataFrame row(s) based on given column
29 RUN CODE >>
value.
30 Write a Pandas program to widen output display to see more columns. RUN CODE >>
Write a Pandas program to select a row of series/dataframe by given integer
31 RUN CODE >>
index.
Write a Pandas program to replace all the NaN values with Zero's in a column of a
32
dataframe. RUN CODE >>
33 Write a Pandas program to convert index in a column of the given dataframe. RUN CODE >>
Write a Pandas program to set a given value for particular cell in DataFrame using
34 RUN CODE >>
index value.
Write a Pandas program to count the NaN values in one or more columns in
35 RUN CODE >>
DataFrame.
36 Write a Pandas program to drop a list of rows from a specified DataFrame. RUN CODE >>
37 Write a Pandas program to reset index in a given DataFrame. RUN CODE >>
38 Write a Pandas program to divide a DataFrame in a given ratio. RUN CODE >>
39 Write a Pandas program to combining two series into a DataFrame. RUN CODE >>
40 Write a Pandas program to shuffle a given DataFrame rows. RUN CODE >>
Write a Pandas program to convert DataFrame column type from string to
41 RUN CODE >>
datetime.
42 Write a Pandas program to rename a specific column name in a given DataFrame. RUN CODE >>
43 Write a Pandas program to get a list of a specified column of a DataFrame. RUN CODE >>
Write a Pandas program to create a DataFrame from a Numpy array and specify
44 RUN CODE >>
the index column and column headers.
Write a Pandas program to find the row for where the value of a given column is
45 RUN CODE >>
maximum.
Write a Pandas program to check whether a given column is present in a
46 RUN CODE >>
DataFrame or not.
83
47 Write a Pandas program to get the specified row value of a given DataFrame. RUN CODE >>
48 Write a Pandas program to get the datatypes of columns of a DataFrame. RUN CODE >>
49 Write a Pandas program to append data to an empty DataFrame. RUN CODE >>
50 Write a Pandas program to sort a given DataFrame by two or more columns. RUN CODE >>
51 Write a Pandas program to convert the datatype of a given column (floats to ints). RUN CODE >>
52 Write a Pandas program to remove infinite values from a given DataFrame. RUN CODE >>
Write a Pandas program to insert a given column at a specific column index in a
53 RUN CODE >>
DataFrame.
54 Write a Pandas program to convert a given list of lists into a Dataframe. RUN CODE >>
Write a Pandas program to group by the first column and get second column as
55 RUN CODE >>
lists in rows.
Write a Pandas program to get column index from column name of a given
56 RUN CODE >>
DataFrame.
57 Write a Pandas program to count number of columns of a DataFrame. RUN CODE >>
Write a Pandas program to select all columns, except one given column in a
58 RUN CODE >>
DataFrame.
59 Write a Pandas program to get first n records of a DataFrame. RUN CODE >>
60 Write a Pandas program to get last n records of a DataFrame. RUN CODE >>
Write a Pandas program to get topmost n records within each group of a
61 RUN CODE >>
DataFrame.
62 Write a Pandas program to remove first n rows of a given DataFrame. RUN CODE >>
63 Write a Pandas program to remove last n rows of a given DataFrame. RUN CODE >>
Write a Pandas program to add a prefix or suffix to all columns of a given
64 RUN CODE >>
DataFrame.
65 Write a Pandas program to reverse order (rows, columns) of a given DataFrame. RUN CODE >>
66 Write a Pandas program to select columns by data type of a given DataFrame. RUN CODE >>
67 Write a Pandas program to split a given DataFrame into two random subsets. RUN CODE >>
Write a Pandas program to rename all columns with the same pattern of a given
68 RUN CODE >>
DataFrame.
69 Write a Pandas program to merge datasets and check uniqueness. RUN CODE >>
Write a Pandas program to convert continuous values of a column in a given
70 RUN CODE >>
DataFrame to categorical.
Write a Pandas program to display memory usage of a given DataFrame and
71 RUN CODE >>
every column of the DataFrame.
72 Write a Pandas program to combine many given series to create a DataFrame. RUN CODE >>
Write a Pandas program to create DataFrames that contains random values,
73 RUN CODE >>
contains missing values, contains datetime values and contains mixed values.
84
74 Write a Pandas program to fill missing values in time series data. RUN CODE >>
75 Write a Pandas program to use a local variable within a query. RUN CODE >>
Write a Pandas program to clean object column with mixed data of a given
76 RUN CODE >>
DataFrame using regular expression.
Write a Pandas program to get the numeric representation of an array by
77 RUN CODE >>
identifying distinct values of a given column of a dataframe.
Write a Pandas program to replace the current value in a dataframe column based
78 on last largest value. If the current value is less than last largest value replaces the RUN CODE >>
value with 0.
Write a Pandas program to create a DataFrame from the clipboard (data from an
79 RUN CODE >>
Excel spreadsheet or a Google Sheet).
80 Write a Pandas program to check for inequality of two given DataFrames. RUN CODE >>
Write a Pandas program to get lowest n records within each group of a given
81 RUN CODE >>
DataFrame.
Pandas Indexing
Write a Pandas program to display the default index and set a column as an Index
1 RUN CODE >>
in a given dataframe.
Write a Pandas program to create a multi Index frame using two columns and
2 RUN CODE >>
using an Index and a column.
Write a Pandas program to display the default index and set a column as an Index
3 RUN CODE >>
in a given dataframe and then reset the index
Write a Pandas program to create an index labels by using 64-bit integers, using
4 RUN CODE >>
floating-point numbers in a given dataframe.
5 Write a Pandas program to create a DataFrame using intervals as an index. RUN CODE >>
6 Write a Pandas program to create a dataframe indexing by date and time. RUN CODE >>
Write a Pandas program to create a dataframe and set a title or name of the index
7 RUN CODE >>
column.
Write a Pandas program to set value in a specific cell in a given dataframe using
8 RUN CODE >>
index.
9 Write a Pandas program to convert index of a given dataframe into a column. RUN CODE >>
Write a Pandas program to convert 1st and 3rd levels in the index into columns
10 RUN CODE >>
from a multiple level of index frame of a given dataframe.
Write a Pandas program to check if a specified value exists in single and multiple
11 RUN CODE >>
column index dataframe.
Write a Pandas program to construct a series using the MultiIndex levels as the
12 RUN CODE >>
column and index.
85
Write a Pandas program to construct a DataFrame using the MultiIndex levels as
13 RUN CODE >>
the column and index.
Write a Pandas program to extract a single row, rows and a specific value from a
14 RUN CODE >>
MultiIndex levels DataFrame.
Write a Pandas program to rename names of columns and specific labels of the
15 RUN CODE >>
Main Index of the MultiIndex dataframe.
Write a Pandas program to sort a MultiIndex of a DataFrame. Also sort on various
16 RUN CODE >>
levels of index.
Write a Pandas program to extract elements in the given positional indices along
17 RUN CODE >>
an axis of a dataframe.
18 Write a Pandas program to get the index of an element of a given Series. RUN CODE >>
Write a Pandas program to select a specific row of given series/dataframe by
19 RUN CODE >>
integer index.
Write a Pandas program to find the indexes of rows of a specified value of a given
20 RUN CODE >>
column in a DataFrame.
Write a Pandas program to drop a index level from a multi-level column index of a
21 RUN CODE >>
dataframe.
Write a Pandas program to insert a column at a specific index in a given
22 RUN CODE >>
DataFrame.
23 Write a Pandas program to print a DataFrame without index. RUN CODE >>
Write a Pandas program to find integer index of rows with missing data in a given
24 RUN CODE >>
dataframe.
Write a Pandas program to start index with different value rather than 0 in a given
25 RUN CODE >>
DataFrame
Write a Pandas program to select rows by filtering on one or more column(s) in a
26
multi-index dataframe. RUN CODE >>
86
Write a Pandas program to count of occurrence of a specified substring in a
6 RUN CODE >>
DataFrame column.
Write a Pandas program to find the index of a given substring of a DataFrame
7 RUN CODE >>
column.
Write a Pandas program to find the index of a substring of DataFrame with
8 RUN CODE >>
beginning and end position.
Write a Pandas program to check whether alpha numeric values present in a given
9 RUN CODE >>
column of a DataFrame.
Write a Pandas program to check whether alphabetic values present in a given
10 RUN CODE >>
column of a DataFrame.
Write a Pandas program to check whether only numeric values present in a given
11 RUN CODE >>
column of a DataFrame.
Write a Pandas program to check whether only lower case or upper case is
12 RUN CODE >>
present in a given column of a DataFrame
Write a Pandas program to check whether only proper case or title case is present
13 RUN CODE >>
in a given column of a DataFrame.
Write a Pandas program to check whether only space is present in a given column
14 RUN CODE >>
of a DataFrame.
Write a Pandas program to get the length of the string present of a given column in
15 RUN CODE >>
a DataFrame.
Write a Pandas program to get the length of the integer of a given column in a
16 RUN CODE >>
DataFrame.
Write a Pandas program to check if a specified column starts with a specified
17 RUN CODE >>
string in a DataFrame.
Write a Pandas program to swap the cases of a specified character column in a
18 RUN CODE >>
given DataFrame.
Write a Pandas program to convert a specified character column in upper/lower
19 RUN CODE >>
cases in a given DataFrame.
Write a Pandas program to convert a specified character column in title case in a
20 RUN CODE >>
given DataFrame.
Write a Pandas program to replace arbitrary values with other values in a given
21 RUN CODE >>
DataFrame.
Write a Pandas program to replace more than one value with other values in a
22 RUN CODE >>
given DataFrame.
Write a Pandas program to split a string of a column of a given DataFrame into
23 RUN CODE >>
multiple columns.
Write a Pandas program to extract email from a specified column of string type of
24 RUN CODE >>
a given DataFrame.
87
Write a Pandas program to extract hash attached word from twitter text from the
25 RUN CODE >>
specified column of a given DataFrame.
Write a Pandas program to extract word mention someone in tweets using @ from
26 RUN CODE >>
the specified column of a given DataFrame.
Write a Pandas program to extract only number from the specified column of a
27 RUN CODE >>
given DataFrame.
Write a Pandas program to extract only phone number from the specified column
28 RUN CODE >>
of a given DataFrame.
Write a Pandas program to extract year between 1800 to 2200 from the specified
29 RUN CODE >>
column of a given DataFrame.
Write a Pandas program to extract only non alphanumeric characters from the
30 RUN CODE >>
specified column of a given DataFrame.
Write a Pandas program to extract only punctuations from the specified column of
31 RUN CODE >>
a given DataFrame.
Write a Pandas program to remove repetitive characters from the specified column
32 RUN CODE >>
of a given DataFrame.
Write a Pandas program to extract numbers greater than 940 from the specified
33 RUN CODE >>
column of a given DataFrame.
Write a Pandas program to extract numbers less than 100 from the specified
34 RUN CODE >>
column of a given DataFrame.
Write a Pandas program to check whether two given words present in a specified
35 RUN CODE >>
column of a given DataFrame.
Write a Pandas program to extract date (format: mm-dd-yyyy) from a given column
36 RUN CODE >>
of a given DataFrame.
Write a Pandas program to extract only words from a given column of a given
37 RUN CODE >>
DataFrame.
Write a Pandas program to extract the sentences where a specific word is present
38 RUN CODE >>
in a given column of a given DataFrame.
Write a Pandas program to extract the unique sentences from a given column of a
39 RUN CODE >>
given DataFrame
Write a Pandas program to extract words starting with capital words from a given
40 RUN CODE >>
column of a given DataFrame.
Write a Pandas program to remove the html tags within the specified column of a
41 RUN CODE >>
given DataFrame.
88
Write a Pandas program to join the two given dataframes along columns and
2 RUN CODE >>
assign all data.
Write a Pandas program to append rows to an existing DataFrame and display the
3 RUN CODE >>
combined data.
Write a Pandas program to append a list of dictioneries or series to a existing
4 RUN CODE >>
DataFrame and display the combined data.
Write a Pandas program to join the two given dataframes along rows and merge
5 RUN CODE >>
with another dataframe along the common column id.
Write a Pandas program to join the two dataframes using the common column of
6 RUN CODE >>
both dataframes.
Write a Pandas program to join the two dataframes with matching records from
7 RUN CODE >>
both sides where available.
Write a Pandas program to join (left join) the two dataframes using keys from left
8 RUN CODE >>
dataframe only
Write a Pandas program to join two dataframes using keys from right dataframe
9 RUN CODE >>
only.
10 Write a Pandas program to merge two given datasets using multiple join keys. RUN CODE >>
Write a Pandas program to create a new DataFrame based on existing series,
11 RUN CODE >>
using specified argument and override the existing columns names.
Write a Pandas program to create a combination from two dataframes where a
12 RUN CODE >>
column id combination appears more than once in both dataframes.
Write a Pandas program to combine the columns of two potentially
13 RUN CODE >>
differently-indexed DataFrames into a single result DataFrame.
14 Write a Pandas program to merge two given dataframes with different columns. RUN CODE >>
Write a Pandas program to Combine two DataFrame objects by filling null values
15 RUN CODE >>
in one DataFrame with non-null values from other DataFrame.
89
Write a Pandas program to create a date range using a startpoint date and a
6 RUN CODE >>
number of periods.
Write a Pandas program to create a whole month of dates in daily frequencies.
7 RUN CODE >>
Also find the maximum, minimum timestamp and indexs.
8 Write a Pandas program to create a time series using three months frequency. RUN CODE >>
9 Write a Pandas program to create a sequence of durations increasing by an hour. RUN CODE >>
Write a Pandas program to convert year and day of year into a single datetime
10 RUN CODE >>
column of a dataframe.
Write a Pandas program to create a series of Timestamps from a DataFrame of
11 integer or string columns. Also create a series of Timestamps using specified RUN CODE >>
columns.
12 Write a Pandas program to check if a day is a business day (weekday) or not. RUN CODE >>
Write a Pandas program to get a time series with the last working days of each
13 RUN CODE >>
month of a specific year.
14 Write a Pandas program to create a time series combining hour and minute. RUN CODE >>
Write a Pandas program to convert unix/epoch time to a regular time stamp in
15 RUN CODE >>
UTC. Also convert the said timestamp in to a given time zone.
16 Write a Pandas program to create a time series object with a time zone. RUN CODE >>
Write a Pandas program to remove the time zone information from a Time series
17 RUN CODE >>
data.
Write a Pandas program to subtract two timestamps of same time zone or different
18 RUN CODE >>
time zone.
19 Write a Pandas program to calculate all Thursdays between two given days. RUN CODE >>
Write a Pandas program to find the all the business quarterly begin and end dates
20 RUN CODE >>
of a specified year.
Write a Pandas program to generate sequences of fixed-frequency dates and time
21 RUN CODE >>
spans intervals.
Write a Pandas program to generate time series combining day and intraday
22 RUN CODE >>
offsets intervals.
Write a Pandas program to extract the day name from a specified date. Add 2
23 RUN CODE >>
days and 1 business day with the specified date.
Write a Pandas program to convert integer or float epoch times to Timestamp and
24 RUN CODE >>
DatetimeIndex.
Write a Pandas program to calculate one, two, three business day(s) from a
25 RUN CODE >>
specified date. Also find the next business month end from a specific date.
Write a Pandas program to create a period index represent all monthly boundaries
26 of a given year. Also print start and end time for each period object in the said RUN CODE >>
index
90
Write a Pandas program create a series with a PeriodIndex which represents all
27 the calendar month periods in 2029 and 2031. Also print the values for all periods RUN CODE >>
in 2030.
Write a Pandas program to generate holidays between two dates using the US
28 RUN CODE >>
federal holiday calendar.
Write a Pandas program to create a monthly time period and display the list of
29 RUN CODE >>
names in the current local scope.
Write a Pandas program to create a yearly time period from a specified year and
30 RUN CODE >>
display the properties of this period.
Pandas Filter
Write a Pandas program to display the dimensions or shape of the World alcohol
1 RUN CODE >>
consumption dataset. Also extract the column names from the dataset.
Write a Pandas program to select first 2 rows, 2 columns and specific two columns
2 RUN CODE >>
from World alcohol consumption dataset.
Write a Pandas program to select random number of rows, fraction of random
3 RUN CODE >>
rows from World alcohol consumption dataset.
Write a Pandas program to find and drop the missing values from World alcohol
4 RUN CODE >>
consumption dataset.
Write a Pandas program to remove the duplicates from 'WHO region' column of
5 RUN CODE >>
World alcohol consumption dataset.
Write a Pandas program to find out the alcohol consumption of a given year from
6 RUN CODE >>
the world alcohol consumption dataset.
Write a Pandas program to find out the alcohol consumption details in the year
7 RUN CODE >>
'1987' or '1989' from the world alcohol consumption dataset.
Write a Pandas program to find out the alcohol consumption details by the
8 RUN CODE >>
'Americas' in the year '1985' from the world alcohol consumption dataset.
Write a Pandas program to find out the alcohol consumption details in the year
9 '1986' where WHO region is 'Western Pacific' and country is 'VietNam' from the RUN CODE >>
world alcohol consumption dataset.
Write a Pandas program to find out the alcohol consumption details in the year
10 '1986' or '1989' where WHO region is 'Americas' from the world alcohol RUN CODE >>
consumption dataset.
Write a Pandas program to find out the alcohol consumption details in the year
11 '1986' or '1989' where WHO region is 'Americas' or 'Europe' from the world alcohol RUN CODE >>
consumption dataset.
Write a Pandas program to find out the 'WHO region, 'Country', 'Beverage Types'
12 in the year '1986' or '1989' where WHO region is 'Americas' or 'Europe' from the RUN CODE >>
world alcohol consumption dataset.
91
Write a Pandas program to find out the records where consumption of beverages
13 per person average >=5 and Beverage Types is Beer from world alcohol RUN CODE >>
consumption dataset.
Write a Pandas program to find out the records where consumption of beverages
14 per person average >=4 and Beverage Types is Beer, Wine, Spirits from world RUN CODE >>
alcohol consumption dataset.
Write a Pandas program to filter the specified columns and records by range from
15 RUN CODE >>
world alcohol consumption dataset.
Write a Pandas program to filter those records where WHO region contains "Ea"
16 RUN CODE >>
substring from world alcohol consumption dataset.
Write a Pandas program to filter those records where WHO region matches with
17 multiple values (Africa, Eastern Mediterranean, Europe) from world alcohol RUN CODE >>
consumption dataset.
Write a Pandas program to filter those records which not appears in a given list
18 RUN CODE >>
from world alcohol consumption dataset.
Write a Pandas program to filter all records where the average consumption of
19 RUN CODE >>
beverages per person from .5 to 2.50 in world alcohol consumption dataset
Write a Pandas program to find average consumption of wine per person greater
20 RUN CODE >>
than 2 in world alcohol consumption dataset.
Write a Pandas program to filter rows based on row numbers ended with 0, like 0,
21 RUN CODE >>
10, 20, 30 from world alcohol consumption dataset.
Write a Pandas program to select consecutive columns and also select rows with
22 RUN CODE >>
Index label 0 to 9 with some columns from world alcohol consumption dataset.
Write a Pandas program to rename all and only some of the column names from
23 RUN CODE >>
world alcohol consumption dataset.
Write a Pandas program to find which years have all non-zero values and which
24 RUN CODE >>
years have any non-zero values from world alcohol consumption dataset.
Write a Pandas program to filter all columns where all entries present, check which
25 rows and columns has a NaN and finally drop rows with any NaNs from world RUN CODE >>
alcohol consumption dataset
Write a Pandas program to filter all records starting from the 'Year' column, access
26 RUN CODE >>
every other column from world alcohol consumption dataset.
Write a Pandas program to filter all records starting from the 2nd row, access
27 RUN CODE >>
every 5th row from world alcohol consumption dataset.
92
Write a Pandas program to split the following dataframe by school code and get
2 RUN CODE >>
mean, min, and max value of age for each school.
Write a Pandas program to split the following given dataframe into groups based
3 RUN CODE >>
on school code and class.
Write a Pandas program to split the following given dataframe into groups based
4 RUN CODE >>
on school code and cast grouping as a list.
Write a Pandas program to split the following given dataframe into groups based
5 RUN CODE >>
on single column and multiple columns. Find the size of the grouped data.
Write a Pandas program to split the following given dataframe into groups based
6 RUN CODE >>
on school code and call a specific group with the name of the group.
Write a Pandas program to split a dataset, group by one column and get mean,
min, and max values by group. Using the following dataset find the mean, min,
7 RUN CODE >>
and max values of purchase amount (purch_amt) group by customer id
(customer_id).
Write a Pandas program to split a dataset to group by two columns and count by
8 RUN CODE >>
each row.
Write a Pandas program to split a dataset to group by two columns and then sort
9 RUN CODE >>
the aggregated results within the groups.
In the following dataset group on 'customer_id', 'salesman_id' and then sort sum of
RUN CODE >>
purch_amt within the groups.
Write a Pandas program to split the following dataframe into groups based on
10 RUN CODE >>
customer id and create a list of order date for each group.
Write a Pandas program to split the following dataframe into groups and calculate
11 RUN CODE >>
monthly purchase amount.
Write a Pandas program to split the following dataframe into groups, group by
12 month and year based on order date and find the total purchase amount year RUN CODE >>
wise, month wise.
Write a Pandas program to split the following dataframe into groups based on first
13 RUN CODE >>
column and set other column values into a list of values.
Write a Pandas program to split the following dataframe into groups based on all
14 RUN CODE >>
columns and calculate Groupby value counts on the dataframe.
Write a Pandas program to split the following dataframe into groups and count
15 RUN CODE >>
unique values of 'value' column.
Write a Pandas program to split a given dataframe into groups and list all the keys
16 RUN CODE >>
from the GroupBy object.
Write a Pandas program to split a given dataframe into groups and create a new
17 RUN CODE >>
column with count from GroupBy.
18 Write a Pandas program to split a given dataframe into groups with bin counts. RUN CODE >>
93
Write a Pandas program to split a given dataframe into groups with multiple
19 RUN CODE >>
aggregations.
Split the following given dataframe by school code, class and get mean, min, and
RUN CODE >>
max value of height and age for each value of the school.
Write a Pandas program to split a given dataframe into groups and display target
20 RUN CODE >>
column as a list of unique values.
Write a Pandas program to split the following dataframe into groups and calculate
21 RUN CODE >>
quarterly purchase amount.
Write a Pandas program to split the following dataframe into groups by school
22 code and get mean, min, and max value of age with customized column name for RUN CODE >>
each school.
Write a Pandas program to split the following datasets into groups on customer id
23 and calculate the number of customers starting with 'C', the list of all products and RUN CODE >>
the difference of maximum purchase amount and minimum purchase amount.
Write a Pandas program to split the following datasets into groups on customer_id
24 RUN CODE >>
to summarize purch_amt and calculate percentage of purch_amt in each group.
Write a Pandas program to split a dataset, group by one column and get mean,
min, and max values by group, also change the column name of the aggregated
25 RUN CODE >>
metric. Using the following dataset find the mean, min, and max values of
purchase amount (purch_amt) group by customer id (customer_id).
Write a Pandas program to split a given dataset, group by two columns and
26 convert other columns of the dataframe into a dictionary with column header as RUN CODE >>
key.
Write a Pandas program to split a given dataset, group by one column and apply
27 an aggregate function to few columns and another aggregate function to the rest RUN CODE >>
of the columns of the dataframe.
Write a Pandas program to split a given dataset, group by one column and remove
28 RUN CODE >>
those groups if all the values of a specific columns are not available.
Write a Pandas program to split a given dataset using group by on specified
29 RUN CODE >>
column into two labels and ranges.
Write a Pandas program to split the following dataset using group by on first
30 RUN CODE >>
column and aggregate over multiple lists on second column.
Write a Pandas program to split the following dataset using group by on
31 RUN CODE >>
'salesman_id' and find the first order date for each group.
Write a Pandas program to split a given dataset using group by on multiple
32 RUN CODE >>
columns and drop last n rows of from each group.
94
Write a Pandas program to identify the column(s) of a given DataFrame which
2 RUN CODE >>
have at least one missing value.
Write a Pandas program to count the number of missing values in each column of
3 RUN CODE >>
a given DataFrame.
Write a Pandas program to find and replace the missing values in a given
4 RUN CODE >>
DataFrame which do not have any valuable information.
Write a Pandas program to drop the rows where at least one element is missing in
5 RUN CODE >>
a given DataFrame.
Write a Pandas program to drop the columns where at least one element is
6 RUN CODE >>
missing in a given DataFrame.
Write a Pandas program to drop the rows where all elements are missing in a
7 RUN CODE >>
given DataFrame.
Write a Pandas program to keep the rows with at least 2 NaN values in a given
8 RUN CODE >>
DataFrame.
Write a Pandas program to drop those rows from a given DataFrame in which
9 RUN CODE >>
specific columns have missing values.
10 Write a Pandas program to keep the valid entries of a given DataFrame. RUN CODE >>
Write a Pandas program to calculate the total number of missing values in a
11 RUN CODE >>
DataFrame.
Write a Pandas program to replace NaNs with a single constant value in specified
12 RUN CODE >>
columns in a DataFrame.
Write a Pandas program to replace NaNs with the value from the previous row or
13 RUN CODE >>
the next row in a given DataFrame.
Write a Pandas program to replace NaNs with median or mean of the specified
14 RUN CODE >>
columns in a given DataFrame.
Write a Pandas program to interpolate the missing values using the Linear
15 RUN CODE >>
Interpolation method in a given DataFrame.
Write a Pandas program to count the number of missing values of a specified
16 RUN CODE >>
column in a given DataFrame.
17 Write a Pandas program to count the missing values in a given DataFrame. RUN CODE >>
Write a Pandas program to find the Indexes of missing values in a given
18 RUN CODE >>
DataFrame.
Write a Pandas program to replace the missing values with the most frequent
19 RUN CODE >>
values present in each column of a given DataFrame.
Write a Pandas program to create a hitmap for more information about the
20 RUN CODE >>
distribution of missing values in a given DataFrame.
95
Pandas Styling
Create a dataframe of ten rows, four columns with random values. Write a Pandas
1 RUN CODE >>
program to highlight the negative numbers red and positive numbers black.
Create a dataframe of ten rows, four columns with random values. Convert some
2 RUN CODE >>
values to nan values. Write a Pandas program which will highlight the nan values.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
3 RUN CODE >>
program to highlight the maximum value in each column.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
4 RUN CODE >>
program to highlight the minimum value in each column.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
5 RUN CODE >>
program to highlight the maximum value in last two columns.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
6 RUN CODE >>
program to set dataframe background Color black and font color yellow.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
7 RUN CODE >>
program to highlight dataframe's specific columns.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
8 RUN CODE >>
program to highlight dataframe's specific columns with different colors.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
9 RUN CODE >>
program to display the dataframe in table style.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
10 program to highlight the entire row in Yellow where a specific column value is RUN CODE >>
greater than 0.5.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
11 RUN CODE >>
program to display the dataframe in Heatmap style.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
12 RUN CODE >>
program to make a gradient color mapping on a specified column.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
13 RUN CODE >>
program to make a gradient color on all the values of the said dataframe.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
14 program to display the dataframe in table style and border around the table and RUN CODE >>
not around the rows.
Create a dataframe of ten rows, four columns with random values. Write a Pandas
15 RUN CODE >>
program to display bar charts in dataframe on specified columns.
Pandas Excel
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a Pandas
1 RUN CODE >>
dataframe.
Write a Pandas program to get the data types of the given excel data
2 RUN CODE >>
(coalpublic2013.xlsx ) fields.
96
3 Write a Pandas program to read specific columns from a given excel file RUN CODE >>
Write a Pandas program to find the sum, mean, max, min value of 'Production
4 RUN CODE >>
(short tons)' column of coalpublic2013.xlsx file.
Write a Pandas program to insert a column in the sixth position of the said excel
5 RUN CODE >>
sheet and fill it with NaN values.
Write a Pandas program to import some excel data (coalpublic2013.xlsx ) skipping
6 RUN CODE >>
first twenty rows into a Pandas dataframe.
7 Write a Pandas program to add summation to a row of the given excel file. RUN CODE >>
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a Pandas
8 RUN CODE >>
dataframe and display the last ten rows.
Write a Pandas program to create a subtotal of "Labor Hours" against MSHA ID
9 RUN CODE >>
from the given excel data (coalpublic2013.xlsx ).
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a
10 RUN CODE >>
dataframe and find a specific MSHA ID.
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a
11 RUN CODE >>
dataframe and find details where "Labor Hours" > 20000.
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a
12 RUN CODE >>
dataframe and find details where "Mine Name" starts with "P".
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a
13 RUN CODE >>
dataframe and find all records that include two specific MSHA ID.
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a Pandas
14 RUN CODE >>
dataframe and find a list of specified customers by name.
Write a Pandas program to import excel data (employee.xlsx ) into a Pandas
15 RUN CODE >>
dataframe and find a list of employees where hire_date> 01-01-07.
Write a Pandas program to import excel data (employee.xlsx ) into a Pandas
16 RUN CODE >>
dataframe and to sort the records by the hire_date column.
Write a Pandas program to import excel data (employee.xlsx ) into a Pandas
17 dataframe and find a list of employees where hire_date between two specific RUN CODE >>
month and year.
Write a Pandas program to import excel data (employee.xlsx ) into a Pandas
18 RUN CODE >>
dataframe and find a list of employees of a specified year.
Write a Pandas program to import excel data (employee.xlsx ) into a Pandas
19 RUN CODE >>
dataframe and convert the data to use the hire_date as the index
Write a Pandas program to import given excel data (employee.xlsx ) into a Pandas
20 RUN CODE >>
dataframe and sort based on multiple given columns.
Write a Pandas program to import sheet2 data from a given excel data
21 RUN CODE >>
(employee.xlsx ) into a Pandas dataframe.
Write a Pandas program to import three datasheets from a given excel data
22 RUN CODE >>
(coalpublic2013.xlsx ) and combine in to a single dataframe.
97
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a
23 dataframe and draw a bar plot where each bar will represent one of the top 10 RUN CODE >>
production.
Write a Pandas program to import excel data (coalpublic2013.xlsx ) into a
24 dataframe and draw a bar plot comparing year, MSHA ID, Production and RUN CODE >>
Labor_hours of first ten records.
Write a Pandas program to import three datasheets from a given excel data
25 RUN CODE >>
(employee.xlsx ) into a single dataframe and export the result into new Excel file.
98
Write a Pandas program to extract the column labels, shape and data types of the
2
dataset (titanic.csv). RUN CODE >>
Write a Pandas program to create a Pivot table with multiple indexes from the data
3 RUN CODE >>
set of titanic.csv.
Write a Pandas program to create a Pivot table and find survival rate by gender on
4 RUN CODE >>
various classes.
5 Write a Pandas program to create a Pivot table and find survival rate by gender. RUN CODE >>
Write a Pandas program to create a Pivot table and find survival rate by gender,
6 RUN CODE >>
age wise of various classes.
Write a Pandas program to partition each of the passengers into four categories
7 RUN CODE >>
based on their age.
Write a Pandas program to create a Pivot table and count survival by gender,
8 RUN CODE >>
categories wise age of various classes.
Write a Pandas program to create a Pivot table and find survival rate by gender,
9 RUN CODE >>
age of the different categories of various classes.
Write a Pandas program to create a Pivot table and find survival rate by gender,
age of the different categories of various classes. Add the fare as a dimension of
10 RUN CODE >>
columns and partition fare column into 2 categories based on the values present in
fare columns.
Write a Pandas program to create a Pivot table and calculate number of women
11 RUN CODE >>
and men were in a particular cabin class.
Write a Pandas program to create a Pivot table and find survival of both gender
12 RUN CODE >>
and class affected.
Write a Pandas program to create a Pivot table and compute survival totals of all
13 RUN CODE >>
classes along each group.
Write a Pandas program to create a Pivot table and calculate how many women
14 RUN CODE >>
and men were in a particular cabin class.
Write a Pandas program to create a Pivot table and find number of survivors and
15 RUN CODE >>
average rate grouped by gender and class.
Write a Pandas program to create a Pivot table and find number of adult male,
16 RUN CODE >>
adult female and children.
Write a Pandas program to create a Pivot table and check missing values of
17 RUN CODE >>
children.
Write a Pandas program to create a Pivot table and separate the gender according
18 RUN CODE >>
to whether they traveled alone or not to get the probability of survival.
Write a Pandas program to create a Pivot table and find the probability of survival
19 RUN CODE >>
by class, gender, solo boarding and port of embarkation.
99
Pandas Datetime
1 Write a Pandas program to create the todays date. RUN CODE >>
Write a Pandas program to calculate all the sighting days of the unidentified flying
2 RUN CODE >>
object (ufo) from current date.
Write a Pandas program to get the current date, oldest date and number of days
3 RUN CODE >>
between Current date and oldest date of Ufo dataset.
Write a Pandas program to get all the sighting days of the unidentified flying object
4 RUN CODE >>
(ufo) which are less than or equal to 40 years (365*40 days).
Write a Pandas program to get all the sighting days of the unidentified flying object
5 RUN CODE >>
(ufo) between 1950-10-10 and 1960-10-10.
Write a Pandas program to get all the sighting years of the unidentified flying
6 RUN CODE >>
object (ufo) and create the year as column.
Write a Pandas program to create a plot to present the number of unidentified
7 RUN CODE >>
flying object (UFO) reports per year.
Write a Pandas program to extract year, month, day, hour, minute, second and
8 RUN CODE >>
weekday from unidentified flying object (UFO) reporting date.
9 Write a Pandas program to convert given datetime to timestamp. RUN CODE >>
Write a Pandas program to count year-country wise frequency of reporting dates
10 RUN CODE >>
of unidentified flying object(UFO).
Write a Pandas program to extract unique reporting dates of unidentified flying
11 RUN CODE >>
object (UFO).
Write a Pandas program to get the difference (in days) between documented date
12 RUN CODE >>
and reporting date of unidentified flying object (UFO).
Write a Pandas program to add 100 days with reporting date of unidentified flying
13 RUN CODE >>
object (UFO).
Write a Pandas program to generate sequences of fixed-frequency dates and time
14 RUN CODE >>
spans.
15 Write a Pandas program to create a conversion between strings and datetime. RUN CODE >>
Write a Pandas program to manipulate and convert date times with timezone
16 RUN CODE >>
information.
Write a Pandas program to get the average mean of the UFO (unidentified flying
17 RUN CODE >>
object) sighting was reported.
Write a Pandas program to create a graphical analysis of UFO (unidentified flying
18 RUN CODE >>
object) Sightings year.
Write a Pandas program to check the empty values of UFO (unidentified flying
19 RUN CODE >>
object) Dataframe.
Write a Pandas program to create a plot of distribution of UFO (unidentified flying
20 RUN CODE >>
object) observation time.
100
Write a Pandas program to create a graphical analysis of UFO (unidentified flying
21 RUN CODE >>
object) sighted by month.
Write a Pandas program to create a comparison of the top 10 years in which the
22 RUN CODE >>
UFO was sighted vs the hours of the day.
Write a Pandas program to create a comparison of the top 10 years in which the
23 RUN CODE >>
UFO was sighted vs each Month.
Write a Pandas program to create a heatmap (rectangular data as a
24 color-encoded matrix) for comparison of the top 10 years in which the UFO was RUN CODE >>
sighted vs each Month.
Write a Pandas program to create a Timewheel of Hour Vs Year comparison of the
25 RUN CODE >>
top 10 years in which the UFO was sighted.
Pandas Plotting
Write a Pandas program to create a line plot of the historical stock prices of
1 RUN CODE >>
Alphabet Inc. between two specific dates.
Write a Pandas program to create a line plot of the opening, closing stock prices of
2 RUN CODE >>
Alphabet Inc. between two specific dates.
Write a Pandas program to create a bar plot of the trading volume of Alphabet Inc.
3 RUN CODE >>
stock between two specific dates.
Write a Pandas program to create a bar plot of opening, closing stock prices of
4 RUN CODE >>
Alphabet Inc. between two specific dates.
Write a Pandas program to create a stacked bar plot of opening, closing stock
5 RUN CODE >>
prices of Alphabet Inc. between two specific dates.
Write a Pandas program to create a horizontal stacked bar plot of opening, closing
6 RUN CODE >>
stock prices of Alphabet Inc. between two specific dates.
Write a Pandas program to create a histograms plot of opening, closing, high, low
7 RUN CODE >>
stock prices of Alphabet Inc. between two specific dates.
Write a Pandas program to create a stacked histograms plot of opening, closing,
8 RUN CODE >>
high, low stock prices of Alphabet Inc. between two specific dates.
Write a Pandas program to draw a horizontal and cumulative histograms plot of
9 RUN CODE >>
opening stock prices of Alphabet Inc. between two specific dates.
Write a Pandas program to create a stacked histograms plot of opening, closing,
10 RUN CODE >>
high, low stock prices of Alphabet Inc. between two specific dates with more bins.
Write a Pandas program to create a stacked histograms plot with more bins of
11 opening, closing, high, low stock prices of Alphabet Inc. between two specific RUN CODE >>
dates.
Write a Pandas program to create a plot of stock price and trading volume of
12 RUN CODE >>
Alphabet Inc. between two specific dates.
101
Write a Pandas program to create a plot of Open, High, Low, Close, Adjusted
13 RUN CODE >>
Closing prices and Volume of Alphabet Inc. between two specific dates.
Write a Pandas program to create a plot of adjusted closing prices, thirty days and
14 RUN CODE >>
forty days simple moving average of Alphabet Inc. between two specific dates.
Write a Pandas program to create a plot of adjusted closing prices, 30 days simple
15 moving average and exponential moving average of Alphabet Inc. between two RUN CODE >>
specific dates.
Write a Pandas program to create a scatter plot of the trading volume/stock prices
16 RUN CODE >>
of Alphabet Inc. stock between two specific dates.
Write a Pandas program to create a plot to visualize daily percentage returns of
17 RUN CODE >>
Alphabet Inc. stock price between two specific dates.
Write a Pandas program to plot the volatility over a period of time of Alphabet Inc.
18 RUN CODE >>
stock price between two specific dates.
Write a Pandas program to create a histogram to visualize daily return distribution
19 RUN CODE >>
of Alphabet Inc. stock price between two specific dates.
102
Write a Pandas program to create a boolean series selecting rows with one or
13 RUN CODE >>
more nulls from locations file.
Write a Pandas program to count the NaN values of all the columns of locations
14 RUN CODE >>
file.
Write a Pandas program to display the first name, last name, salary and
15 RUN CODE >>
department number for those employees whose first name ends with the letter 'm'.
Write a Pandas program to display the first name, last name, salary and
16 department number for those employees whose first name ends with the letter 'd' RUN CODE >>
or 'n' or 's' and also arrange the result in descending order by department id.
Write a Pandas program to display the first name, last name, salary and
17 RUN CODE >>
department number for employees who works either in department 70 or 90.
Write a Pandas program to display the first name, last name, salary and
18 department number for those employees whose managers are hold the ID 120, RUN CODE >>
103 or 145.
Write a Pandas program to display the first, last name, salary and department
19 number for those employees who holds a letter n as a 3rd character in their first RUN CODE >>
name.
Write a Pandas program to display the first name, job id, salary and department for
20 RUN CODE >>
those employees not working in the departments 50,30 and 80.
Write a Pandas program to display the ID for those employees who did two or
21 RUN CODE >>
more jobs in the past.
Write a Pandas program to calculate minimum, maximum and mean salary from
22 RUN CODE >>
employees file.
Write a Pandas program to display the details of jobs in descending sequence on
23 RUN CODE >>
job title.
Write a Pandas program to display the first and last name and date of joining of
24 RUN CODE >>
the employees who is either Sales Representative or Sales Man.
103
Write a Pandas program to get the details of the movie with title 'Grumpier Old
6 RUN CODE >>
Men'.
7 Write a Pandas program to get the details of fifth movie of the DataFrame. RUN CODE >>
Write a Pandas program to create a smaller DataFrame with a subset of all
8 RUN CODE >>
features.
9 Write a Pandas program to display the first 10 rows of the DataFrame. RUN CODE >>
10 Write a Pandas program to sort the DataFrame based on release_date. RUN CODE >>
11 Write a Pandas program to access those movies, released after 1995-01-01. RUN CODE >>
12 Write a Pandas program to sort movies on runtime in descending order. RUN CODE >>
Write a Pandas program to get those movies whose revenue more than 2 million
13 RUN CODE >>
and spent less than 1 million.
14 Write a Pandas program to get the longest runtime and shortest runtime. RUN CODE >>
Write a Pandas program to calculate the number of votes garnered by the 70%
15 RUN CODE >>
movie.
Write a Pandas program to display the movies (title, runtime) longer than 30
16 RUN CODE >>
minutes and shorter than 360 minutes.
Write a Pandas program to display the movies (title, number of votes) that
17 RUN CODE >>
received specified number of votes.
104
Write a Pandas program to remove multiple columns at once of the diamonds
10 RUN CODE >>
Dataframe.
Write a Pandas program to remove multiple rows at once (axis=0 refers to rows)
11 RUN CODE >>
from diamonds dataframe.
Write a Pandas program to sort the 'cut' Series in ascending order (returns a
12 RUN CODE >>
Series) of diamonds Dataframe.
Write a Pandas program to sort the 'price' Series in descending order (returns a
13 RUN CODE >>
Series) of diamonds Dataframe.
Write a Pandas program to sort the entire diamonds DataFrame by the 'carat'
14 RUN CODE >>
Series in ascending and descending order.
Write a Pandas program to filter the DataFrame rows to only show carat weight at
15 RUN CODE >>
least 0.3.
16 Write a Pandas program to convert a python list to pandas series. RUN CODE >>
Write a Pandas program to find the details of the diamonds where length>5,
17 RUN CODE >>
width>5 and depth>5.
18 Write a Pandas program to find the diamonds that are either Premium or Ideal. RUN CODE >>
Write a Pandas program to find the diamonds that are with a Fair or Good or
19 RUN CODE >>
Premium.
20 Write a Pandas program to display all column labels of diamonds DataFrame. RUN CODE >>
Write a Pandas program to read only a subset of 3 rows from diamonds
21 RUN CODE >>
DataFrame.
22 Write a Pandas program to iterate through diamonds DataFrame. RUN CODE >>
Write a Pandas program to drop all non-numeric columns from diamonds
23 RUN CODE >>
DataFrame.
Write a Pandas program to include only numeric columns in the diamonds
24 RUN CODE >>
DataFrame.
Write a Pandas program to pass a list of data types to only describe certain types
25 RUN CODE >>
of diamonds DataFrame.
Write a Pandas program to calculate the mean of each numeric column of
26 RUN CODE >>
diamonds DataFrame.
Write a Pandas program to calculate the mean of each row of diamonds
27 RUN CODE >>
DataFrame.
Write a Pandas program to calculate the mean of price for each cut of diamonds
28 RUN CODE >>
DataFrame.
Write a Pandas program to calculate count, minimum, maximum price for each cut
29 RUN CODE >>
of diamonds DataFrame.
Write a Pandas program to create a side-by-side bar plot of the diamonds
30 RUN CODE >>
DataFrame.
105
Write a Pandas program to count how many times each value in cut series of
31 RUN CODE >>
diamonds DataFrame occurs.
Write a Pandas program to display percentages of each value of cut series occurs
32 RUN CODE >>
in diamonds DataFrame.
Write a Pandas program to display the unique values in cut series of diamonds
33 RUN CODE >>
DataFrame.
Write a Pandas program to count the number of unique values in cut series of
34 RUN CODE >>
diamonds DataFrame.
Write a Pandas program to compute a cross-tabulation of two Series in diamonds
35 RUN CODE >>
DataFrame.
Write a Pandas program to calculate various summary statistics of cut series of
36 RUN CODE >>
diamonds DataFrame.
Write a Pandas program to create a histogram of the 'carat' Series (distribution of
37 RUN CODE >>
a numerical variable) of diamonds DataFrame.
Write a Pandas program to create a bar plot of the 'value_counts' for the 'cut'
38 RUN CODE >>
series of diamonds DataFrame.
Write a Pandas program to create a DataFrame of booleans (True if missing,
39 RUN CODE >>
False if not missing) from diamonds DataFrame.
Write a Pandas program to count the number of missing values in each Series of
40 RUN CODE >>
diamonds DataFrame.
Write a Pandas program to check the number of rows and columns and drop those
41 RUN CODE >>
row if 'any' values are missing in a row of diamonds DataFrame.
Write a Pandas program to drop a row if any or all values in a row are missing of
42 RUN CODE >>
diamonds DataFrame on two specific columns.
Write a Pandas program to set an existing column as the index of diamonds
43 RUN CODE >>
DataFrame.
Write a Pandas program to set an existing column as the index of diamonds
44 RUN CODE >>
DataFrame and restore the index name, and move the index back to a column.
Write a Pandas program to access a specified Series index and the Series values
45 RUN CODE >>
of diamonds DataFrame.
Write a Pandas program to sort a Series by its values and index of diamonds
46 RUN CODE >>
DataFrame.
Write a Pandas program to calculate the multiply of length, width and depth for
47 RUN CODE >>
each cut of diamonds DataFrame.
Write a Pandas program to concatenate the diamonds DataFrame with the 'color'
48 RUN CODE >>
Series.
Write a Pandas program to read specified rows and all columns of diamonds
49 RUN CODE >>
DataFrame.
106
Write a Pandas program to read rows 0, 5, 7 and all columns of diamonds
50 RUN CODE >>
DataFrame.
Write a Pandas program to read rows 2 through 5 and all columns of diamonds
51 RUN CODE >>
DataFrame.
Write a Pandas program to read rows 0 through 2 (inclusive), columns 'color' and
52 RUN CODE >>
'price' of diamonds DataFrame.
Write a Pandas program to read rows 0 through 2 (inclusive), columns 'color'
53 RUN CODE >>
through 'price' (inclusive) of diamonds DataFrame.
Write a Pandas program to read rows in which the 'cut' is 'Premium', column 'color'
54 RUN CODE >>
of diamonds DataFrame.
Write a Pandas program to read rows in positions 0 and 1, columns in positions 0
55 RUN CODE >>
and 3 of diamonds DataFrame.
Write a Pandas program to read rows in positions 0 through 4, columns in
56 RUN CODE >>
positions 1 through 4 of diamonds DataFrame.
Write a Pandas program to read rows in positions 0 through 4 (exclusive) and all
57 RUN CODE >>
columns of diamonds DataFrame.
Write a Pandas program to read rows 2 through 5 (inclusive), columns in positions
58 RUN CODE >>
0 through 2 (exclusive) of diamonds DataFrame.
59 Write a Pandas program to print a concise summary of diamonds DataFrame. RUN CODE >>
60 Write a Pandas program to get the true memory usage by diamonds DataFrame. RUN CODE >>
Write a Pandas program to calculate the memory usage for each Series (in bytes)
61 RUN CODE >>
of diamonds DataFrame.
62 Write a Pandas program to get randomly sample rows from diamonds DataFrame. RUN CODE >>
Write a Pandas program to get sample 75% of the diamonds DataFrame's rows
63 without replacement and store the remaining 25% of the rows in another RUN CODE >>
DataFrame.
Write a Pandas program to read the diamonds DataFrame and detect duplicate
64 RUN CODE >>
color.
65 Write a Pandas program to count the duplicate rows of diamonds DataFrame. RUN CODE >>
NumPy Basic
Write a Numpy program to get the Numpy version and show the Numpy build
1 RUN CODE >>
configuration.
2 Write a NumPy program to get help with the add function. RUN CODE >>
Write a NumPy program to test whether none of the elements of a given array are
3 RUN CODE >>
zero.
Write a NumPy program to test if any of the elements of a given array are
4 RUN CODE >>
non-zero.
107
Write a NumPy program to test a given array element-wise for finiteness (not
5 RUN CODE >>
infinity or not a number).
6 Write a NumPy program to test elements-wise for positive or negative infinity. RUN CODE >>
7 Write a NumPy program to test element-wise for NaN of a given array. RUN CODE >>
Write a NumPy program to test element-wise for complex numbers, real numbers
8 RUN CODE >>
in a given array. Also test if a given number is of a scalar type or not.
Write a NumPy program to test whether two arrays are element-wise equal within
9 RUN CODE >>
a tolerance.
Write a NumPy program to create an element-wise comparison (greater,
10 RUN CODE >>
greater_equal, less and less_equal) of two given arrays.
Write a NumPy program to create an element-wise comparison (equal, equal
11 RUN CODE >>
within a tolerance) of two given arrays
Write a NumPy program to create an array with the values 1, 7, 13, 105 and
12 RUN CODE >>
determine the size of the memory occupied by the array.
13 Write a NumPy program to create an array of 10 zeros, 10 ones, and 10 fives. RUN CODE >>
14 Write a NumPy program to create an array of integers from 30 to 70. RUN CODE >>
15 Write a NumPy program to create an array of all even integers from 30 to 70. RUN CODE >>
16 Write a NumPy program to create a 3x3 identity matrix. RUN CODE >>
17 Write a NumPy program to generate a random number between 0 and 1. RUN CODE >>
Write a NumPy program to generate an array of 15 random numbers from a
18 RUN CODE >>
standard normal distribution.
Write a NumPy program to create a vector with values ranging from 15 to 55 and
19 RUN CODE >>
print all values except the first and last.
20 Write a NumPy program to create a 3X4 array and iterate over it. RUN CODE >>
Write a NumPy program to create a vector of length 10 with values evenly
21 RUN CODE >>
distributed between 5 and 50.
Write a NumPy program to create a vector with values from 0 to 20 and change
22 RUN CODE >>
the sign of the numbers in the range from 9 to 15.
Write a NumPy program to create a vector of length 5 filled with arbitrary integers
23 RUN CODE >>
from 0 to 10
24 Write a NumPy program to multiply the values of two given vectors. RUN CODE >>
25 Write a NumPy program to create a 3x4 matrix filled with values from 10 to 21. RUN CODE >>
26 Write a NumPy program to find the number of rows and columns in a given matrix. RUN CODE >>
Write a NumPy program to create a 3x3 identity matrix, i.e. the diagonal elements
27 RUN CODE >>
are 1, the rest are 0.
Write a NumPy program to create a 10x10 matrix, in which the elements on the
28 RUN CODE >>
borders will be equal to 1, and inside 0.
108
Write a NumPy program to create a 5x5 zero matrix with elements on the main
29 RUN CODE >>
diagonal equal to 1, 2, 3, 4, 5.
Write a NumPy program to create a 4x4 matrix in which 0 and 1 are staggered,
30 RUN CODE >>
with zeros on the main diagonal.
31 Write a NumPy program to create a 3x3x3 array filled with arbitrary values. RUN CODE >>
Write a NumPy program to compute the sum of all elements, the sum of each
32 RUN CODE >>
column and the sum of each row in a given array.
33 Write a NumPy program to compute the inner product of two given vectors. RUN CODE >>
34 Write a NumPy program to add a vector to each row of a given matrix. RUN CODE >>
35 Write a NumPy program to save a given array to a binary file . RUN CODE >>
36 Write a NumPy program to save a given array to a binary file. RUN CODE >>
37 Write a NumPy program to save a given array to a text file and load it. RUN CODE >>
Write a NumPy program to convert a given array into bytes, and load it as an
38 RUN CODE >>
array.
rite a NumPy program to convert a given list into an array, then again convert it
39 RUN CODE >>
into a list. Check initial list and final list are equal or not.
Write a NumPy program to compute the x and y coordinates for points on a sine
40 RUN CODE >>
curve and plot the points using matplotlib.
41 Write a NumPy program to convert numpy dtypes to native Python types RUN CODE >>
Write a NumPy program to add elements to a matrix. If an element in the matrix is
42 RUN CODE >>
0, we will not add the element below this element.
43 Write a NumPy program to find missing data in a given array. RUN CODE >>
Write a NumPy program to check whether two arrays are equal (element wise) or
44 RUN CODE >>
not.
Write a NumPy program to create a one-dimensional array of single, two and
45 RUN CODE >>
three-digit numbers.
46 Write a NumPy program to create a two-dimensional array of a specified format. RUN CODE >>
Write a NumPy program to create a one-dimensional array of forty
47 pseudo-randomly generated values. Select random numbers from a uniform RUN CODE >>
distribution between 0 and 1.
Write a NumPy program to create a two-dimensional array with shape (8,5) of
48 RUN CODE >>
random numbers. Select random numbers from a normal distribution (200,7).
Write a NumPy program to generate a uniform, non-uniform random sample from
49 RUN CODE >>
a given 1-D array with and without replacement.
Write a NumPy program to create a 4x4 array with random values. Create an array
50 RUN CODE >>
from the said array swapping first and last rows
Write a NumPy program to create a new array of given shape (5,6) and type, filled
51 RUN CODE >>
with zeros.
109
Write a NumPy program to sort a given array by row and column in ascending
52 RUN CODE >>
order.
Write a NumPy program to extract all numbers from a given array less and greater
53 RUN CODE >>
than a specified number.
Write a NumPy program to replace all numbers in a given array equal, less and
54 RUN CODE >>
greater than a given number.
Write a NumPy program to create an array of equal shape and data type for a
55 RUN CODE >>
given array.
Write a NumPy program to create a three-dimensional array with the shape (3,5,4)
56 RUN CODE >>
and set it to a variable.
Write a NumPy program to create a 4x4 array. Create an array from said array by
57 RUN CODE >>
swapping first and last, second and third columns.
Write a NumPy program to swap rows and columns of a given array in reverse
58 RUN CODE >>
order.
Write a NumPy program to multiply two given arrays of the same size
59 RUN CODE >>
element-by-element.
110
Write a NumPy program to find the number of elements in an array. It also finds
16 the length of one array element in bytes and the total bytes consumed by the RUN CODE >>
elements.
Write a NumPy program to test whether each element of a 1-D array is also
17 RUN CODE >>
present in a second array.
18 Write a NumPy program to find common values between two arrays. RUN CODE >>
19 Write a NumPy program to get the unique elements of an array. RUN CODE >>
Write a NumPy program to find the set difference between two arrays. The set
20 RUN CODE >>
difference will return sorted, distinct values in array1 that are not in array2.
Write a NumPy program to find the set exclusive-or of two arrays. Set exclusive-or
21 RUN CODE >>
will return sorted, distinct values in only one (not both) of the input arrays.
Write a NumPy program to find the union of two arrays. Union will return a unique,
22 RUN CODE >>
sorted array of values in each of the two input arrays.
23 Write a NumPy program to test whether all elements in an array evaluate to True. RUN CODE >>
Write a NumPy program to test whether any array element along a given axis
24 RUN CODE >>
evaluates to True.
25 Write a NumPy program to construct an array by repeating. RUN CODE >>
26 Write a NumPy program to repeat array elements. RUN CODE >>
Write a NumPy program to find the indices of the maximum and minimum values
27 RUN CODE >>
along the given axis of an array.
28 Write a NumPy program to compare two arrays using NumPy. RUN CODE >>
29 Write a NumPy program to compare two arrays using NumPy. RUN CODE >>
Write a NumPy program to sort pairs of a first name and a last name and return
30 RUN CODE >>
their indices
Write a NumPy program to get the values and indices of the elements that are
31 RUN CODE >>
bigger than 10 in a given array.
32 Write a NumPy program to save a NumPy array to a text file. RUN CODE >>
33 Write a NumPy program to find the memory size of a NumPy array. RUN CODE >>
34 Write a NumPy program to create an array of ones and zeros. RUN CODE >>
35 Write a NumPy program to change an array's dimension. RUN CODE >>
36 Write a NumPy program to create a contiguous flattened array. RUN CODE >>
Write a NumPy program to create a 2-dimensional array of size 2 x 3 (composed
37 RUN CODE >>
of 4-byte integer elements), also print the shape, type and data type of the array.
Write a NumPy program to create another shape from an array without changing
38 RUN CODE >>
its data.
39 Write a NumPy program to change an array's data type. RUN CODE >>
40 Write a NumPy program to create a new array of 3*5, filled with 2. RUN CODE >>
111
Write a NumPy program to create an array of 10's with the same shape and type
41 RUN CODE >>
as the given array.
Write a NumPy program to create a 3-D array with ones on a diagonal and zeros
42 RUN CODE >>
elsewhere.
Write a NumPy program to create a 2-D array whose diagonal equals [4, 5, 6, 8]
43 RUN CODE >>
and 0's elsewhere.
Write a NumPy program to create a 1-D array with values from 0 to 50 and an
44 RUN CODE >>
array from 10 to 50.
Write a NumPy program to create a 1-D array of 30 evenly spaced elements
45 RUN CODE >>
between 2.5 and 6.5, inclusive
Write a NumPy program to create a 1-D array of 20 elements spaced evenly on a
46 RUN CODE >>
log scale between 2. and 5., exclusive.
47 Write a NumPy program to create an array like the one below. RUN CODE >>
48 Write a NumPy program to create an array like the one below. RUN CODE >>
49 Write a NumPy program to collapse a 3-D array into a one-dimensional array. RUN CODE >>
50 Write a NumPy program to find the 4th element of a specified array. RUN CODE >>
51 Write a NumPy program to change two array axes. RUN CODE >>
Write a NumPy program to move array axes to alternate positions. Other axes
52 RUN CODE >>
remain in their original order.
Write a NumPy program to move the specified axis backwards, until it lies in a
53 RUN CODE >>
given position.
Write a NumPy program to convert specified inputs into arrays with at least one
54 RUN CODE >>
dimension.
Write a NumPy program to view inputs as arrays with at least two dimensions,
55 RUN CODE >>
three dimensions.
56 Write a NumPy program to insert a new axis within a 2-D array. RUN CODE >>
Write a NumPy program to remove single-dimensional entries from a specified
57 RUN CODE >>
shape.
58 Write a NumPy program to concatenate two 2-dimensional arrays. RUN CODE >>
59 Write a NumPy program to convert 1-D arrays as columns into a 2-D array. RUN CODE >>
Write a NumPy program to convert (in sequence depth wise (along the third axis))
60 RUN CODE >>
two 1-D arrays into a 2-D array.
.Write a NumPy program to split an array of 14 elements into 3 arrays, each with
61 RUN CODE >>
2, 4, and 8 elements in the original order.
Write a NumPy program that splits an array of shape 4x4 into two arrays along the
62 RUN CODE >>
second axis.
63 Write a NumPy program to get the number of non-zero elements in an array. RUN CODE >>
112
Write a NumPy program to create a 5x5 matrix with row values ranging from 0 to
64 RUN CODE >>
4.
65 Write a NumPy program to test whether specified values are present in an array. RUN CODE >>
Write a NumPy program to create a vector of size 10 with values ranging from 0 to
66 RUN CODE >>
1, both excluded.
67 Write a NumPy program to make an array immutable (read-only). RUN CODE >>
Write a NumPy program (using numpy) to sum all the multiples of 3 or 5 below
68 RUN CODE >>
100.
69 Write a NumPy program to create an array with 10^3 elements. RUN CODE >>
70 Write a NumPy program to create and display every element of a NumPy array. RUN CODE >>
Write a NumPy program to create and display every element of a NumPy array in
71 RUN CODE >>
Fortran order.
72 Write a NumPy program to create a 5x5x5 cube of 1's. RUN CODE >>
Write a NumPy program to create an array of (3, 4) shapes, multiply every element
73 RUN CODE >>
value by 3 and display the result array.
Write a NumPy program to combine a one and two dimensional array together and
74 RUN CODE >>
display their elements.
Write a NumPy program to create an array of zeros and three column types
75 RUN CODE >>
(integer, floating, and character).
76 Write a NumPy program to create a function cube for all array elements. RUN CODE >>
Write a NumPy program to create an array of (3, 4) shapes and convert the array
77 RUN CODE >>
elements into smaller chunks.
78 Write a NumPy program to create a record array from a (flat) list of arrays. RUN CODE >>
79 Write a NumPy program to generate a generic 2D Gaussian-like array. RUN CODE >>
80 Write a NumPy program to convert a NumPy array into a Python list structure. RUN CODE >>
81 Write a NumPy program to access an array by column. RUN CODE >>
Write a NumPy program to convert a NumPy array of floating values to a numpy
82 RUN CODE >>
array of integer values.
83 Write a NumPy program to display a NumPy array of floating values with precision. RUN CODE >>
Write a NumPy program to suppress the use of scientific notation for small
84 RUN CODE >>
numbers in a NumPy array.
85 Write a NumPy program to create a NumPy array of 10 integers from a generator. RUN CODE >>
86 Write a NumPy program to add an extra column to a NumPy array. RUN CODE >>
87 Write a NumPy program to find distinct rows in a NumPy array. RUN CODE >>
Write a NumPy program to replace all elements of NumPy array that are greater
88 RUN CODE >>
than the specified array.
89 Write a NumPy program to remove specific elements from a NumPy array. RUN CODE >>
113
90 Write a NumPy program to replace the negative values in a NumPy array with 0. RUN CODE >>
Write a NumPy program to remove all rows in a NumPy array that contain
91 RUN CODE >>
non-numeric values.
Write a NumPy program to select indices satisfying multiple conditions in a NumPy
92 RUN CODE >>
array.
93 Write a NumPy program to get the magnitude of a vector in NumPy. RUN CODE >>
Write a NumPy program to count the frequency of distinct values in a NumPy
94 RUN CODE >>
array.
95 Write a NumPy program to check whether the NumPy array is empty or not. RUN CODE >>
96 Write a NumPy program to divide each row by a vector element. RUN CODE >>
97 Write a NumPy program to print all array values. RUN CODE >>
Write a NumPy program to convert raw array data to a binary string and create an
98 RUN CODE >>
array.
Write a NumPy program to sum and compute the product of a numpy array of
99 RUN CODE >>
elements.
Write a NumPy program to take values from a source array and put them at
100 RUN CODE >>
specified indices of another array.
101 Write a NumPy program to print the full NumPy array, without truncation. RUN CODE >>
102 Write a NumPy program to convert a NumPy array into a CSV file. RUN CODE >>
103 Write a NumPy program to calculate the Euclidean distance. RUN CODE >>
Write a NumPy program to access the last two columns of a multidimensional
104 RUN CODE >>
column.
105 Write a NumPy program to read a CSV data file and store records in an array. RUN CODE >>
Write a NumPy program to count the occurrences of a specified item in a given
106 RUN CODE >>
NumPy array.
Write a NumPy program to calculate percentiles for a sequence or
107 RUN CODE >>
single-dimensional NumPy array.
108 Write a NumPy program to convert a PIL image into a NumPy array. RUN CODE >>
109 Write a NumPy program to convert a NumPy array to an image. Display an image. RUN CODE >>
110 Write a NumPy program to remove nan values from a given array. RUN CODE >>
Write a NumPy program to create a Cartesian product of two arrays into a single
111 RUN CODE >>
array of 2D points.
112 Write a NumPy program to get NumPy array memory usage. RUN CODE >>
Write a NumPy program to build an array of all combinations of three NumPy
113 RUN CODE >>
arrays.
114 Write a NumPy program to create a random set of rows from a 2D array. RUN CODE >>
Write a NumPy program to find the indices of elements equal to zero in a NumPy
115 RUN CODE >>
array.
114
116 Write a NumPy program to compute the histogram of a set of data. RUN CODE >>
117 Write a NumPy program to compute the line graph of a set of data. RUN CODE >>
Write a NumPy program to find the position of the index of a specified value
118 RUN CODE >>
ranked higher than an existing value in a NumPy array.
119 Write a NumPy program to add another row to an empty NumPy array. RUN CODE >>
Write a NumPy program to get the index of a maximum element in a NumPy array
120 RUN CODE >>
along one axis.
121 Write a NumPy program to join a sequence of arrays along an axis. RUN CODE >>
Write a NumPy program to find the index of the sliced elements from a given 4x4
122 RUN CODE >>
array.
Write a NumPy program to create two arrays bigger and smaller than a given
123 RUN CODE >>
array.
Write a NumPy program to broadcast on different shapes of arrays where p(3,3) +
124 RUN CODE >>
q(3).
Write a NumPy program to broadcast on different shapes of arrays where a(,3) +
125 RUN CODE >>
b(3).
126 Write a NumPy program to rearrange array dimensions. RUN CODE >>
127 Write a NumPy program to stack arrays horizontally (column wise). RUN CODE >>
128 Write a NumPy program to stack arrays vertically. RUN CODE >>
129 Write a NumPy program to stack 1-D arrays columns wise. RUN CODE >>
130 Write a NumPy program to stack 1-D arrays row wise. RUN CODE >>
Write a NumPy program to split a given array into multiple sub-arrays vertically
131 RUN CODE >>
(row-wise).
Write a NumPy program to split an array into multiple sub-arrays along the 3rd
132 RUN CODE >>
axis.
Write a NumPy program to count the number of dimensions, number of elements
133 RUN CODE >>
and number of bytes for each element in a given array.
Write a NumPy program to extract all the elements of the first row from a given
134 RUN CODE >>
(4x4) array.
Write a NumPy program to extract all the elements of the second row from a given
135 RUN CODE >>
(4x4)
Write a NumPy program to extract all the third column elements from a given (4x4)
136 RUN CODE >>
array.
Write a NumPy program to extract the first and second elements of the first and
137 RUN CODE >>
second rows from a given (4x4) array.
Write a NumPy program to extract the third and fourth elements of the first and
138 RUN CODE >>
second rows from a given (4x4) array.
115
Write a NumPy program to extract the first and third elements of the first and third
139 RUN CODE >>
rows from a given (4x4) array.
Write a NumPy program to extract the second and fourth elements of the second
140 RUN CODE >>
and fourth rows from a given (4x4) array.
Write a NumPy program to extract all the elements of the second and third
141 RUN CODE >>
columns from a given (4x4) array.
Write a NumPy program to extract all the elements of the first and fourth columns
142 RUN CODE >>
from a given (4x4) array.
Write a NumPy program to extract the first element of the second row and the
143 RUN CODE >>
fourth element of the fourth row from a given (4x4) array.
Write a NumPy program to extract the second and third elements of the second
144 RUN CODE >>
and third rows from a given (4x4) array.
Write a NumPy program to extract the first, third and fifth elements of the third and
145 RUN CODE >>
fifth rows from a given (6x6) array.
146 Write a NumPy program to add two arrays A and B of sizes (3,3) and (,3). RUN CODE >>
Write a NumPy program to create an array that represents the rank of each item in
147 RUN CODE >>
a given array.
148 Write a NumPy program to copy data from a given array to another array. RUN CODE >>
Write a NumPy program to find elements within a range from a given array of
149 RUN CODE >>
numbers.
150 Write a NumPy program to swap columns in a given array. RUN CODE >>
Write a NumPy program to get the row numbers in a given array where at least
151 RUN CODE >>
one item is larger than a specified value.
152 Write a NumPy program to calculate the sum of all columns in a 2D NumPy array. RUN CODE >>
153 Write a NumPy program to extract the upper triangular part of a NumPy matrix. RUN CODE >>
Write a NumPy program to get a copy of a matrix with the elements below the k-th
154 RUN CODE >>
diagonal zeroed.
155 Write a NumPy program to check whether a Numpy array contains a specified row. RUN CODE >>
156 Write a NumPy program to calculate averages without NaNs along a given array. RUN CODE >>
Write a NumPy program to create an array which is the average of every
157 RUN CODE >>
consecutive triplet of elements in a given array.
Write a NumPy program to calculate the average values of two given NumPy
158 RUN CODE >>
arrays.
Write a NumPy program to rearrange columns of a given NumPy 2D array using
159 RUN CODE >>
given index positions.
160 Write a NumPy program to find the k smallest values in an array. RUN CODE >>
161 Write a NumPy program to create a white image of size 512x256. RUN CODE >>
116
Create an array (a) of shape 3, 4, 8 (K=3, J=4, I=8). tidx is an array of the same
162 length as a.shape[1], i.e. contains J = 4 elements where each index denotes which RUN CODE >>
element of K should be chosen.
Create two arrays of six elements. Write a NumPy program to count the number of
163 RUN CODE >>
instances of a value occurring in one array on the condition of another array.
Write a NumPy program to save as text a matrix that has two floats in each row
164 RUN CODE >>
and one string at the end.
165 Write a NumPy program to merge three NumPy arrays of the same shape. RUN CODE >>
Write a NumPy program to combine the last element with the first element of two
166 RUN CODE >>
given ndarray with different shapes
167 Write a NumPy program to convert a Python dictionary to a NumPy ndarray. RUN CODE >>
Write a NumPy program to convert Pandas dataframe to a NumPy array with
168 RUN CODE >>
headers
169 Write a NumPy program to get all 2D diagonals of a 3D NumPy array. RUN CODE >>
Create a 2-dimensional array of size 2 x 3, composed of 4-byte integer elements.
170 Write a NumPy program to find the number of occurrences of a sequence in an RUN CODE >>
array.
Write a NumPy program to search for the index of a given array in a different
171 RUN CODE >>
array.
Write a NumPy program to find and store non-zero unique rows in an array after
172 RUN CODE >>
comparing each row with other rows in a given matrix.
Write a NumPy program to set zero to lower triangles along the last two axes of a
173 RUN CODE >>
three-dimensional of a given array.
Write a NumPy program to get the number of items, array dimensions, number of
174 RUN CODE >>
array dimensions and the memory size of each element of a given array.
Write a NumPy program to create a 1-D array of 20 elements. Now creates an
175 array of shapes (5, 4) from the said array, then restore the reshaped array into a RUN CODE >>
1-D array.
Write a NumPy program to create an array of shapes 4,5 and swap column1 with
176 RUN CODE >>
column4.
Write a NumPy program to create an array of 4,5 shaped arrays and reverse the
177 rows of that array. After reversing 1st row will be 4th row and 4th row will be 1st RUN CODE >>
row, 2nd row will be 3rd row and 3rd row will be 2nd row.
Write a NumPy program to replace all the nan (missing values) of a given array
178 RUN CODE >>
with the mean of another array.
Write a NumPy program to fetch all items from a given array of shape 4,5 which
179 RUN CODE >>
are greater than 6 and a multiple of 3.
Write a NumPy program to check whether the dimensions of two given arrays are
180 RUN CODE >>
the same or not.
117
Write a NumPy program to place a specified element at a specified time randomly
181 RUN CODE >>
in a specified 2D array.
182 Write a NumPy program to subtract the mean of each row from a given matrix. RUN CODE >>
183 Write a NumPy program to test whether a 2D array has null columns or not. RUN CODE >>
Write a NumPy program to create an array using a generator function that
184 RUN CODE >>
generates 15 integers.
Write a NumPy program to create a vector with 2 consecutive 0 between two
185 RUN CODE >>
values of a given vector.
Write a NumPy program to multiply an array of dimensions (2,2,3) by an array with
186 RUN CODE >>
dimensions (2,2).
187 Write a NumPy program to convert a given vector of integers to a binary matrix. RUN CODE >>
Write a NumPy program to extract rows with unequal values (e.g. [1,1,2]) from a
188 RUN CODE >>
10x3 matrix.
Write a NumPy program to find rows of a given array of shape (8,3) that contain
189 RUN CODE >>
elements of each row of another given array of shape (2,2).
190 Write a NumPy program to create a record array from a given regular array. RUN CODE >>
Write a NumPy program to get the block-sum (block size is 5x5) from a given array
191 RUN CODE >>
of shape 25x25.
Write a NumPy program to extract all the contiguous 4x4 blocks from a given
192 RUN CODE >>
random 12x12 matrix.
Write a Numpy program to test whether a numpy array is faster than a Python list
193 RUN CODE >>
or not.
Write a NumPy program to create two arrays with shape (300,400, 5). Fill values
194 with unsigned integers (0 to 255). Insert an axis at the beginning of the expanded RUN CODE >>
array shape. Now combine both arrays into one.
Write a NumPy program to remove the first dimension from a given array of shape
195 RUN CODE >>
(1,3,4).
Write a NumPy program to create a 12x12x4 array with random values and extract
196 RUN CODE >>
any array of shape(6,6,3) from the said array.
Write a NumPy program to create a concatenation of two given arrays of shapes
197 RUN CODE >>
(2, 2) and (2,1).
Write a NumPy program to create a 10x4 array filled with random floating point
198 RUN CODE >>
number values. Set the array values with the specified precision.
Write a NumPy program to create an array using scientific notation for numbers.
199 RUN CODE >>
Set the precision value to 6 and print the array.
200 Write a NumPy program to remove a specific column from a given array. RUN CODE >>
Write a NumPy program to create a 90x30 array filled with random point numbers.
201 RUN CODE >>
Increase the number of items (10 edge elements) shown in the print statement.
118
Write a NumPy program to calculate the arithmetic mean of the corresponding
202 RUN CODE >>
elements of two given arrays of the same size.
Write a NumPy program to create a 11x3 array filled with student information (id,
203 RUN CODE >>
class and name) and shuffle the rows of the array starting from 3rd to 9th.
Write a NumPy program to extract all the rows from a given array where a specific
204 RUN CODE >>
column starts with a given character.
119
NumPy Random
Write a NumPy program to generate five random numbers from the normal
1 RUN CODE >>
distribution.
2 Write a NumPy program to generate six random integers between 10 and 30. RUN CODE >>
3 Write a NumPy program to create a 3x3x3 array with random values. RUN CODE >>
Write a NumPy program to create a 5x5 array with random values and find the
4 RUN CODE >>
minimum and maximum values.
Write a NumPy program to create a random 10x4 array and extract the first five
5 RUN CODE >>
rows of the array and store them into a variable.
6 Write a NumPy program to shuffle numbers between 0 and 10 (inclusive). RUN CODE >>
7 Write a NumPy program to normalize a 3x3 random matrix. RUN CODE >>
8 Write a NumPy program to create a random vector of size 10 and sort it. RUN CODE >>
9 Write a NumPy program to find the nearest value from a given value in an array. RUN CODE >>
10 Write a NumPy program to check if two random arrays are equal or not. RUN CODE >>
Write a NumPy program to create a random vector of size 15 and replace the
11 RUN CODE >>
maximum value by -1.
Write a NumPy program to find point by point distances of a random vector with
12 RUN CODE >>
shape (10,2) representing coordinates.
13 Write a NumPy program to find the most frequent value in an array. RUN CODE >>
Write a NumPy program to convert cartesian coordinates to polar coordinates of a
14 RUN CODE >>
random 10x2 matrix representing cartesian coordinates.
15 Write a NumPy program to find the closest value (to a given scalar) in an array. RUN CODE >>
16 Write a NumPy program to get the n largest values of an array. RUN CODE >>
Write a NumPy program to create a three-dimension array with shape (300,400,5)
17 and set to a variable. Fill the array elements with values using unsigned integer (0 RUN CODE >>
to 255).
120
5 Write a NumPy program to get the indices of the sorted elements of a given array. RUN CODE >>
Write a NumPy program to sort a given complex array using the real part first, then
6 RUN CODE >>
the imaginary part.
Write a NumPy program to partition a given array in a specified position and move
7 all the smaller elements values to the left of the partition, and the remaining values RUN CODE >>
to the right, in arbitrary order (based on random choice).
Write a NumPy program to sort the specified number of elements from beginning
8 RUN CODE >>
of a given array.
9 Write a NumPy program to sort an given array by the nth column. RUN CODE >>
NumPy Mathematics
1 Write a NumPy program to add, subtract, multiply, divide arguments element-wise. RUN CODE >>
Write a NumPy program to compute logarithm of the sum of exponentiations of the
2 RUN CODE >>
inputs, sum of exponentiations of the inputs in base-2.
3 Write a NumPy program to get true division of the element-wise array inputs. RUN CODE >>
Write a NumPy program to get the largest integer smaller or equal to the division
4 RUN CODE >>
of the inputs.
5 Write a NumPy program to get the powers of an array values element-wise. RUN CODE >>
6 Write a NumPy program to get the element-wise remainder of an array of division. RUN CODE >>
7 Write a NumPy program to calculate the absolute value element-wise. RUN CODE >>
8 Write a NumPy program to round array elements to the given number of decimals. RUN CODE >>
9 Write a NumPy program to round elements of the array to the nearest integer. RUN CODE >>
Write a NumPy program to get the floor, ceiling and truncated values of the
10 RUN CODE >>
elements of a numpy array.
Write a NumPy program to multiply a 5x3 matrix by a 3x2 matrix and create a real
11 RUN CODE >>
matrix product.
Write a NumPy program to multiply a matrix by another matrix of complex
12 RUN CODE >>
numbers and create a new matrix of complex numbers.
13 Write a NumPy program to create an inner product of two arrays. RUN CODE >>
Write a NumPy program to generate inner, outer, and cross products of matrices
14 RUN CODE >>
and vectors.
15 Write a NumPy program to generate a matrix product of two arrays. RUN CODE >>
16 Write a NumPy program to find the roots of the following polynomials. RUN CODE >>
17 Write a NumPy program to compute the following polynomial values. RUN CODE >>
Write a NumPy program to add one polynomial to another, subtract one
18 polynomial from another, multiply one polynomial by another and divide one RUN CODE >>
polynomial by another.
121
Write a NumPy program to calculate mean across dimension, in a 2D numpy
19 RUN CODE >>
array.
Write a NumPy program to create a random array with 1000 elements and
20 RUN CODE >>
compute the average, variance, standard deviation of the array elements.
Write a NumPy program to compute the trigonometric sine, cosine and tangent
21 RUN CODE >>
array of angles given in degrees.
Write a NumPy program to calculate inverse sine, inverse cosine, and inverse
22 RUN CODE >>
tangent for all elements in a given array.
Write a NumPy program to convert angles from radians to degrees for all elements
23 RUN CODE >>
in a given array.
Write a NumPy program to convert angles from degrees to radians for all elements
24 RUN CODE >>
in a given array.
Write a NumPy program to calculate hyperbolic sine, hyperbolic cosine, and
25 RUN CODE >>
hyperbolic tangent for all elements in a given array.
Write a NumPy program to calculate round, floor, ceiling, truncated and round (to
26 RUN CODE >>
the given number of decimals) of the input, element-wise of a given array.
Write a NumPy program to calculate cumulative sum of the elements along a
27 given axis, sum over rows for each of the 3 columns and sum over columns for RUN CODE >>
each of the 2 rows of a given 3x3 array.
Write a NumPy program to calculate cumulative product of the elements along a
28 given axis, sum over rows for each of the 3 columns and product over columns for RUN CODE >>
each of the 2 rows of a given 3x3 array.
Write a NumPy program to calculate the difference between neighboring elements,
29 RUN CODE >>
element-wise of a given array.
Write a NumPy program to calculate the difference between neighboring elements,
30 RUN CODE >>
element-wise, and prepend [0, 0] and append[200] to a given array.
31 Write a NumPy program to compute ex, element-wise of a given array. RUN CODE >>
32 Write a NumPy program to calculate exp(x) - 1 for all elements in a given array. RUN CODE >>
33 Write a NumPy program to calculate 2p for all elements in a given array. RUN CODE >>
Write a NumPy program to compute natural, base 10, and base 2 logarithms for all
34 RUN CODE >>
elements in a given array.
Write a NumPy program to compute the natural logarithm of one plus each
35 RUN CODE >>
element of a given array in floating-point accuracy.
Write a NumPy program to check element-wise True/False of a given array where
36 RUN CODE >>
signbit is set.
Write a NumPy program to change the sign of a given array to that of a given
37 RUN CODE >>
array, element-wise.
Write a NumPy program to compute numerical negative values for all elements in
38 RUN CODE >>
a given array.
122
Write a NumPy program to compute the reciprocal for all elements in a given
39 RUN CODE >>
array.
Write a NumPy program to compute xy, element-wise where x, y are two given
40 RUN CODE >>
arrays.
Write a NumPy program to compute an element-wise indication of the sign for all
41 RUN CODE >>
elements in a given array.
NumPy Statistics
Write a Python program to find the maximum and minimum value of a given
1 RUN CODE >>
flattened array.
Write a NumPy program to get the minimum and maximum value of a given array
2 RUN CODE >>
along the second axis.
Write a NumPy program to calculate the difference between the maximum and the
3 RUN CODE >>
minimum values of a given array along the second axis.
Write a NumPy program to compute the 80th percentile for all elements in a given
4 RUN CODE >>
array along the second axis.
5 Write a NumPy program to compute the median of a flattened given array. RUN CODE >>
6 Write a NumPy program to compute the weighted of a given array. RUN CODE >>
Write a NumPy program to compute the mean, standard deviation, and variance of
7 RUN CODE >>
a given array along the second axis.
8 Write a NumPy program to compute the covariance matrix of two given arrays. RUN CODE >>
9 Write a NumPy program to compute cross-correlation of two given arrays. RUN CODE >>
Write a NumPy program to compute pearson product-moment correlation
10 RUN CODE >>
coefficients of two given arrays.
Write a NumPy program to test element-wise of a given array for finiteness (not
11 infinity or not Not a Number), positive or negative infinity, for NaN, for NaT (not a RUN CODE >>
time), for negative infinity, for positive infinity.
Write a Python NumPy program to compute the weighted average along the
12 RUN CODE >>
specified axis of a given flattened array.
Write a Python program to count the number of occurrences of each value in a
13 RUN CODE >>
given array of non-negative integers.
14 Write a NumPy program to compute the histogram of nums against the bins. RUN CODE >>
NumPy DateTime
1 Write a NumPy program to display all the dates for the month of March, 2017. RUN CODE >>
2 Write a NumPy program to get the dates of yesterday, today and tomorrow. RUN CODE >>
3 Write a NumPy program to count the number of days of a specific month. RUN CODE >>
123
Write a NumPy program to create 24 python datetime.datetime objects (single
4 RUN CODE >>
object for every hour), and then put it in a numpy array.
5 Write a NumPy program to find the first Monday in May 2017. RUN CODE >>
6 Write a NumPy program to find the number of weekdays in March 2017. RUN CODE >>
7 Write a NumPy program to convert numpy datetime64 to Timestamp. RUN CODE >>
NumPy String
1 Write a NumPy program to concatenate element-wise two arrays of string. RUN CODE >>
Write a NumPy program to repeat all the elements three times of a given array of
2 RUN CODE >>
string
Write a NumPy program to capitalize the first letter, lowercase, uppercase,
3 RUN CODE >>
swapcase, title-case of all the elements of a given array.
Write a NumPy program to capitalize the first letter, lowercase, uppercase,
4 RUN CODE >>
swapcase, title-case of all the elements of a given array.
Write a NumPy program to insert a space between characters of all the elements
5 RUN CODE >>
of a given array.
Write a NumPy program to encode all the elements of a given array in cp500 and
6 RUN CODE >>
decode it again.
Write a NumPy program to remove the leading and trailing whitespaces of all the
7 RUN CODE >>
elements of a given array.
Write a NumPy program to remove the leading whitespaces of all the elements of
8 RUN CODE >>
a given array.
Write a NumPy program to remove the trailing whitespaces of all the elements of a
9 RUN CODE >>
given array.
10 Write a NumPy program to split the element of a given array with spaces. RUN CODE >>
11 Write a NumPy program to split the element of a given array to multiple lines. RUN CODE >>
Write a NumPy program to make all the elements of a given string to a numeric
12 RUN CODE >>
string of 5 digits with zeros on its left.
Write a NumPy program to replace "PHP" with "Python" in the element of a given
13 RUN CODE >>
array.
Write a NumPy program to test equal, not equal, greater equal, greater and less
14 RUN CODE >>
test of all the elements of two given arrays.
15 Write a NumPy program to count the number of "P" in a given array, element-wise. RUN CODE >>
Write a NumPy program to count the lowest index of "P" in a given array,
16 RUN CODE >>
element-wise.
Write a NumPy program to check whether each element of a given array is
17 RUN CODE >>
composed of digits only, lower case letters only and upper case letters only.
124
Write a NumPy program to check whether each element of a given array starts
18 RUN CODE >>
with "P".
Write a NumPy program to add two zeros to the beginning of each element of a
19 RUN CODE >>
given array of string values.
Write a NumPy program to replace a specific character with another in a given
20 RUN CODE >>
array of string values.
Write a NumPy program to count a given word in each row of a given array of
21 RUN CODE >>
string values.
Write a NumPy program to split a given text into lines and split the single line into
22 RUN CODE >>
array values.
125
Write a NumPy program to create a 5x5 array with random values and replace the
14 RUN CODE >>
minimum value with 0.
Write a NumPy program to create a 5x5 array with random values and calculate
15 RUN CODE >>
the exponential of each element.
__________________________________________✤✤✤✤✤_____________________________________
_
126