Description
1. Write a Python program to print the following string in a specific format (see the output).
Sample String : “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”
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
Sample Output :
2014-07-05 14:34:14
3. Write a Python program which accepts the user’s first and last name and print them in reverse order with a space between them.
4. Write a Python program to display the examination schedule.
Sample Input: exam_st_date = (11, 12, 2014)
Sample Output : The examination will start from : 11 / 12 / 2014
5. Write a Python program to calculate number of days between two dates.
Sample dates : (2014, 7, 2), (2014, 7, 11)
Expected output : 9 days
6.Write a Python program to parse a string to Float or Integer.
String, Variable declaration:
1. Write a Python program which accepts the radius of a circle from the user and compute the area. Sample: r = 1.1
Area = 3.8013271108436504
2. Write a Python program which accepts the user’s first and last name and print them in reverse order with a space between them.
Sample:
Input your First Name: Dany
Input your Last Name: Boon
Hello Boon Dany
3. Write a Python program to calculate the length of a string.
Sample String: Bangladesh
Expected Result: 10
4. Write a Python program to count the number of characters (character frequency) in a
string.
Sample String: google.com’
Expected Result: {‘g’: 2, ‘o’: 3, ‘l’: 1, ‘e’: 1, ‘.’: 1, ‘c’: 1, ‘m’: 1}
5. 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: ‘xyc abz’
6. 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’
Condition:
7 Write a python program to get the absolute difference between n and 51. If n is greater than 51 return triple the absolute difference.
Expected Output:
6 21
0
8 Write a python program to check whether a given number is even or odd.
Sample input: 15
Expected Output: 15 is an odd integer
9 Write a python program to find whether a given year is a leap year or not
10 Write a python program to read the age of a candidate and determine whether it is eligible for casting his/her own vote
Sample input: 21
Expected Output: Congratulation! You are eligible for casting your vote.
11 Write a python program to find the largest of three numbers. Sample input: 12 25 52
Expected Output:
1st Number = 12, 2nd Number = 25, 3rd Number = 52
The 3rd Number is the greatest among three
12 Write a python program to check whether a triangle is Equilateral, Isosceles or Scalene Sample input: 50 50 60
Expected Output: This is an isosceles triangle.
13 Write a program in python which is a Menu-Driven Program to perform a simple calculation. Sample input:
10 2 3
Expected Output: The Multiplication of 10 and 2 is: 20
14 Write a python program to check whether an alphabet is a vowel or consonant.
Sample input: k
Expected Output: The alphabet is a consonant.
15 Write a python program to read marks of three subjects and calculate the total, percentage and division.
Sample input:
Input the marks of Physics, Chemistry and Computer Application: 70 80 90 Expected Output:
Roll No: 784
Name of Student: James
Marks in Physics: 70
Marks in Chemistry: 80
Marks in Computer Application: 90
Total Marks = 240
Percentage = 80.00
Division = First
Source: w3resource
Reviews
There are no reviews yet.