Output :
Twinkle, twinkle, little star,
How I wonder what you are!
Up above the world so high,
Like a diamond in the sky.
Twinkle, twinkle, little star,
How I wonder what you are
3. WAP to print names of your 5 friends each in new line using single print() and independent string for each name.
Click Here For Solution
2. If cost price and selling price of an item is input through keyboard. Write a program to determine how much profit he made or how much loss he got.
5. The marks obtain by a student in 5 different subjects are input through keyboard. The student gets the division as per the following rules:
- Percentage above or equal to 60- first division
- Percentage between 50 and 59- second division
- Percentage between 40 and 49 – third division
- Percentage below 40- fails.
Marks in Mathematics are greater than or equal to 60 and marks in physics is greater than or equal to 50 and marks in chemistry is greater than or equal to 40 OR Total marks in mathematics, physics and chemistry is greater than or equal to 200. OR Total marks in mathematics and physics are greater than or equal to 150. Marks of all three subjects will be entered through the keyboard. WAP to tell whether a student is qualifying for admission or not.
Note: You can withdraw an amount only if balance is greater than or equal to 500 and withdrawing amount should be less than balance.
Click Here For Solution
1
2 3
4 5 6
*
* *
* *
* * * * *
1 2 3 4 5
1 2 3 4
1 2 3
1 2
1
1
2 2
3 3 3
4 4 4 4
Click Here For Solution
Sample String : google.com' Expected Result : {'o': 3, 'g': 2, '.': 1, 'e': 1, 'l': 1, 'm': 1, 'c': 1}
3. Write a Python program to get a string from a given string where all occurrences of its first char have been changed to '$', except the first char itself.
Sample String : 'restart' Expected Result : 'resta$t'
4. Write a Python program to get a single string from two given strings, separated by a space and swap the first two characters of each string.
Sample String : 'abc', 'xyz' Expected Result : 'xycabz'
5. Write a Python program to add 'ing' at the end of a given string (length should be at least 3). If the given string already ends with 'ing' then add 'ly' instead. If the string length of the given string is less than 3, leave it unchanged.
Sample String : 'abc' Expected Result : 'abcing' Sample String : 'string' Expected Result : 'stringly'
6. Write a Python program to find the first appearance of the substring 'not' and 'poor' from a given string, if 'not' follows the 'poor', replace the whole 'not'...'poor' substring with 'good'. Return the resulting string.
Sample String : 'The lyrics is not that poor!' 'The lyrics is poor!'
Expected Result : 'The lyrics is good!' 'The lyrics is poor!'
8. Write a Python program to change a given string to a new string where the first and last chars have been exchanged.
11. Write a Python script that takes input from the user and displays that input back in upper and lower cases.
12. Write a Python program that accepts a comma separated sequence of words as input and prints the unique words in sorted form (alphanumerically).
Sample Words : red, white, black, red, green, black Expected Result : black, green, red, white,red
14. Write a Python function to get a string made of 4 copies of the last two characters of a specified string (length must be at least 2).
Sample function and result : insert_end('Python') ->onononon insert_end('Exercises') ->eseseses
15. Write a Python function to get a string made of its first three characters of a specified string. If the length of the string is less than 3 then return the original string.
Sample function and result : first_three('ipy') ->ipy first_three('python') ->pyt
18. Write a Python function to convert a given string to all uppercase if it contains at least 2 uppercase characters in the first 4 characters.
Sample string: 'thequickbrownfoxjumpsoverthelazydog' Expected output : o 4 e 3 u 2 h 2 r 2 t 2
Sample string: "32.054,23" Expected Output: "32,054.23"
35. Write a Python program to print all permutations with given repetition number of characters of a given string.
37. Write a Python program to find the first repeated character of a given string where the index of first occurrence is smallest.
46.WAP to find number of occurrences of character ‘o’ in the string entered through keyboard. If the character ‘o’ is not present in the string then show a message “o is not present in the entered string”.
50.WAP to delete all vowel from a sentence of the character length 15. The sentence should be entered through keyboard.
Click Here For Solution
3. Write a Python program to count the number of strings where the string length is 2 or more and the first and last character are same from a given list of strings.
Sample List : ['abc', 'xyz', 'aba', '1221']
Expected Result : 2
Sample List : ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
Expected Output : ['Green', 'White', 'Black']
7. Write a Python program to print the numbers of a specified list after removing even numbers from it.
Click Here For Solution
Click Here For Solution
Sample Dictionary : {0: 10, 1: 20}
Expected Result : {0: 10, 1: 20, 2: 30}
3. Write a Python script to concatenate following dictionaries to create a new one.Sample Dictionary :
dic1={1:10, 2:20}
dic2={3:30, 4:40}
dic3={5:50,6:60}
Expected Result : {1: 10, 2: 20, 3: 30, 4: 40, 5: 50, 6: 60}
6. Write a Python script to generate and print a dictionary that contains a number (between 1 and n) in the form (x, x*x).
Sample Dictionary ( n = 5) :
Expected Output : {1: 1, 2: 4, 3: 9, 4: 16, 5: 25}
7. Write a Python script to print a dictionary where the keys are numbers between 1 and 15 (both included) and the values are square of keys.
Sample Dictionary {1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64, 9: 81, 10: 100, 11: 121, 12: 144, 13: 169, 14: 196, 15: 225}
d1 = {'a': 100, 'b': 200, 'c':300}
d2 = {'a': 300, 'b': 200, 'd':400}
Sample output: Counter({'a': 400, 'b': 400, 'd': 400, 'c': 300})
Sample data: {'item1': 45.50, 'item2':35, 'item3': 41.30, 'item4':55, 'item5': 24}
Expected Output:
item4 55
item1 45.5
item3 41.3
Sample dictionary: {'key1': 1, 'key2': 3, 'key3': 2}, {'key1': 1, 'key2': 2}
Expected output: key1: 1 is present in both x and y
Click Here For Solution
5. Write the function to print the Fibonacci series. The number of terms for Fibonacci series will be entered through keyboard.
8. Write a function that takes a number entered through keyboard and find whether it is positive or negative.
9. Write a function that takes a number entered through keyboard and find whether it isArmstrong number or not.
11. Write a function that takes numbers entered through keyboard and return the sum of digits of entered numbers.
12. Write a function that takes two numbers a and b, entered through keyboard and return the value of ab.
Click Here For Solution
If you want to contribute to this project and make it better with new Question and their Solutions, your pull request is most welcomed. If you find any issue just put it in the repository issue section.
or