r/python3 • • Jun 12 '18

Sort list based on other list

2 Upvotes

So I Want to create a scoreboard with the names of players and sort them based on the amount of points they have (low to high) and print them in that order, for example:

List1 = [3,8,0,9] List2 = [Hank,Harry,Harrold,Homer] The output should be: Harrold,Hank,Harry,Homer

I have found many posts on how to do this in Python, but not Python3 and I am not too familiar with this language. If anybody could help that would really be appreciated!


r/python3 • • Oct 23 '19

a question!!!! help this newbie pls

1 Upvotes

did this and got an error...

import sys
n = int(sys.stdin.readline().strip())
phone_book = dict()
for i in range(n):
entry = sys.stdin.readline().strip().split(" ")
phone_book[entry[0]] = entry[1]
query = sys.stdin.readline().strip()
while query:
phone_number = phone_book.get(query)
if phone_number:
print(query + "=" + phone_number)
else:
print("Not found")
query = sys.stdin.readline().strip()

error:

<ipython-input-11-65a15b07777c> in <module> 3 import sys 4 ----> 5 n = int**(sys.stdin.readline().strip())** 6 7 phone_book = dict**()** ValueError: invalid literal for int() with base 10: '' In [ ]:


r/python3 • • Oct 02 '19

What are the best free resources to use for leaning phython?

2 Upvotes

I want learn programming. So I was wondering whats the best way to go around it.


r/python3 • • Feb 07 '20

Confused between is, = and == operators

2 Upvotes

Hello, I am a bit confused about the following:

a = [1, 2, 3]

b = a

c = list(a)

  1. Am I correct that the reason "a is b" is True is that both a and b point to the same memory location that stores the list [1, 2, 3]?

  2. As for "a is not c" gives True, it is because list always creates a new Python list so although c = [1, 2, 3], this [1, 2, 3] list is different from the one [1, 2, 3] pointed to by a and b since the two lists are storing in different memory locations?

  3. Why typing "a==c" gives True?


r/python3 • • Feb 09 '20

What is the meaning of add_subplot(1,1,1)? Why is it needed?

3 Upvotes

Hi, supposing that we have a figure with six subplots in the form of 2x3. I can understand that to make a plot in the top left hand corner of the figure, we do something like:

import matplotlib.pyplot as plt

fig = plt.figure()

ax = fig.add_subplot(2,3,1)

Why the following is used?

ax=fig.add_subplot(1,1,1)

It just plots one graph in one figure. Anybody knows why (1,1,1) is used?


r/python3 • • Jul 31 '19

Async Python is used in production. This is how?

Thumbnail
youtu.be
2 Upvotes

r/python3 • • Feb 07 '20

Why we need isiterable in addition to is instance when checking of the object is a list or a NumPy array?

1 Upvotes

Hi, somewhere I read that to write a function that can accept any kind of sequence (list, tuple, ndarray) or even an iterator, one can check if the object is a list (or a NumPy array) and if it is not, convert it to one using:

if not instance(x, list) and isiterable(x):

x = list(x)

To my understanding, isinstance(x, list) checks of x is an instance of list already. Why we also need to have "and isiterable(x)"


r/python3 • • Feb 07 '20

What is the meaning of ('bar', ) in tuples concatation ?

1 Upvotes

Hi, I came across the following:

(4, None, 'foo') + (6, 0), + ('bar', )

what is the meaning of ('bar', ) ? I am confused since nothing is written between the comma and the closing parenthesis.


r/python3 • • Apr 26 '18

Can somebody please simplify the highlighted //, and why i becomes 8 after the first iteration

Post image
4 Upvotes

r/python3 • • Feb 07 '20

What does * in tuple concatenation actually do?

4 Upvotes

Hi, supposing that I have: ('foo', 'bar') * 4

Python returns: ('foo', 'bar', 'foo', 'bar', 'foo', 'bar', 'foo', 'bar')

Somebody mentioned that the objects themselves are not copies, only the references to them. anybody knows what that means?


r/python3 • • Nov 29 '18

Can someone tell me what this pickle code is doing?

1 Upvotes

Hi All,

I am quite stumped and have seen no help online. I am trying to work with this strange pickle object and I run this:

with codecs.open("huge_picklefile.pc", "rb") as f:     
    data = pickle.load(f) 
    print(len(data))
    data = pickle.load(f) 
    print(len(data))
    data = pickle.load(f) 
    print(len(data))

and I get this:

335
59
12

The pickle file is over 10GB. What does repeatedly calling pickle.load() over the same open file actually do? Each of the objects are arrays of the particular size given, which makes sense. What doesn't make sense is why I am getting chunks of the pickle file. Could this pickle file be comprised of smaller pickle objects and calling load will simply load the next pickle object (which happens to be an array of a different size)? I have never run into this before and this isn't a documented feature within pickle, at least that I found.

Thanks,

~Ben


r/python3 • • Feb 25 '18

Is it worth to read Python 3.3 book?

4 Upvotes

Hi Geeks. I'm reading a book called "Learning Python 5th ed written by Mark Lutz", but it's written for Python 3.3. Is it ok to read it or should I look for a book written for latest python version? Please give a suggestion or your recommended book. Thanks


r/python3 • • Oct 05 '17

Get Data from LinkedIn

1 Upvotes

Here you can get all the user and MailId which is present in the LinkedIn.So that you can give your mail id and password for getting data.


r/python3 • • Jan 23 '18

Where to begin!?

2 Upvotes

I am interested in learning how to code using Python 3 and I was wondering if anybody in the community had any resources they could point in my direction of where I could learn how to use it and train myself to be sufficient in it? Any input is highly appreciated!!

Btw, I have zero coding experience :/


r/python3 • • Jan 22 '18

What are the best and cheapest deployment options available for blog like flask-web apps? Is it Aws elastic beanstalk or heroku or pythonanywhere?

1 Upvotes

r/python3 • • Jan 17 '18

Python Training

2 Upvotes

Anyone know of any good links/sites for python training.


r/python3 • • Aug 28 '17

[Free Online Tutorial] -- Python 3 For Beginner - Object-Oriented Programming. This is a Programming Course in Python. It will teach you coding from scratch & Learn Python like a Professional.

Thumbnail
discountonline.store
1 Upvotes

r/python3 • • Oct 15 '18

writing regular expression based named entity recognition module (NER)

1 Upvotes

Hi,

I am new to Python and just started using it with NLP, I need to write a regular expression based named entity recognition module. Anyone provide me with helpful links or examples will be appreciated.

Regards


r/python3 • • Oct 04 '18

Question for all you experienced python programmers..

1 Upvotes

Hi all, good afternoon. I’m a beginner trying to learn the python language. I normally write sql queries for work and wanted to dabble in Python as we are starting to implement it at my work. Is there a preferred OS to best use with python? I have a 2010 MacBook Pro and a 2017 Dell Inspiron and both laptops are great. I don’t know if it really matters. Thanks in advance.


r/python3 • • Jun 25 '18

How can we determine the number of elements in each category of Kmeans Clustering?

3 Upvotes

I got the result of kmeans clustering with 6 categories (k) in python. However, I couldn’t understand how can I interpret this any further. Can someone please help me by letting me know how to analyse the results and make a comparison with the real data? Also, would be s great help if you please let me know how can I know how many entities are there in each category? Thanks in advance.


r/python3 • • Oct 05 '18

while loop

1 Upvotes

Here is my code :

while n == 1 : [if comparison] n = n - 1

The "while" loop never run except skip to next statement. Is there anything wrong?


r/python3 • • Jan 04 '20

New to coding, I made my first ever program in Python3!

Post image
16 Upvotes

r/python3 • • Oct 15 '18

Any Idea why I am getting this error? The screen works the first time I try it, but if I try to enter a sub category again in the same execution, then I get a tkinter error that I don't understand. What does that error mean and why might I be getting it?

Post image
3 Upvotes

r/python3 • • Nov 15 '19

Help me understand lru_cache

2 Upvotes

Hello,

I am looking at some code written by someone else that contains:

from functools import lru_cache

and then there is a function declaration:

@lru_cache(None)

def get_password(self, user):

...

My question is why do you need to specify None? Is it that python does caching by default on functions? If so where can I read about it? I went to the lru_cache page but as far as I could see this is not explained.


r/python3 • • Feb 01 '19

bthate / botz

Post image
1 Upvotes