result = 0 answers = '110011111111111111111111110110010' #print("Number of questions: %i" % len(answers)) for i in range(0, len(answers)): #print("Index %i Value: %s" % (i, answers[i])) result += int(answers[i]) << i ans_key = {i: 1 << i for i in range(0, len(answers))} #print(ans_key) chk_num = 2 chk_2 = 6 #print(result & (ans_key[chk_num - 1] + ans_key[chk_2 - 1])) if result & (ans_key[chk_num - 1] + ans_key[chk_2 - 1]): pass #print("Question#: %i is True" % chk_num) else: pass #print("Question#: %i is False" % chk_num) def print_answers(result, mask): for i, val in ans_key: pass import csv class Table: def __init__(self, d_path): pass def read_bats(self, x): pass class Marine: def __init__(self): self.bats = {} self.priority = 0 def add_result(self, year, period, result): res_key = year << period #experimental: year shifted by observation code self.bats[res_key] = result def get_result(self, year, period): key = year << period if key in self.bats: return self.bats[key] else: return -1
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question