I am trying to implement a simple BFS code. Code: def initalizeVertex(): n = int(input(‘Enter the no. of vertices.n’)) for vertex in range(n): Vertex.append(vertex) node_adjacency[vertex] =  def initalizeUndirectedEdges(): n = int(input("Enter the no. of edges.n")) print("Enter the space seperated edges.") for i in range(n): a,b = map(int,input().split()) node_adjacency[a].append(b) node_adjacency[b].append(a) def bfs(): current_level = 1 ..
I have this loop: for dt in AllDates: data = importdata(location, dt, Curve, max_maturity = ’30Y’) fwdrate = interpolate(data, ‘1y’, ‘1y’) It takes each date from AllDates, imports the data for that date and then calculates a set of forward rates for said date. The forward rates are then appended in a dictionary. It does ..
I want to create a countdown clock and I almost did but if I run this code down below and press the ‘go’ button, I get the error: NameError: name ‘be’ is not defined. Even if I try to put global be in there it doesn’t seem to work import tkinter as tk def set1(): ..
I am trying to generate all the possible root words that I can from these vowels and consonants in a CVC order. When I try to call the function it says "missing 2 required positional arguments: ‘consonants’ and ‘vowels.’" consonants = ["θ", "t", "d", "k", "f", "s","m", "w", "n", "ŋ", "l", "ʒ", "ʁ", "χ", "ʃ"] ..
The if-in statement should print ‘test’, but it will not. Whenever I try a similar idea outside of a function, it works perfectly, as in the example at the bottom. I can tell the problem is with the if in statement, but I don’t understand why it doesn’t work. Is there anything I can do ..
def main(): num = 5 triple(num) print(num) def triple(num): num = 3 * num main() This came directly from my Python textbook. When ran, it just returns 5. So, maybe it’s not supposed to "triple" the number. But, I would’ve expected it to return 15 based on just looking at the code. So, how would ..
if I run this code down below and press the ‘go’ button, I get the error: NameError: name ‘be’ is not defined. Even if I try to put global be in there it doesn’t seem to work import tkinter as tk def set1(): global be if be1 is not ”: be = int(en.get()) def countdown(): ..
I am new to functions and I am trying to write a function that returns the number of days between two dates: My attempt: import datetime from dateutil.parser import parse def get_x_days_ago (date_from, current_date = None): td = current_date – parse(date_from) if current_date is None: current_date = datetime.datetime.today() else: current_date = datetime.datetime.strptime(date_from, "%Y-%m-%d") return td.days ..
I have been doing some python project and one question occured in my mind. Here is what I had: def fun1(): a = 5 b = 3 *some code* return a, b def fun2(): a, b = fun1() *some code* fun2() I was wondering, how or if it is possible in python to do something ..
My GUI app has two files: gui.py that contains all the Tkinter objects and controller.py contains the logic. The logic is one main function def automation(): that nests several other functions. The app is very simple it’s only one button that calls automation(). I would like to add the print statements and errors that appear ..