Skip to main content

All Questions

Tagged with
-5 votes
1 answer
64 views

Comparison Operators result in Python

Why in Python print(bool(7>8)==False==True) results False, logically it should be True? as bool(7>8) is False, therefore False==False==True -> True==True -> True (NOT False) as the ...
Aman Raj Srivastva's user avatar
0 votes
0 answers
53 views

What does a caret and an equal sign (^=) do in Python? [duplicate]

I was looking at the solution to a Python problem, and in it was int ^= num I don't understand what it means. When I searched for it, I got a bunch of posts explaining what the caret sign does on its ...
Cool_Dude's user avatar
0 votes
1 answer
61 views

How to parse search engine keywords input

I'm implementing a tool that lets users search for terms in texts. I'm currently focused on handling more complex input from the search. The operators I am looking to support are : | = OR & = AND ...
Equino's user avatar
  • 47
2 votes
1 answer
47 views

Understanding Array comparison while using custom data types with numpy

i have a question regarding comparison with numpy arrays while using cusom data types. Here is my code: import numpy as np class Expr: def __add__(self, other): return Add(self, other) ...
Max Berktold's user avatar
1 vote
1 answer
22 views

ComputeError with polars dataframe while trying to pass a column expressions in a simple shift() operation

Sorry, I'm starting out in Polars. Is there a way to achieve the same functionality of the shift(n) function where n is a dataframe variable. When I try: df = pl.DataFrame({ "a": [1, 2, ...
user23486287's user avatar
0 votes
0 answers
22 views

How do I define a custom method for @ operator? [duplicate]

Numpy uses the @ operator for matrix multiplication between two arrays. I have my own class for which I want to define a method using the @ operator. How should this be done? I define my own __add__, ...
johann's user avatar
  • 16
0 votes
0 answers
28 views

Airfllow: Having a Custom Sensor Operator inside of python operator

I have a dag task called check_file that is responsible to check the file in remote location. check_file = PythonOperator( task_id='check_file', python_callable=check_file, ...
adkharel's user avatar
-1 votes
1 answer
51 views

Why does Python return 0 for this & operation?

I'm learning Python and messing around with operations when I tried >>> 14 & 16 0 >>> 0b1110 & 0b10000 0 In my head it would look like this: >>> 0b1110 & ...
neirad's user avatar
  • 3
0 votes
0 answers
80 views

Inaccurate results using mod operator in python [duplicate]

I'm having trouble in a condition i want in a if statement. I want to check if a variable(float type), like 0.9, is multiple of 0.1. I had this code: (t * dt) % 0.1 == 0 I've tried the modulo ...
mariami's user avatar
0 votes
0 answers
39 views

Python example f"{heading:=^30}"

I ran across this in a basic Python tutorial (https://docs.python.org/3.10/tutorial/controlflow.html). The example is: >>> heading = "Centered string" >>> f"{heading:=...
user3765883's user avatar
0 votes
2 answers
55 views

Python script: upper bound of range not being included

I wrote this script: inpf = input('input file name:') lb = input('lower bound:') ub = input('upper bound:') with open(inpf, 'r') as f: contents = f.readlines() for i in contents: if lb ...
Drew's user avatar
  • 1
-1 votes
1 answer
42 views

Combining python "in" and "==" operator has confusing behavior [duplicate]

A buddy of mine is learning python and I saw an odd thing he did with his code: if ch in input[index] == test[index]) Obviously there's some context missing for that fragment, but interestingly, that ...
Christian Baker's user avatar
0 votes
2 answers
27 views

I want to know which determines the output like not in this case applies to first condition only or both

x=(not (5==5) and (10<12)) print(x) when executing. not negates the first expression or both? In my opinion "not" should be executed with (5==5) only but my colleague says it will affect ...
sana's user avatar
  • 1
-3 votes
1 answer
77 views

Could you please explain below three codes?, why they are giving different results

code 1 list_a = [] list_a += str(1) O/P: ['1'] code 2 list_a = [] list_a += 1 O/P: Type Error code 3 list_a = [] list_a = list_a + str(1) O/P: Type Error I'm expecting that if += operator ...
Bhuvana ravula's user avatar
-2 votes
1 answer
89 views

Fonction skip bool and doesn't calculate [duplicate]

Welcome in my misery. I'm a novice/beginner in coding :) I've been trying to write a calculator that detects anomalies in the input provided. My first problem was to neglect any letters and that was ...
TheAX 0198's user avatar

15 30 50 per page
1
2 3 4 5
53