Python Assignment # 2 | Help in Homework |

Publicado el: 25 agosto 2024
en el canal de: Help In Homework
33
0

24 / 7 Live Support
support@helpinhomework.org
+44-7309655268
+91-9828671065

Python Assignment # 2
1. Write a Python program which iterates the integers from 1 to 50. For multiples of three print "Fizz"
instead of the number and for the multiples of five print "Buzz". For numbers which are multiples of
both three and five print "FizzBuzz".
2. Write a Python program which takes two digits m (row) and n (column) as input and generates a twodimensional array. The element value in the i-th row and j-th column of the array should be i*j.
Note :i = 0,1.., m-1
j = 0,1, n-1.
Test Data : Rows = 3, Columns = 4
Expected Result : [[0, 0, 0, 0], [0, 1, 2, 3], [0, 2, 4, 6]]
3. Write a Python program to convert month name to a number of days. Expected Output: List of
months: January, February, March, April, May, June, July, August, September, October, November,
December
Input the name of Month: February
No. of days: 28/29 days
4. Write a Python function that accepts a string and calculate the number of upper case letters and lower
case letters.
Sample String : 'The quick Brow Fox'
Expected Output :
No. of Upper case characters : 3
No. of Lower case Characters : 12
5. Write a Python function that takes a list and returns a new list with unique elements of the first list.
Sample List : [1,2,3,3,3,3,4,5]
Unique List : [1, 2, 3, 4, 5]
6. Write a Python program to detect the number of local variables declared in a function.
7. Write a Python program that accepts a sequence of lines (blank line to terminate) as input and prints
the lines as output (all characters in lower case).
8. Write a Python program to check the validity of a password (input from users).
Validation :
At least 1 letter between [a-z] and 1 letter between [A-Z].
At least 1 number between [0-9].
At least 1 character from [$#@].
Minimum length 6 characters.
Maximum length 16 characters.
9. Write a Python program to get next day of a given date.
This study source was downloaded by 100000887303144 from CourseHero.com on 06-15-2024 02:53:02 GMT -05:00
https://www.coursehero.com/file/63448...
Expected Output:
Input a year: 2016
Input a month [1-12]: 08
Input a day [1-31]: 23
The next date is [yyyy-mm-dd] 2016-8-24
10. Write a Python program to insert a new item before the second element in an existing array.
11. Write a Python program to convert an array to an ordinary list with the same items.
12. Write a Python program to get the current memory address and the length in elements of the buffer
used to hold an array’s contents and also find the size of the memory buffer in bytes.
13. 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}
14. Write a Python program to create and display all combinations of letters, selecting each letter from a
different key in a dictionary.
Sample data : {'1':['a','b'], '2':['c','d']}
Expected Output:
ac
ad
bc
bd
15. Write a Python program to sort Counter by value.
Sample data : {'Math':81, 'Physics':83, 'Chemistry':87}
Expected data: [('Chemistry', 87), ('Physics', 83), ('Math', 81)]
16. Write a Python program to get a list, sorted in increasing order by the last element in each tuple from a
given list of non-empty tuples.
Sample List : [(2, 5), (1, 2), (4, 4), (2, 3), (2, 1)]
Expected Result : [(2, 1), (1, 2), (2, 3), (4, 4), (2, 5)]
17. Write a Python program to replace the last element in a list with another list.
Sample data : [1, 3, 5, 7, 9, 10], [2, 4, 6, 8]
Expected Output: [1, 3, 5, 7, 9, 2, 4, 6, 8]
This study source was downloaded by 100000887303144 from CourseHero.com on 06-15-2024 02:53:02 GMT -05:00
https://www.coursehero.com/file/63448...
Powered by TCPDF (www.tcpdf.org)


En esta página del sitio puede ver el video en línea Python Assignment # 2 | Help in Homework | de Duración hora minuto segunda en buena calidad , que subió el usuario Help In Homework 25 agosto 2024, comparta el enlace con amigos y conocidos, en youtube este video ya ha sido visto 33 veces y le gustó 0 a los espectadores. Disfruta viendo!