Python Task-2 - 26101064
Python Task-2 - 26101064
3) Write a program to calculate factorial of a number by accepting input from the user?
4)Write a program to calculate the sum and average of First n natural numbers by taking n
as input from the user?
5)Write a program which will find all such numbers which are divisible by 7 but are not a
multiple of 5,
between 1 and 200 (both included).
7)Write a program that accepts a sentence and calculate the number of letters and digits.
LETTERS 13
DIGITS 3
8)write a program to print the multiplication table of n,by taking n as input from user
9)Write a program to calculate the area of the traingle by accepting base and height as
integer/float input from the user?
10)Write a program to find the greatest number from three numbers by accepting three
integer inputs from the user?
11)Write a program that prompts the user to enter a number between 1-7 and then displays
the corresponding day of the week.
12)Write a Python program to convert Imperial Units of Inches with the Metric Units of
Centimetres by if-elif-else by accepting float value of units and ask whether inches or cms
from the user and then convert that means two inputs from the user?
13)write a program to determine whether the character entered is a vowel or not by using
logical operator?
14)Write a program that accepts a sentence and calculate the number of upper case letters
and lower case letters.
Suppose the following input is supplied to the program:
Hello Codegnan!
Then, the output should be:
UPPER CASE 2
LOWER CASE 11
15)Write a program to evaluate whether the given number is even or odd by accepting input
from the user?
17)Write a Python program to check if the given value exists in dictionary or not using if-else
by accepting value as string from the user?
Your input is
a ={'sno':1,'name':'Codegnan','place':'Vijayawada'}
{'sno': [1, 2, 3, 4], 'names': ['Codegnan', 'Saketh', 'Python'], 'Gender': {'Female', 'Male'},
'place': ['Vijayawada', 'Mnglgiri']}
19)With a given number n, write a program to generate a dictionary that contains (i, i*i) such
that is an integral number between 1 and n (both included)and then the program should print
the dictionary.
Suppose the following input is supplied to the program:
8
Then, the output should be:
{1: 1, 2: 4, 3: 9, 4: 16, 5: 25, 6: 36, 7: 49, 8: 64}
20)Write a program that accepts a comma separated sequence of words as input and prints
the words in a comma-separated
sequence after sorting them alphabetically.
iris,air,saketh,bat,cat,mat
Output should be as:
air,bat,cat,iris,mat,saketh
21)Write a program, which will find all such numbers between 1000 and 3000 (both included)
such that each digit of the number is an even number.
The numbers obtained should be printed in a comma-separated sequence on a single line.
22) Write a Python program to print Prime Numbers within given range such as accepting
two inputs from user and print in that range?
23)Write a Python Program to display which letters are present in both the strings by
accepting two strings from user?
24)Write a Python Program to find the factors of a number by accepting input from the user?
25)Write a Python program to count the even numbers in the list by accepting list as input
from the user?
26)Write a Python program which iterates the numbers from 1 to 50 (including 50).For
multiples of 3 print "Codegnan" instead of number in output,and for the multiples of five print
"Python". For numbers which are multiples of both three and five print "I love Codegnan".
27)Write a Python program to convert month name to a number of days by accepting month
name from the user?
29)Write a Python Program to accept two numbers from user and find the sum and
product of two numbers,your code should be in two lines only?
30)write a program that displays all leap years from 1900-2101 along with the count of leap
years in given range by satisfying all the conditions for a Leap year?
1
22
333
4444
55555
666666
7777777
88888888
999999999
34)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 length of the given
string is less than 3, leave it unchanged.
35)Write a Python program that takes multiple words as input from user (store in list) and
return the longest word and the length of the longest one?
36)Write a Python program to remove the list values in the given dictionary?
your dictionary is :
a = {'Monday': [10, 20, 30], 'Tuesday': [20, 30, 40], 'Wednesday': [12,15,16,28],'Thursday':
[52,12,36,6],
'Friday':[15,16,28,9,25],'Saturday':[15,25,35,45]}
Output is: {'Monday': [], 'Tuesday': [], 'Wednesday': [], 'Thursday': [], 'Friday': [], 'Saturday': []}
37)Define a function that can receive two integral numbers in string form and compute their
sum and then print it in console
41)Define a function that can accept two strings as input and print the string with maximum
length in console. If two strings have the same length, then the function should print all
strings line by line.
42)Define a function which can print a dictionary where the keys are numbers between 1 and
15 (both included) and the values are square of keys.
43)Define a function which can generate a list where the values are square of numbers
between 1 and 15 (both included). Then the function needs to print the first 5 and last 5
elements in the list.
45)Write a Function to generate all sentences where subject is in ["I", "You"] and verb is in
["Play", "Love"] and the sport is in ["Hockey","Cricket"].
47)Write a Function that accepts a string from user and gives the output of vowels in given
string as list along with the length of the list?
49)Write a function for checking the speed of drivers. This function should have one
parameter: speed.
-->Otherwise, for every 5km above the speed limit (70), it should give the driver one
demerit point and print the total number of demerit points. For example, if the speed is 80, it
should print: "Points: 2".
-->If the driver gets more than 10 points, the function should print: "License suspended"
50)Write a function that returns the sum of multiples of 3 and 5 between 0 and given limit.
For example, if limit is 20, it should return the sum of 3, 5, 6, 9, 10, 12, 15, 18, 20
51)Write a Function to count the number of trailing zeros in an Integer?
52)Create a Function Accept a number from user as input and generate Fibonacci series till
given input such as if input is 10 your output should be as below and should be in single line
0112358
53)Create a Function Same above question accept number from user and print Fibonacci
Series according to user desired values such as if he/she gives input as 10 series should
have 10 numbers as below
0 1 1 2 3 5 8 13 21 34
54)Write a Python program to print all the .txt and .py file names from your Desktop location?
Codegnan
We enjoy learning in Codegnan
Bubyee
56)Write a Python program to generate 10 6 digit differnt OTPS with an interval of 5 seconds
for every OTP?
57)Write a Python program to accept 3 inputs as date,month and year from user and convert
it to date format and then give the corresponding month name,day of the week for given
date,along with day number of the year?
58)Write a Python program to calculate the number of days between two given dates,as two
dates should be accepted from the user by converting them to date format?
59)Write a Python program to read a random line from the given text file,you can use any
text file which is already present -->random module
60)Write a Python program by creating a Function to append text to a file and display the
text.Your output should look as below line by line
Zen of Python
Easter Eggs
As in the given case we have above two lines in text file so create a text file with above data
only.