Search the Community
Showing results for tags 'python3'.
-
If I run this code the lines and numbers that should be appearing are not appearing, can somebody help me? import pgzrun from random import randint from time import time WIDTH=600 HEIGHT=338 num_of_pc=8 computers=[] lines=[] next_computer=0 s_time=0 t_time=0 e_time=0 def create_computers(): global s_time for count in range(0,num_of_pc): pc=Actor("download") pc.pos=randint(40,WIDTH-40), randint(40,HEIGHT-40) computers.append(pc) s_time=time() def draw(): screen.blit("maps",(0,0)) number=1 for pc in computers: screen.draw.text(str(number),(pc.pos[0]+8,pc.pos[1]+13)) pc.draw() number=number+1 for line in lines: screen.draw.line(line[0],line[1],(255,0,0)) if next_computer<num_of_pc: t_time=time()-s_time screen.draw.text(str(round(t_time,1)),(10,10),fontsize=30) else: screen.draw.text(str(round(t_time,1)),(10,10),fontsize=30) create_computers() def on_mouse_down(pos): global next_computer,lines if next_computer<num_of_pc: if computers[next_computer].collidepoint(pos): if next_computer: lines.append((computers[next_computer-1].pos,computers[next_computer].pos)) next_computer+=1 else: lines=[] next_computer=0 pgzrun.go()
-
Hello! Firstly, the audience for this topic is for archivists and data hoarders. Not so much about the programming that went on here which leads me into the goal of this post. I’d like to spread awareness about this tool regarding comments made by Linus during the most recent WAN show about the Internet Archive’s legal woes. I read into it a little, and I didn’t like what I saw. Also, I love the archive but it’s not easily accessible to most people when you’re looking at hundreds (in this case hundreds of thousands!) of files. I wrote this tool to address this problem, making collection of the torrent files in Great 78 quite a bit more straightforward. I want to be clear that this does not download the content of files hosted by the archive, it merely collects and downloads the torrent files. It is not a torrent client. It is simply to make sharing this collection significantly easier for myself, and hopefully others. More information, about both the tool and the suit, is available in the readme file in the repo: http://github.com/ech0riginal/phonograpy I’m not a lawyer, but I wanted to do something. I’m just a programmer by trade so I whipped up a script this afternoon. I don’t plan on maintaining it in any way. Comments and questions are most welcome but if you’d like a feature I encourage you to fork the repository. Hope y’all are well, cheers!
-
I am learning Python, but my only keyboard compatible device is my Chromebook. I have been using an online IDE to code, but I find the UI laid out odd. I know I could download the official Python IDE on my iPad, but my iPad doesn't support my USB keyboard and I can't afford a Bluetooth Keyboard/Keyboard Case.
- 3 replies
-
- chromeos
- chromebooks
-
(and 3 more)
Tagged with:
-
-
This is for my brothers birthday and here is my code so far name = input("enter Name ") input("Is " + name + " correct? ") month = input("enter month that you were born in ") input("Is " + month + " correct? ") day = input("enter day that you were born in ") input("Is " + day + " correct? ") year = input("enter year that you were born in ") input("Is " + year + " correct?") age = 2023 - year print("seems like It is" + name + age + "BIRTHDAY!!!!!!!!!!!" )
-
So I have started taking Python 3 courses and it's my first programming language. I am trying to make a funny magic 8-ball program, but something isn't adding up and I keep getting an "invalid keyword argument" error while executing. I am certain it's probably something silly and simple, but it's still evading me. Also, this is my first day learning. I appreciate any help and tips!
- 6 replies
-
- python3
- programming
-
(and 2 more)
Tagged with:
-
Hi there, I am building a system for storage which will most likely have a raspberry pi as the host. How would I make it so I could easily search in all “boxes” and then see if they have the item that I am looking for. I would be using Python 3 #CODE EXAMPLE THINGY# Box1 [car,dog,sheep] Box2 [rock,cat,sheep] Input for search “sheep” Then searches all boxes I have made to see if it that has sheep in them If it has them then it goes: OUTPUT: Sheep in box 1 and 2 Else goes item unavailable. Input for search “car” Searches all boxes I have made to see if it has car in them* If it has them then it goes: OUTPUT: Car in box 1 This is an example and colours, led and items in box would be different. I don’t mind just needing to use the terminal in order to find an item that is required. If you have any questions feel free to ask and I will try and get back to you ASAP. I am not asking for someone to code the entire thing I am just asking if anyone knows any systems that have been made like this and if there is any ideas on what systems I should use. If you want to reach me privately my discord is Spoiled_Kitten#4911 Thanks, Blake McCullough
-
Current input is lst = [['13', '4', '17'], ['30', '6', '5'], ['12', '37', '10']] I would like to sort it like this lst = [['4', '13', '17'], ['5', '6', '30'], ['10', '12', '37']] Any ideas wait i think i got it for sublist in lst: sublist.sort() print(lst)
-
Hi this an old python pygame tutorial for tetris from tech with tims, I want to a function to this code where I can create a ghost piece so the user knows where there piece is going to drop. Im trying to create a ghost_piece and I know I have to set it to the current piece. The problem with this is beacuse the ghost_piece needs to be at the bottom it is immediatly locked and I cant seem to understand how he locked the piece in the first place, so I dont really know how to unlock it. Tetris - Full Code.py
-
Hi there, I need a method to control the running of my Python Script. I already have a method to trigger the script, but have had no luck making my own control script, especially one that terminates it gracefully (I've not been able to reliably get PID, etc) I have a script to keep the script alive also (forever.py) I am happy to use bash, python or something else. I am also happy if I need to add a visudo Idea: $> control.ext restart [Script gracefully kills forever.py] [Script starts forever.py] $> control.ext stop [Script gracefully kills forever.py] I've tried the internet, but had no such luck. I don't expect anybody to write a full program! If you can point me in the right direction (eg: mainly How to terminate the script) that would help greatly, and i'll work the rest out Thank you!
-
Hello. I need to trigger an event if an function's input string is equal to a variable. So far I have event_fire = "FIRE" event_tamper = "TAMP" event_intruder = "INTRUDER" event_fault = "FAULT" ... elif input.find(event_fault) != -1: decipher_act(event_fault,1) elif input.find(event_intruder) != -1: decipher_act(event_intruder,1) elif input.find(event_tamper) != -1: decipher_act(event_tamper,1) ... Which works: But I feel there has to be a better way than if statements, as there is 15+ of these in my code. Any ideas? Thanks!
-
Not to take a piss on python , i actually like the languagee , especially the development speed you get with it. but... only in python are things that are an order of magnitude faster in other languages actually much much slower: Branching logic vs Branchless Logic: import random from time import perf_counter_ns,sleep testnrs = [random.randrange(0,5,1) for _ in range(2**20)] def branch(nr,idx,result): if nr < 1 : result|=int((str(abs(result))*9)[1:3]) elif nr == 1: result|=idx elif nr == 2: result|= 2*int(str(result)[0]) elif nr == 3 : result|=3*idx elif nr >= 4 : result|= nr*int(str(idx)[-1]) return result def nobranch(nr,idx,result): result|= (((int((str(abs(result))*9)[1:3])) * (nr < 1)) + ( (idx)*(nr==1)) + ( (2*int(str(result)[0])*(nr==2))) +( ((3*idx)*(nr==3)))+ ( (nr*int(str(idx)[-1])*(nr>=4)))) return result subtot1=0 ;start1=perf_counter_ns() for idx,nr in enumerate(testnrs): subtot1=branch(nr,idx,subtot1) time1=(perf_counter_ns()-start1)*10**-9 sleep(2) subtot2=0 ; start2=perf_counter_ns() for idx,nr in enumerate(testnrs): subtot2=nobranch(nr,idx,subtot2) time2=(perf_counter_ns()-start2)*10**-9 print(subtot1,'\t\ttime:\t\t',time1) print(subtot2,'\t\ttime:\t\t',time2) result: 4194303 : time: 3.047605361 4194303 : time: 9.314754315
-
- python3
- develpment
-
(and 2 more)
Tagged with:
-
Hello everyone, I am a Python programmer for quite a while and although Python makes development easier and faster in a lot of ways, there is an area that always seemed that was kept behind even though it was widely used by the Python community, and that thing I’m talking about is Pythons native Object Oriented System. While Java or C# or even C++ has an Object Oriented system that support attribute type enforcement, interfaces and abstract classes, Python can somewhat provide those things, but without any enforcement at all. That always seemed to me a shameful thing, because Python in many ways is a very powerful language, but that also makes it prone to errors. For instance, I’ve had many bugs in Python when I was trying to assign a value to the wrong attribute because I simply misspelled it’s name by one character (e.g. namee instead of name). Another issue that seemed problematic to me is that there are a lot of repetitive tasks we do when creating classes that could be automated as well, from constructors, type enforcement, lazy attributes to the creation of getters/setters (While I’m aware of the @property decorator, I always preferred get/set methods). Granted, Python 3.7 introduced the @dataclass classes, they are very simplistic — No type enforcement, default values assignement is basic at best (You cannot call a method to assign their default values), let alone speak about lazy attributes, or final attributes. For that reason, I’ve decided to create a new Object Oriented System for Python — Kisa. Kisa supposed to bring many improvements over Pythons native Object Oriented System and that includes: Auto generated getters/setters Auto generated constructors Default attributes — Can be initialized from instance method Lazy attributes Attribute type support Abstract classes Interfaces Enforcement of inheritance Static attributes Static methods Attribute modifiers — Add hooks to attribute/method call before the call, around the call or after it was called Allow attributes to be None or not Make attributes final Decide if attributes are required by the constructor or not Many more I believe Kisa can and will make development in Python faster to write, maintain, better organized, and safer. A very basic example of a Kisa class: import kisa class Person(metaclass=kisa.Class): firstname = kisa.Info(type=str, required=True, final=True) lastname = kisa.Info(type="str", required=True, final=True) age = kisa.Info(type=int, required=True) friends = kisa.Info(type=list, default=lambda: []) def fullname(self): return f"{self.firstname()} {self.lastname()}" def birthday(self): # Getter new_age = self.age() + 1 # Setter self.age(new_age) # # raises Exception: "firstname" is Missing in instance creation for class Person # noam = Person() noam = Person(firstname="Noam", lastname="Nisanov", age=22) # raises Exception: Tried to modify a final attribute "firstname" # noam.firstname("Generic") # raises Exception: "age" must be of type: <class 'int'> # noam.age("bla bla") print(f"First name: {noam.firstname()}") # prints "First name: Noam" print(f"Last name: {noam.lastname()}") # prints "Last name: Nisanov" print(f"Full name: {noam.fullname()}") # prints "Full name: Noam Nisanov" print(f"Current age: {noam.age()}") # prints "Current age: 22" print(f"Birthday!") # prints "Birthday!" noam.birthday() print(f"New age: {noam.age()}") # prints "New age: 23" For more information, please take a look at the project GitHub https://github.com/nmnsnv/kisa Thanks Noam Nisanov (noam.nisanov@gmail.com)
- 7 replies
-
- object oriented
- python
-
(and 2 more)
Tagged with:
-
import turtle as trtl import random as rand import time #-----setup----- apple_image = "apple.gif" # Store the file name of your shape letterlist = ["A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z"] wn = trtl.Screen() wn.setup(width=1.0, height=1.0) wn.bgpic("background.gif") wn.addshape(apple_image) wn.tracer(False) # Make the screen aware of the new file apple = trtl.Turtle() apple.penup() apple.hideturtle() letterchoicevar = '' apple_turtles = [] atactiveletters = [] letter_turtles = [] clear = False numberturtles = 0 index = 0 #-----functions----- # given a turtle, set that turtle to be shaped by the image file def havefun(): global numberturtles letterchoice() atactiveletters.append(letterchoicevar) at = trtl.Turtle() at.penup() at.shape(apple_image) at.goto((rand.randint(-200,200), rand.randint(-10,100))) at.stamp() at.hideturtle() lettery = (at.ycor() - 40) letterx = (at.xcor() - 18) at.goto(letterx,lettery) at.color('white') at.write(letterchoicevar, font=("Arial", 55, "bold")) apple_turtles.append(at) print(len(apple_turtles)) numberturtles += 1 wn.update() def letterchoice(): global letterchoicevar letterchoicevar = letterlist[(rand.randint(0,(len(letterlist)-1)))] while numberturtles < 5: havefun() def keyfilter(passthrough): index = 0 if passthrough in atactiveletters: while (atactiveletters[index] != passthrough) and index <4: index += 1 apple_fall(index) else: return def apple_fall(indexpassthrough): if len(apple_turtles) < 5: havefun() global numberturtles active_apple = apple_turtles.pop(indexpassthrough) atactiveletters.pop(indexpassthrough) letterchoice() atactiveletters.append(letterchoicevar) appley = active_apple.ycor() apple_offset = abs(-160 - appley) active_apple.setheading(270) active_apple.forward(apple_offset) active_apple.hideturtle() active_apple.clear() numberturtles = (numberturtles - 1) wn.update() #TODO Create a function that takes a turtle as its parameter and gives that turtle (apple) # a new location on the tree, only if the list of letters is not empty. Associate the # turtle with a new letter selected at random from the list of letters #def apple_pos(): #TODO Create a function that takes a turtle (apple) and its corresponding letter from the letter # list and draws that letter on that turtle (apple) #TODO Create a function that takes a turtle (apple) and its corresponding ltter from the letter # list and set that turtle to be shaped by the image file, call the letter drawing function, # and update the Screen #TODO Iterate over the numbers from 0 to the number of apples, creating that many turtles # calling your function that resets the apples by giving them a new random location # add the new apples to a list of apples to be used in the rest of the program. # The loop below executes the correct number of times by using the range() function # to create a list of numbers to iterate over. #'''for i in range(0, number_of_apples): #TODO Create a function that takes a letter as its parameter, uses that letter to retrieve the # corresponding turtle (apple) and causes both to drop from the tree simultaneously. Once the # apple and letter have dropped, call the apple reseting function. #TODO define a function per letter that you will use in your program. Each function should check # to see if the given letter is in the list of letters; if it is, it should drop the corresponding # apple. #TODO use the onkeypress method of wn to correlate the functions you defined above with each # of the letters that the user might type. # onkeypress requires that you name one function that must take # no arguments to be called when the specified key is pressed. #-----function calls----- while True: wn.onkey(keyfilter("A"),"A") wn.onkey(keyfilter("B"),"B") wn.onkey(keyfilter("C"),"C") wn.onkey(keyfilter("D"),"D") wn.onkey(keyfilter("E"),"E") wn.onkey(keyfilter("F"),"F") wn.onkey(keyfilter("G"),"G") wn.onkey(keyfilter("H"),"H") wn.onkey(keyfilter("I"),"I") wn.onkey(keyfilter("J"),"J") wn.onkey(keyfilter("K"),"K") wn.onkey(keyfilter("L"),"L") wn.onkey(keyfilter("M"),"M") wn.onkey(keyfilter("N"),"N") wn.onkey(keyfilter("O"),"O") wn.onkey(keyfilter("P"),"P") wn.onkey(keyfilter("Q"),"Q") wn.onkey(keyfilter("R"),"R") wn.onkey(keyfilter("S"),"S") wn.onkey(keyfilter("T"),"T") wn.onkey(keyfilter("U"),"U") wn.onkey(keyfilter("V"),"V") wn.onkey(keyfilter("W"),"W") wn.onkey(keyfilter("X"),"X") wn.onkey(keyfilter("Y"),"Y") wn.onkey(keyfilter("Z"),"Z") wn.listen() wn.update() I know the wn.update() isn't ideal, it's there to slow down the code so it doesn't hang on my computer. Basically, the only reference to the "apple_fall" function is the onkey functions at the bottom of my code, and yet the function is being called without me pressing any keys. I have looked the functions up for help, and asked my teacher, but I found no sources due to other modules advertising their keyboard plugin.
-
I don't know why but the condition is not executed n=0 dice=[] for i in range(100): b=random.randint(1,6) dice.append(b) print(dice) for i in dice: if dice == 6: n=n+1 print(n) outpu [1, 2, 1, 1, 3, 6, 4, 1, 1, 6, 1, 5, 4, 4, 6, 6, 3, 4, 3, 3, 3, 6, 3, 6, 5, 6, 2, 2, 5, 3, 5, 4, 2, 2, 6, 5, 4, 4, 2, 4, 4, 4, 6, 1, 6, 5, 1, 3, 5, 1, 1, 3, 5, 2, 5, 2, 4, 1, 5, 1, 2, 1, 2, 6, 2, 2, 6, 6, 1, 2, 5, 5, 5, 1, 1, 1, 3, 4, 5, 5, 5, 2, 6, 5, 6, 5, 2, 3, 1, 1, 4, 6, 5, 5, 1, 4, 2, 6, 2, 2] 0 pls help I'm running code in jupyter notebook
-
My question is, I want to put a 'calculate' text under the 'Go' button just after the user's click on the 'Go' button. Execution of the calculation takes plenty of time, so I want to display the 'calculating' text before the execution ends, and before the results are displayed. I tried: import sys from PySide6 import QtWidgets class Window(QtWidgets.QMainWindow): def __init__(self): QtWidgets.QMainWindow.__init__(self) self.init_window() def init_window(self): self.setWindowTitle("i want a rolls") self.resize(800, 400) self.go_button = QtWidgets.QPushButton("Go") go_layout = QtWidgets.QHBoxLayout() go_layout.addStretch() go_layout.addWidget(self.go_button) go_layout.addStretch() self.calculating = QtWidgets.QLabel() calculating_layout = QtWidgets.QHBoxLayout() calculating_layout.addStretch() calculating_layout.addWidget(self.calculating) calculating_layout.addStretch() calculating_layout.addStretch() panel_layout = QtWidgets.QVBoxLayout() panel_layout.addStretch() panel_layout.addLayout(go_layout) panel_layout.addLayout(calculating_layout) panel_layout.addStretch() central = QtWidgets.QWidget(self) self.setCentralWidget(central) central.setLayout(panel_layout) self.go_button.clicked.connect(self.progress) self.go_button.clicked.connect(self.calculate) self.show() def progress(self): self.calculating.setText('calculating...') def calculate(self): x = 0 while x < 10000: x += 0.0001 print(x) app = QtWidgets.QApplication(sys.argv) window = Window() sys.exit(app.exec()) I wanted to display 'calculating' text just after the user's click on the 'Go' button, and before the calculation ends. Yet it is showed after the calculation ends. If I delete the 'self.search_button.clicked.connect(self.calculate)' line (line number 37), the code works, it shows the 'calculating' message that I wanted to display, but the actual calculate is not executed(naturally). Why it is not working? I do not know what to do from now on, can somebody help me please?
-
Hello, I have some modules in a folder in dropbox which is downloaded in my phone. I want to add that location permanently to the PYTHONPATH so that I can call them whenever I want. But I am unable to do that. Things I tried. import sys import site site.addsitedir('the path') print(sys.path) This was only temporary. 2. In pydroid terminal.. export PYTHONPATH = "$PYTHONPATH: the path" Any help will be much appreciated. P.S: I don't want to move these files to any other folder as because I want to have a direct connection to my PC where Dropbox folder is added to the pythonpath.
-
Hello, When I am trying to create a new file from inside python using "open", the file is created in the location from where the terminal is run (in my case /User). Now I can change the location of this new file in 2 ways, 1. By including the desired path in my script. 2. Changing the path of the terminal (using "cd" command). But every time I have to do this manually. Say I want to create this new file in the location of the existing file i.e the file which is creating the new file. And this existing file changes its location every now and then. Then I have to manually perform either the step 1 or 2 every single time. Now Idle creates this new file in the same location as the existing one. I was wondering if I could do the same using VS Code. Thanks.
-
In the example: You can see that im trying to import, but it will always import to import.py, im trying to make it import to main.py from running the function. How can i do this? # import.py def importer(str_import): import str_import # main.py, this is the file that will be running. import importer importer("os") os.system("blah")
-
Hi, I'm currently run into an issue with my below python code import socket import threading import sys class Server: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) connections = [] def __init__(self): self.sock.bind(('0.0.0.0', 10000)) self.sock.listen(1) def handler(self, c, a): while True: data = c.recv(1024) for connection in self.connections: connection.send(data) if not data: print(str(a[0]) + ':' + str(a[1]), "disconnected") self.connections.remove(c) c.close() break def run(self): while True: c, a = self.sock.accept() cThread = threading.Thread(target=self.handler, args=(c, a)) cThread.daemon = True cThread.start() self.connections.append(c) print(str(a[0]) + ':' + str(a[1]), "connected") class Client: sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM) def sendMsg(self): while True: self.sock.send(bytes(input(""), 'utf-8')) def __init__(self, address): self.sock.connect((address, 10000)) iThread = threading.Thread(target=self.sendMsg) iThread.daemon = True iThread.start() while True: data = self.sock.recv(1024) if not data: break print(str(data, 'utf-8')) if (len(sys.argv) > 1): client = Client(sys.argv[1]) else: server = Server() server.run() Everytime I run the code on the client end I keep getting the following error: File "chat.py", line 29 print(str(a[0]) + ':' + str(a[1]), "connected") The python code is exactly the same on the server and client end, but I don't get any issues on the server end. Any Questions? Thank you
-
Hello reader! I've been trying to import libraries that i installed for python. All I get is "OSError: [WinError 193] %1 is not a valid Win32 application" error. How do i fix it? Im running a 64-bit version of Python 3.6.5. PLEASE HELP! THANK YOU!
-
Hi All, Hoping you can help me, I'm looking to learn python 3. I want to use it for creating fairly complex websites and algorithms, especially to do with finance and math. Is there a YouTube (or otherwise) course that anyone would recommend for taking me from 0 to being 100% ready to code the stuff I wanna code in one go? I would prefer it to be in one go so I don't have to jump around alot and know exactly how long it will take me (maybe I should be doing an interactive course?). Anyway, thanks to everybody who replies! Will
-
what do packages do i need to install to run this repl.it in normal linux. Please list all the packages i need for the script. im using linux what pip packages do i install? please list me a full list of commands below if you can thanks for any help / advice ?
-
Hi, I am pretty new to python (and programming in general), I am trying to create a curve fit to my data, I am loading two arrays 'Tnn_month' and 'amon_month' from .mat files, I want to create a scatter plot of these two parameters and then assign a curve fit to show the correlation between both, I tried to apply the curve_fit examples done on simple plots, but I still get this error: error: Result from function call is not a proper array of floats. Tnn_month (x) and amon_month (y) are both arrays of length 5433656 find attached the scatter plot ----------------------------------------------------- input: import numpy as np import matplotlib.pyplot as plt import scipy.io as io import pandas as pd import seaborn as sns from matplotlib.pyplot import figure MainFolder= r"/home/abeed/Documents/thesis/python/scatter/" yyyymm_str= '201005' d_or_n = 'day' colors = (0,0,0) area = np.pi*3 #load data mat = io.loadmat('Tnn_amon0.01_201005.mat') Tnn_month = mat['Tnn_index'] amon_month = mat['amon_index'] colors=np.array([0.1, 0.5, 0.5]) # scatter plot figure(num=None, figsize=(8, 6), dpi=80, facecolor='w', edgecolor='k') plt.scatter(Tnn_month, amon_month, s=area, c=colors, alpha=0.5) plt.title('May 2010', fontsize=14) plt.ylabel('Ammonia Total Concentration (molec/cm$^{2}$)',fontsize=14) plt.xlabel('Skin Temperature (Kelvin)', fontsize=14) plt.savefig(MainFolder + yyyymm_str + '_test_' + d_or_n +'.png', format='png', dpi=700) #plt.show() # curve_fit import matplotlib.pyplot as plt from scipy.optimize import curve_fit import numpy as np Tnn_month[np.isnan(Tnn_month)]=0 #something for nans amon_month[np.isnan(amon_month)]=0 def func(X, a, b, c): return a * np.exp(-b * X) + c Y = func(Tnn_month, 2.5, 1.3, 0.5) np.random.seed(len(Tnn_month)) print(Tnn_month) popt, pcov = curve_fit(func, Tnn_month, amon_month) plt.plot(Tnn_month, func(Tnn_month, *popt), 'g--',label='fit: a=%5.3f, b=%5.3f, c=%5.3f' % tuple(popt)) plt.show() -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- output: [[272.64697509] [273.43998094] [272.89872854] ... [265.03563904] [264.87200613] [273.74241245]] --------------------------------------------------------------------------- ValueError Traceback (most recent call last) ValueError: object too deep for desired array --------------------------------------------------------------------------- error Traceback (most recent call last) <ipython-input-2-2ed29e6832ed> in <module> 71 print(Tnn_month) 72 ---> 73 popt, pcov = curve_fit(func, Tnn_month, amon_month) 74 75 plt.plot(Tnn_month, func(Tnn_month, *popt), 'g--',label='fit: a=%5.3f, b=%5.3f, c=%5.3f' % tuple(popt)) ~/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py in curve_fit(f, xdata, ydata, p0, sigma, absolute_sigma, check_finite, bounds, method, jac, **kwargs) 750 # Remove full_output from kwargs, otherwise we're passing it in twice. 751 return_full = kwargs.pop('full_output', False) --> 752 res = leastsq(func, p0, Dfun=jac, full_output=1, **kwargs) 753 popt, pcov, infodict, errmsg, ier = res 754 cost = np.sum(infodict['fvec'] ** 2) ~/anaconda3/lib/python3.7/site-packages/scipy/optimize/minpack.py in leastsq(func, x0, args, Dfun, full_output, col_deriv, ftol, xtol, gtol, maxfev, epsfcn, factor, diag) 394 maxfev = 200*(n + 1) 395 retval = _minpack._lmdif(func, x0, args, full_output, ftol, xtol, --> 396 gtol, maxfev, epsfcn, factor, diag) 397 else: 398 if col_deriv: error: Result from function call is not a proper array of floats.