Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
25 views

Python QB-1

This document contains 30 programming problems related to Python. The problems cover a range of topics including arrays, strings, lists, patterns, functions, dictionaries, sorting, and more. Some examples of problems include finding the longest consecutive elements sequence in an unsorted array, calculating the maximum difference between successive elements in a sorted array, checking if a string contains letters and numbers, and determining if two strings are anagrams.

Uploaded by

dasm04675
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
25 views

Python QB-1

This document contains 30 programming problems related to Python. The problems cover a range of topics including arrays, strings, lists, patterns, functions, dictionaries, sorting, and more. Some examples of problems include finding the longest consecutive elements sequence in an unsorted array, calculating the maximum difference between successive elements in a sorted array, checking if a string contains letters and numbers, and determining if two strings are anagrams.

Uploaded by

dasm04675
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

1. Given an unsorted array of integers nums, return the length of the longest consecutive elements sequence.

Input: nums = [100,4,200,1,3,2]


Output: 4
2. Given an integer array nums, return the maximum difference between two successive elements in its sorted form. If the array
contains less than two elements, return 0.
Input: nums = [3,6,9,1]
Output: 3
3. Print the following pattern.
*
***
*****
*******
4. Print the following pattern.
1
23
456
7 8 9 10
11 12 13 14 15

5. Print the following pattern.


A
BC
DEF
GHIJ
KLMNO

6. Write a function to find the longest common prefix string amongst an array of strings. If there is no common prefix, return an
empty string. Example 1:
Input: strs = ["flower","flow","flight"]
Output: "fl"
7. Python code to get the Cumulative sum of a list
8. Python code to count the number of occurrences of an item in a list.
9. Write a Python program to check a list is empty or not.
10. Python program to check if a string has at least one letter and one number.

11. Python program to capitalize the first and last character of each word in a string

12. Python program to implement call by reference.

13. Write a Python program to add two given lists using map and lambda.

14. Write a Python program that multiply each number of given list with a given number using lambda function. Print the result.

15. Print the following pattern.

16. Check that a number is palindrome or not.

17. Print the following pattern:


*

**

***

****

*****

18. Write a Python program to input a 5 × 5 matrix and print the 2nd row, and 3rd element in 4th row.

19. Two strings are anagrams if you can make one from the other by rearranging the letters.Write a function named is_anagram
that takes two strings as its parameters. Your function should return True if the strings are anagrams, and False otherwise.

20. Program to accept the strings which contain all vowels.

21. Frequency of all numbers in String.

22. Python program to implement variable function argument and thereby find out area of a rectangle.

23. Write a Python program to find numbers divisible by nineteen or thirteen from a list of numbers using Lambda.

24. Python program to find the sum of all items in a dictionary.

25. Python code to display the words in a phrase that have the greatest and lowest ASCII values of characters.

26. Transform a String into a matrix with K characters each row.

27. Given the participants' score sheet for your University Sports Day, you are required to find the runner-up score. You are given
n scores. Store them in a list and find the score of the runner-up.

i/p: n=6

236654

o/p= 5

28. Input the string (Honorificabilit) and check for the minimum frequent vowel and maximum frequent

consonant.

29. Find out the 3rd highest element from an input list.

30. write a function that accepts a number as a parameter. The function should return a number that’s the difference between the
largest and smallest numbers that the digits can form in the number.

For example, if the parameter is “213”, the function should return “198”, which is the result of 123 subtracted from 321.

You might also like