# variable-assignment

## How or when is a variable updated?

How or when is a variable updated? Question: I wrote this code (spoilers for LeetCode problem 13): roman_numbers = [(‘I’, 1), (‘V’, 5), (‘X’, 10), (‘L’, 50), (‘C’, 100), (‘D’, 500), (‘M’, 1000)] class Solution: def get_value(self, number): return dict(roman_numbers)[str(number)] def romanToInt(self, s: str) -> int: result = 0 letter_list = list(letter for letter in …

## Python – possible problem returning a value in a function which can rerun itself

Python – possible problem returning a value in a function which can rerun itself Question: # Python code to check input for "" and diving by zero error def getNumber(): x = input("Enter a number to divide 100 by: ") # string!! if x == "": # must check for this first as cant convert …

## Dictionary Assignment Not Functioning As Intended

Dictionary Assignment Not Functioning As Intended Question: CONTEXT I’m creating a calculator. I’m at the point where I want my calculator to do BODMAS (start calculations with the inner most bracket). The user enters an expression, in this example it is: expression = (1+(1+1)) I have a function that splits up this function into ‘terms’ …

## Local variable 'gamebot' referenced before assignment

Local variable 'gamebot' referenced before assignment Question: This is my question here:) My question is straight forward, the first program is the correct program but second program isnt, why ? gamebot = "OFF" def gamebot_status(): if gamebot == "OFF": gamebotTest = gamebot print("Gamebot is right now ", gamebotTest, "nTurning On gamebot in… n1 n2 n3 …

## Problem with writing an objective oriented python assignment

Problem with writing an objective oriented python assignment Question: Can someone help me while writing an assignment? It is necessary to create a template for creating objects of the Student type. Each Student should have the following properties: It is necessary to create a template for creating objects of type Student. Every student should have …

## Creating ID for every row based on the observations in variable

Creating ID for every row based on the observations in variable Question: A want to create a system where the observations in a variable refer to a number using Python. All the numbers from the (in this case) 5 different variables together form a unique code. The first number corresponds to the first variable. When …

## Python ValueError: could not convert string to float: '1,000000E+06'

Python ValueError: could not convert string to float: '1,000000E+06' Question: I have a list of around 70 string values, all of them with the E+(05 or 06), which they should be converted to float (as whenever i try to print the values, it somehow ignores the 100000 or 1000000). raw_data = ‘EISTest16_10CV_01.txt’ # name of …

## Consecutive letter removal of 3 or MORE consecutive letters

Consecutive letter removal of 3 or MORE consecutive letters Question: The program asks for a string and outputs the string remaining after removing groups of 3 or more meaning it can be 3, 4, 5, 6, and so on, consecutive identical characters. The removal of the groups continues until no more groups are found to …