variables

How to set a variable, that isnt iter variable, to increases in each iteration and doesnt always return to its value prior to its entry into for loop?

How to set a variable, that isnt iter variable, to increases in each iteration and doesnt always return to its value prior to its entry into for loop? Question: import re, datetime def add_months(datestr, months): ref_year, ref_month = "", "" ref_year_is_leap_year = False aux_date = str(datetime.datetime.strptime(datestr, "%Y-%m-%d")) print(repr(aux_date)) for i_month in range(int(months)): # I add …

Total answers: 2

Inserting Python Variable in Sparql

Inserting python variable in SPARQL Question: I have a string variable I want to pass in my SPARQL query and I can’t get it to work. title = ‘Good Will Hunting’ [str(s) for s, in graph.query(”’ PREFIX ddis: <http://ddis.ch/atai/> PREFIX wd: <http://www.wikidata.org/entity/> PREFIX wdt: <http://www.wikidata.org/prop/direct/> PREFIX schema: <http://schema.org/> SELECT ?lbl WHERE { ?movie rdfs:label $title@en …

Total answers: 1

Multiple changes to the same variable within different if statements

Multiple changes to the same variable within different if statements Question: SOLVED: I read through my code, it was a ‘bug’. When I copied the dice roll method from the ‘player character’, since it uses the same mechanics for the enemies, I set the damage to 0 if it rolls with one die on accident. …

Total answers: 1

Python subprocess with dynamic variables and arguments

Python subprocess with dynamic variables and arguments Question: I want to ask how can I run subprocess.run() or subprocess.call() in python when the arguments are dynamic. I have already stored all commands in an external batch file, and I want to use Python to run the batch file after I update the arguments. I will …

Total answers: 1

How to permanently save a variable (login information)

How to permanently save a variable (login information) Question: I am trying to code a username and password system and was wondering if there was any way to save the variable so even when the code stops the username will work the next time. I have not yet started coding it and was just wondering …

Total answers: 3

Filling a vector with a varying amount of variables

Filling a vector with a varying amount of variables Question: Hey currently I’m trying to program a quadratic programming algorithm with Python. But I’m struggling with creating a vector which indicates the dimensions of the problem. My problem: I am trying to create a vector x = [x_1, x_2, x_3, …, x_N] which containts N …

Total answers: 2

Python flask how can i insert a variable in LIKE sql

Python flask how can i insert a variable in LIKE sql Question: Im struggeling on this problem with excuting sql in my flask python app. Im trying to excecute a like function with a variable that im recieving from my get reqs. for example i’ve tried this yet : rows = cursor.execute(f"SELECT * FROM vragen …

Total answers: 1

Define a random variable

Define a random variable Question: I’m new with Python. I have to create a new rv U(t). Assuming that Z has a standard normal distribution c = 1.57, I have that: U(t) = 0 if Z(t) <= c U(t) = Φ(Z(t)) Z(t) > c Where Φ(·) is the cdf of the standard normal distribution N(0, …

Total answers: 1

how can i do a variables in python

how can i do a variables in python Question: this is my problem and the photo of it i have no idea why it didn’t work Asked By: Yahye Enaji || Source Answers: Avoid this by selecting ‘Auto Save’ Option in File Menu of VS Code Answered By: Rajesh Kanna I think it’s not just …

Total answers: 2

How a for in loop in python ends when there is no update statement in it?

How a for in loop in python ends when there is no update statement in it? Question: For example: #1 val = 5 for i in range(val) : print(i) When the range is exhausted i.e. last value reached how python knows for in loop ends . As in other languages #2 for(i=0;i<=5;i++){ print(i) } As …

Total answers: 1