Skip to content

mmrezwan/Assignment-on-python-basics

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 

Repository files navigation

Assignment-on-python-basics

  1. Write a Python program to count the number of characters (character frequency) in a string. Sample String : google.com Expected Result : {'o': 3, 'g': 2, '.': 1, 'e': 1, 'l': 1, 'm': 1, 'c': 1}

  2. Write a Python program to check if a given key already exists in a dictionary.

  3. Write a Python program that accepts a sequence of comma-separated numbers from the user and generates a list and a tuple of those numbers. Sample data : 1, 5, 7, 23 Expected Output : List : ['1', ' 5', ' 7', ' 23'] Tuple : ('1', ' 5', ' 7', ' 23')

  4. Write a Python program to calculate the number of days between two dates. Sample dates : (2014, 7, 2), (2014, 7, 11) Expected output : 9 days

  5. Write a Python program to solve (x + y) * (x + y). Test Data : x = 4, y = 3 Expected Output : (4 + 3) ^ 2) = 49

  6. Write a Python program to compute the future value of a specified principal amount, rate of interest, and number of years. Test Data : amt = 10000, int = 3.5, years = 7 Expected Output : 12722.79

  7. Write a Python program that removes duplicate elements from a given array of numbers so that each element appears only once and returns the new length of the array. Sample Input: [0,0,1,1,2,2,3,3,4,4,4] Sample Output: The list of unique numbers: [0,1,2,3,4] length of the unique list : 5

  8. Write a Python program to sort (ascending and descending) a dictionary by key value.

  9. Write a Python program to add key to a dictionary. Go to the editor Sample Dictionary : {0: 10, 1: 20} Expected Result : {0: 10, 1: 20, 2: 30}

  10. Write a Pandas program to create and display a DataFrame from a specified dictionary data which has the index labels. Sample Python dictionary data and list labels: exam_data = {'name': ['Arif', 'Asir', 'Arik', 'Anis', 'Anil', 'Ashish', 'Anahi', 'Alia', 'Alvin', 'Asim'], 'score': [12.5, 9, 16.5, np.nan, 9, 20, 14.5, np.nan, 8, 19], 'attempts': [1, 3, 2, 3, 2, 3, 1, 1, 2, 1], 'qualify': ['yes', 'no', 'yes', 'no', 'no', 'yes', 'yes', 'no', 'no', 'yes']} labels = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j']

About

Assignment on python basics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published