Assignment on data types in python

Aassignment on data types in python

 


Hello Everyone.......!

It's time for practice and tests your knowledge this assignment is based on chapter 3 data types in python.

## Data Types in Python ##
1. Write a Python program to sum all the items in a list (of integers)

2. Write a Python program to get the largest number from a list (of integers)

3. 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)]

4. Write a Python function that takes two lists and returns True, if they have at least one common member.

5. Write a Python program to convert a list of characters into a string.

6. Suppose you have the list:
['dog', 'pencil', 'fence', 'dog', 'apple', 'dog', 'dog', 'dog', 'pear', 'pencil', 'pear', 'pear']
Using a dictionary, compute the numbers of times each word occurs.

7. Write a Python program to check whether an element exists within a tuple.

8. 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}

9. Write a Python program to combine two dictionary adding values for
common keys.
d1 = {'a': 100, 'b': 200, 'c':300}
d2 = {'a': 300, 'b': 200, 'd':400}
Sample output: {'a': 400, 'b': 400, 'd': 400, 'c': 300}




Best regards from,

softwarebulls:)

THANK YOU!