Python exercise with solutions (Set 3)

 1.To print all prime numbers in a given interval


Sample input : 
20
Sample Output :
2,3,5,7,11,13,17,19

Code :

Prime numbers in python













Output: 














2. To check whether the given string is palindrome or not .

A palindrome is a word that remains same even after reversing it.
The code should print yes if the given word is palindrome and no if it is not a palindrome.

Sample input :
Madam
Sample Output:
Yes

Code :


palindrome in python









Output :








3.To remove the duplicates in a list

Sample input :
[1,2,6,8,2,1,4,6,1,7,9]

Sample Output :
[1,2,6,8,4,7,9]

Code :


remove duplicates in python










Output :







4. To print all items that are available for the given cost

Sample input :
250
Sample Output :
Apple
Orange
Banana

Code :











Output :









5.To capitalise the first letter of first name and last name of a person

Sample input :
henry bacos

Sample Output :
Henry Bacos

Code :




Output :








Comments

Popular posts from this blog

Finding the percentage in python - HackerRank solution

HackerRank challenges with solutions (Rearrangement, Formula, Word sorting, Numbers, Sentence)

What's your name, Tuple - HackerRank solution in python