Crack Your Dream Job at a Product-Based Company

11. Find the GCD (Greatest Common Divisor) of two numbers

Required Input:

8, 12

Expected Output:

4

Code In Python

import math def find_gcd(): a, b = 8, 12 # Your code here return

Output

Click Run Button to view compiled output

12. Find the LCM (Least Common Multiple) of two numbers

Required Input:

4, 5

Expected Output:

20

Code In Python

import math def find_lcm(): a, b = 4, 5 # Your code here return

Output

Click Run Button to view compiled output

13. Check if a number is prime

Required Input:

7

Expected Output:

True

Code In Python

def is_prime(): n = 7 # Your code here return

Output

Click Run Button to view compiled output

14. Find the length of the longest word in a sentence

Required Input:

Python is amazing

Expected Output:

7

Code In Python

def longest_word_length(s): # Your code here return

Output

Click Run Button to view compiled output

15. Convert a list of strings to uppercase

Required Input:

python java cpp

Expected Output:

PYTHON JAVA CPP

Code In Python

def to_uppercase(lst): # Your code here return

Output

Click Run Button to view compiled output

16. Remove duplicates from a list

Required Input:

1 2 2 3 3 3 4

Expected Output:

[1, 2, 3, 4]

Code In Python

def remove_duplicates(lst): # Your code here return

Output

Click Run Button to view compiled output

17. Sort a list of numbers in ascending order

Required Input:

5 3 8 1 2

Expected Output:

[1, 2, 3, 5, 8]

Code In Python

def sort_list(lst): # Your code here return

Output

Click Run Button to view compiled output

18. Find the common elements in two lists

Required Input:

1 2 3 4, 3 4 5 6

Expected Output:

[3, 4]

Code In Python

def common_elements(lst1, lst2): # Your code here return

Output

Click Run Button to view compiled output

19. Check if two strings are anagrams

Required Input:

listen, silent

Expected Output:

True

Code In Python

def are_anagrams(s1, s2): # Your code here return

Output

Click Run Button to view compiled output

20. Find the intersection of two sets

Required Input:

1 2 3, 3 4 5

Expected Output:

{3}

Code In Python

def find_intersection(set1, set2): # Your code here return

Output

Click Run Button to view compiled output

ad vertical

2 of 3