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 :

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 :

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 :

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 :

For more exercises ,
For python tutorials ,
Comments
Post a Comment