# operators

## How do I calculate operations from a txt file?

How do I calculate operations from a txt file? Question: So I have a homework to write those expressions in a notepad, this is my input file: 4+1 12-3 2*182 8/2 then, I have to write a program in idle that will read that, line by line, that will solve the operations and return them …

## What does ^ operator do in Python?

What does ^ operator do in Python? Question: I’ve tried the following: print(1^3) #output 2 print(1^5) #output 4 print(1^6) #output 7 These outputs don’t make any sense for me. Asked By: Victor Rayan || Source Answers: It’s the bitwise XOR operator. Answered By: RedBox

## Using multipe operators in Python sequentially

Using multipe operators in Python sequentially Question: I’m trying to understand how Python handles using multiple sequential operators to add and subtract numbers. Here is an example of what I mean: >>> 5+-2 3 >>> 5-+2 3 >>> 5+-+-+2 7 >>> 5+-+-+-2 3 >>> 5+-+—+2 7 >>> 5-+-+—+2 3 >>> 5-+-+—+-2 7 >>> 5++++-++++–+-+++2 7 …

## Python script that increases a number by a percent and then with a new number till goal

Python script that increases a number by a percent and then with a new number till goal Question: I found this problem and wanted to try to execute, but got stuck: Compile a program that allows you to determine how many days will be enough for 200 something if consumed on the first day 5 …

## Operation_Precedence_in_Python

Operation_Precedence_in_Python Question: Could someone explain to me about operator precedence? For eg. Modulo(%), integer division(//), exponential(**) What comes first, second, third and so on. Also please help me with the output of the following code and with step by step explanation: print(8 % 3 ** 4 // 3 + 2) I coudnt understand about Operator …

## Python NOT equal operator combining with OR operator

Python NOT equal operator combining with OR operator Question: piece of example code: while input("Type STOP to stop this program: ") != (‘STOP’ or "stop"): continue The program doesn’t give the correct output when inputted: stop. Why does STOP work but lower case doesn’t? Asked By: Jelle || Source Answers: You can convert the input …

## Get the season when entering a month and day (python)

Get the season when entering a month and day (python) Question: I am writing a code that allows the user to enter a month and date and the program will tell them what season it will be given the information that the user entered. What I currently have working is that when you enter certain …

## compare two attribute of objects from different list of object python

compare two attribute of objects from different list of object python Question: I’m still pretty new to python and oop and I have some struggles resolving this problem without breaking the performance. I want to compare the id of my user (that’s what I have done with the eq function) and if the id is …

## Python: mathematical operations

Python: mathematical operations Question: I want to creat a programa that reads two input numbers and do mathematical operations on them: addition, multiplication, division and subtraction. I have this code: sum=0 multi=0 div=0 sub=0 for i in range(1,3): num = int(input(f'{i}º dígito: ‘)) sum+=num multi*=num div/=num sub-=num print(f’Soma: {sum}’) print(f’Multi: {multi}’) print(f’Div: {div}’) print(f’Sub: {sub}’) …

## Why is it that I "cannot use assignment expressions with comparison" in Python?

Why is it that I "cannot use assignment expressions with comparison" in Python? Question: In the examples below x is assigned using the walrus operator and is then printed. mystring = "hello, world" #if 1 if x := mystring == "hello, world": print(x) #if 2 if x := (mystring == "hello, world"): print(x) #if 3 …