NAME – UID – BRANCH- BTECH CSE SEM – 4 TH –PYTHON LAB
NAME ? UID ? BRANCH- BTECH CSE SEM ? 4TH SUBJECT ? PYTHON LAB
1. 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}
SOL ? CODE IN TEXT FORM
d1 = {'a': 100, 'b': 200, 'c': 300} d2 = {'a': 300, 'b': 200, 'd': 400} for i in d2 :
if i in d1 : d1[ i ] = d1[ i ] +d2[ i ]
else : d1[ i ] = d2[ i ]
print(d1) ? CODE IN COMPILER
OUTPUT
2.Write a Python program to find the highest 3 values of corresponding keys in a dictionary. ALGO ?
? CODE IN TEXT FORM ? from heapq import nlargest my_dict = {'a':500, 'b':5874, 'c': 560,'d':400, 'e':5873, 'f': 20} three_largest = nlargest(3, my_dict, key=my_dict.get) print(three_largest)
? CODE IN COMPILER-
OUTPUT
................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- debugging with gdb
- hi gdb this is python tuxfamily
- name uid branch btech cse sem 4 th python lab
- debugging hung python processes with gdb 19x
- introduction to gdb python epita
- debugging hung python processes with gdb
- working with geodatabases using sql and python esri
- hi gdb this is python zenk security
- gdb tutorial a walkthrough with examples umd
- cs 331 gdb and x86 64 assembly language
Related searches
- 8 th grade algebra1
- f for th substitution speech
- cse project ideas
- th articulation game
- python variable name rule
- th to f phonological process
- python function name style
- python get name of function as string
- python get name of current function
- d for th phonological process
- name 4 natural resources
- 4 05 virtual blood typing transfusion lab simulation lab