[Solved] print key and only one value from dictionary

in python 3.x you can use: for k,v in std.items(): print(k,v[‘Uid’]) in python 2.x: for k,v in std.iteritems(): print(k,v[‘Uid’]) python 3.x code: std={} n=int(input(“How many Entries you have to fill:”)) for i in range (n): name=input(“Enter name:”) uid=input(“ID:”) age=input(“Age:”) print(“—-Marks—-“) math=input(“Maths:”) phy=input(“Physics:”) chem=input(“Chemistry:”) std[name]={‘Uid’:uid,’Age’:age,’subject’:{‘math’:math,’phy’:phy,’chem’:chem}} print(‘\n’) for k,v in std.items(): print(k,v[‘Uid’]) input and results for 2 … Read more

[Solved] Shuffling a list in python

Using the mylist[::-1] syntax, as asked, reverses a list. It does NOT shuffle the list. Python Extended Slice Syntax Negative values also work to make a copy of the same list in reverse order: >>> L[::-1] [9, 8, 7, 6, 5, 4, 3, 2, 1, 0] solved Shuffling a list in python

[Solved] Python: Add Button via Tkinter

This has nothing to do with your specific Button Code. Indentation Error occur, when your formatting is wrong. your lines always start with a specified number of blanks or tabs (called Indentation). somewhere this went wrong. To get rid of this, check all your Indents in the beginning of your lines. And very important do … Read more

[Solved] File not opening past NUL byte

There is a problem with windows, that nul-bytes terminates any text-string. So Windows stops printing at the first \0. You can use repr to print escape characters. solved File not opening past NUL byte

[Solved] python calculator [closed]

you can’t give the display as parameter to the pow function, it expects a number. and don’t forget to set the display. powF = frame(self, BOTTOM) button(powF, LEFT, ‘pow’, lambda w=display: w.set(pow(float(w.get()),2))) solved python calculator [closed]

[Solved] Similarity between two text documents in Python

import numpy as np from sklearn.feature_extraction.text import TfidfVectorizer vect = TfidfVectorizer(min_df=1) tfidf = vect.fit_transform([“My name is Ankit”, “Ankit name is very famous”, “Ankit like his name”, “India has a lot of beautiful cities”]) print ((tfidf * tfidf.T).A) 1 solved Similarity between two text documents in Python

[Solved] Python: Are `hash` values for built-in numeric types, strings standardised?

The hash values for strings and integers are absolutely not standardized. They could change with any new implementation of Python, including between 2.6.1 and 2.6.2, or between a Mac and a PC implementation of the same version, etc. More importantly, though, stable hash values doesn’t imply repeatable iteration order. You cannot depend on the ordering … Read more

[Solved] Min valule in dict [closed]

You are getting this – TypeError: ‘int’ object is not iterable Because min expects an iterable. Look at the docs But for i in a.keys() gives you int and you can not iterate over an int object. Pass a list like – min(a) or min(a.values()) # depending on your requirement 1 solved Min valule in … Read more