logic

CS50's Introduction to Artificial Intelligence with Python – Knowledge

CS50's Introduction to Artificial Intelligence with Python – Knowledge Question: I’m studyng Harvard’s Introduction to Artificial Intelligence with Python course. I’m enjoying a lot. However I downloaded logic file to use Boolean algebra and Knowledge, that simple operations (OR,AND,NOT…) Before I show my doubt I will share the Knowledge class from harvard source code, I …

Total answers: 1

Could someone point out the error in my logic. (Coding Exercise)

Could someone point out the error in my logic. (Coding Exercise) Question: So this is a question form the website HackerRank. I’ve given it my best shot and I can’t for the life of me figure out what I’m doing wrong. The question goes as follows: "It is New Year’s Day and people are in …

Total answers: 2

Program to check balanced brackets for equation

Program to check balanced brackets for equation Question: I am trying to write a program which checks balanced brackets for equation, my program is checking the brackets but its only looking for brackets and only give the right answer for the bracket but different answer for equation My expected output is exp1 = "(2+3)+(1-5)" # …

Total answers: 3

In Python, How does the following code work?

In Python, How does the following code work? Question: INSTRUCTIONS Prison Break A prison can be represented as a list of cells. Each cell contains exactly one prisoner. A 1 represents an unlocked cell and a 0 represents a locked cell. [1, 1, 0, 0, 0, 1, 0] Starting inside the leftmost cell, you are …

Total answers: 2

Select different columns in different rows according to another pandas Series

Select different columns in different rows according to another pandas Series Question: I have a pandas Series which contains the column names that I need to collect data from: 1 col1 3 col4 4 col3 5 col5 6 col5 And the dataframe that contains data looks like: col1 col2 col3 col4 col5 1 data1 data2 …

Total answers: 1

Create different functions from loop in Python

Create different functions from loop in Python Question: I’m trying to build a tkinter GUI, and I’m having a Python programming logic issue. My problem is the following: I’m creating a bunch of objects in the following way: class Aplication: def createObjects(self): objects = [] for i in range(10): obj = Object(command = lambda: self.myFunction(i)) …

Total answers: 1

AND/OR in Python?

AND/OR in Python? Question: I know that the and and or expressions exist in python, but is there any and/or expression? Or some way to combine them in order to produce the same effect as a and/or expression? my code looks something like this: if input==”a”: if “a” or “á” or “à” or “ã” or …

Total answers: 7

Booleans have two possible values. Are there types that have three possible values?

Booleans have two possible values. Are there types that have three possible values? Question: Possible Duplicate: What's the best way to implement an 'enum' in Python? I’m writing a function that, ideally, I’d like to return one of three states: “yes”, “no”, and “don’t know”. Do any programming languages have a type that has three, …

Total answers: 9