r/pythonhelp • • Aug 17 '21

Text file from a chatroom: Creating an output of how many letters the chatters posted per week

2 Upvotes

How do i create a code to acoomplish this? The text file is in this format

--------------- Monday, August 2, 2021 ---------------

[A] [7:00 PM] Aaaaaand its still down

[B 🤙] [7:34 PM] Photo

End state below (for example):

A: 20

B: 0

From 1-7 Aug 2021


r/pythonhelp • • Aug 07 '21

SOLVED Need help with my code

2 Upvotes

I'm getting an error in my code. Here is my code: from math import sqrt def find_r(n,xs,ys): Exy = [] ex2 = [] ey2 = [] for x in xs: x2 = pow(x,2) ex2.append(x2) for y in ys: y2 = pow(y,2) ey2.append(y2) for x,y in zip(xs,ys): m = xy Exy.append(m) s = sum(Exy) r = (n(s)-(sum(xs)*(sum(ys)))/sqrt(n(sum(ex2)-sum(ex2))*sqrt(n(sum(ey2)-sum(ey2))))) print(r)

x_list = [1,2,3,4,5,6,7,8,9,10] y_list = [2,4,6,8,10,12,14,16,18,20] if len(x_list) == len(y_list): find_r(len(x_list),x_list,y_list)

Here's the error: Traceback (most recent call last): File "main.py", line 22, in <module> find_r(len(x_list),x_list,y_list) File "main.py", line 16, in find_r r = (n*(s)-(sum(xs)*(sum(ys)))/sqrt(n(sum(ex2)-sum(ex2))*sqrt(n(sum(ey2)-sum(ey2))))) TypeError: 'int' object is not callable


r/pythonhelp • • Aug 04 '21

HOMEWORK Ok google feature!

2 Upvotes

So i made a voice assistant from this vid:https://www.youtube.com/watch?v=Lp9Ftuq2sVI&list=PL3yuxwfapZnKapXtYKPmKmtAdTffxvP8U&index=6&t=81s

So i wanted to ask, How do i make it so that its not on everytime? i wanna make an ok google kinda feature. That lets me activate the thing whenever i say ok google. Can anyone supply the code and the packages necessary for the following? I'm kinda new to python so sorry if its a dumb q. Thanks in advance to whoever reads this!


r/pythonhelp • • Jul 14 '21

Why is my pygame getting errors

2 Upvotes

This is my program, for now it is meant to show a blank display yet it runs into errors, anyone know whats wrong:


r/pythonhelp • • Jun 24 '21

SOLVED Interative function in Python

2 Upvotes

Hello everyone,

I'm not 100% sure this is actually doable with Python because I'm not really a Python-dev, but here is my issue:

I have a mathematical formula where I have to isolate a specific argument.

I have every other argument and I know What result I should get, but for that, I have to guess an argument until it gets the correct response.

Here is the equation:

And the arguments:

PMT= 413.17

Y= 7235.5

X= 5426.62

I= 36177.49

D= 60

r=?

So the idea would be to guess r and solve it in a loop until I get the PMT = 413.17

Is that possible via Python? if yes how?

Thanks!


r/pythonhelp • • Jun 06 '21

'NoneType' object has no attribute 'find_all' with BeautifulSoup

2 Upvotes

The problem lies on line 15 and I'm not sure where to go from here.

import requests from bs4 import BeautifulSoup import pandas as pd

url = 'https://cryptoslam.io/topps-mlb/sales' requests.get(url) page = requests.get(url)

soup = BeautifulSoup(page.text, 'lxml')

table_data = soup.find('table', {'table table-striped table-bordered table-hover dataTables-example responsive dataTable no-footer dtr-inline collapsed'})

headers = []

for i in table_data.find_all('th'): title = i.text.strip() headers.append(title)

df = pd.DataFrame(columns = headers)

for j in table_data.find_all('tr'): row_data = j.find_all('td')

row = [tr.text.strip() for tr in row_data]

length = len(df) df.loc[length] = row

print(headers)


r/pythonhelp • • May 26 '21

Can't install dionysus

2 Upvotes

Hi everyone,
I try to install dyonisus with the comand

pip install dyonisus

And i get the error

RuntimeError: CMake must be installed to build the following extensions: dionysus

but CMake is already installed


r/pythonhelp • • May 25 '21

Numpy - multiply elements of array by another array

2 Upvotes

Greetings,

I am stuck on trying to do something efficiently using Numpy (instead of for loops which are slower). I have an array of N elements, a = [a0,a1,...aN], where N is determined at run-time. I have another array b = [b0,b1,b2], which always has three elements. What I want is to multiply each element of array a by the array b (using Numpy utils, not loops), i.e. ans = [ a0 * b, a1 * b, ... aN * b ] = [ a0 *[b0,b1,b2], ... , aN * [b0,b1,b2]]. I am trying to find a rather straightforward and efficient way to do this, but I am having trouble, any help would be appreciative.


r/pythonhelp • • May 23 '21

How can I increment a list within a dictionary?

2 Upvotes

the first int (150) is the price and the second int (0) is the number of times it has been chosen. I want the zero to be incremented by 1 every time that trip has been chosen


r/pythonhelp • • May 02 '21

HOMEWORK creating a game help?

2 Upvotes

For my homework I'm tasked with creating a fantasy league,

The functionality required from this project is:
- Allow the user to choose an unlimited number of teams
- Allow the user to choose players for those teams
- Allow the user to choose an unlimited number of games
- Report the team scores after those games have been played

This is my code so far:

import random
def main():
	print("You need to call your functions here from above") 
	# func_name()
if __name__ == '__main__':
	main()
 
team_size = {}
while True:
    team_name = input('enter a team name\n>')
         team_size.setdefault(team_name,0)

I have two questions. Does the code above hit the first three tick marks? Can someone give me a hint on how to report scores?

Any help is appreciated!!!!


r/pythonhelp • • Apr 25 '21

Tool code ArcPy

2 Upvotes

Hello I am coding a tool that is supposed to update a csv file and then diplay its x Y coordinates. I am currently just trying to get the insert row cursor part to work. this is what my code looks like so far and I keep getting the error

(Traceback (most recent call last):

File "C:/GISc450/BD_Proj/TESTADD.py", line 34, in <module>

main()

File "C:/GISc450/BD_Proj/TESTADD.py", line 29, in main

cursor.insertRow(row_vals)

TypeError: sequence size must match size of the row)

Not sure why this is, do you think it is my code or the table istelf?


r/pythonhelp • • Apr 07 '21

Misunderstanding Functions: Keyword Arguments with Default Parameters

2 Upvotes

Hi. Working MIT 6.0001

Chapter 4.1.2 in the John Guttag Text

I'm having trouble understanding how to interpret the boolean here? In the first line of the body:

###########

if reverse:

print('Olga', 'Puchmajerova' )

###############

If reverse evaluates to True?

Or is it saying whatever you defined as the default parameter is a constant, and if the argument taken by the function is equivalent to that value, its true? So basically if you input false, then it evaluates to true? If you input True it's else?

I'm super confused here.


r/pythonhelp • • Mar 23 '21

Can anyone explain what it means by Time complexity of this code? Homework question

2 Upvotes

r/pythonhelp • • Mar 11 '21

PyCon.De & PyData Ticket Prices (2021)

2 Upvotes

Hey guys, since I can't find any information online, does anyone know what the upcoming ticket prices will be for the PyCon and PyData in germany. If those aren't sure yet, can anyone tell me how much the last tickets cost (2019 ) , especially for the different ticket types ( company, private, etc.) ? Any information on that would be highly appreciated 😁


r/pythonhelp • • Feb 16 '21

SOLVED Receiving an error that says "NoneType has no attribute append" on line 27, but it works correctly the first time through

Post image
2 Upvotes

r/pythonhelp • • Jan 21 '21

Help, need to know if science project model is accurate or not pleaes

2 Upvotes

I have a project deadline coming up, and although my model, works, idk how accurate it is

i have these three numbers: Mean Absolute Error: 3.4079000949583915 Mean Squared Error: 16.84073524874502 Root Mean Squared Error: 4.103746489336911 but I'm not sure what they mean, whether its good or bad, or how to fix it

https://colab.research.google.com/drive/1Sr_0zuhNzwLr-j2HuMa43xhFnz1euTHX?usp=sharing

thats the notebook ^

ty for any help in advance


r/pythonhelp • • Jan 15 '21

Why don't I have permission to pip install matplotlib?

2 Upvotes

Complete beginner here. I was installing the package matplotlib and was going just fine until after installing most of the necissary packages it spat out this error:

ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: 'c:\\python38\\Lib\\site-packages\__pycache__\\pylab.cpython-38.pyc'

Consider using the `--user` option or check the permissions.

any wisdom for me out there?


r/pythonhelp • • Dec 10 '20

SOLVED Help with a basic Monty Hall program

2 Upvotes

I need to write a simple code for a Monty hall program for my Python class, however I cannot wrap my head around how the selection algorithm needs to work.

Here is an example of the one of the outputs I need to display:

Which door would you like to pick: 1

There is a goat behind door #2.

Would you like to change you pick? No

The car was behind door #3

You lost.


r/pythonhelp • • Dec 05 '20

Why does python ignore this highlighted print() command immediately following the true if statement?

2 Upvotes

I'm a python noob and I don't understand why the print("you get up out of bed") function doesn't work even though the if statement above it is true.


r/pythonhelp • • Dec 03 '20

Python Syntax Errors

2 Upvotes

Hi!

I was practicing some pretty easy scripts and all it does is see what a number is and print 'big' or 'small'. so can anyone tell me what the problem is?

x = 5

if x = 5 :

print('big')

if x = 1 :

print('small')

print('done!')

Also im using Pyscripter as an IDE


r/pythonhelp • • Dec 02 '20

Trying to print out the different inputs but not giving the correct output

2 Upvotes

def inputSwimmers():

inputSwimmers1 = input("Enter lane 1 swimmer: ")
inputSwimmers2 = input("Enter lane 2 swimmer: ")
inputSwimmers3 = input("Enter lane 3 swimmer: ")
inputSwimmers4 = input("Enter lane 4 swimmer: ")
inputSwimmers5 = input("Enter lane 5 swimmer: ")

inputSwimmers()

inputSwimmers = ['inputSwimmers1', 'inputSwimmers2', 'inputSwimmers3', 'inputSwimmers4', 'inputSwimmers5']

swimmers = ["A", "B", "C", "D", "E"]

print("Lists of swimmers are: " , inputSwimmers)


r/pythonhelp • • Nov 23 '20

[help] Using a model in a web page

2 Upvotes

I've a Python program that menipulates an image, I've tryed to convert the program to be compitible with flask, but it dosen't seems to work. I've desided to do the processing on the webserver and not the client. But how do I all people upload to the webserver, menipulate the image, and send it back?


r/pythonhelp • • Nov 10 '20

openfermion import error

2 Upvotes

I'm trying to run this example in a terminal. When I run it I get the error

ModuleNotFoundError: No module named 'openfermion.chem'

I'm running in a conda environment with python 3.6 and openfermion installed, pip show openfermion shows

Name: openfermion
Version: 0.11.0
Summary: The electronic structure package for quantum computers.
Home-page: http://www.openfermion.org
Author: The OpenFermion Developers
Author-email: [email protected]
License: Apache 2
Location: /home/al/opt/anaconda3/lib/python3.6/site-packages
Requires: requests, scipy, pubchempy, networkx, h5py, numpy
Required-by: openfermionpsi4

r/pythonhelp • • Nov 05 '20

Trying to set up anaconda environment. I've done it before with no issues but now I am encountering this error. Would it be unwise to just delete the problem "info" file and try again?

Post image
2 Upvotes