import math
def bin2dec(binStr):
count=len(binStr);
decimalVal=0;
for i in range(0,count):
decimalVal=decimalVal+(int(binStr[count-i-1])*math.pow(2,i));
return decimalVal;
def main():
print(bin2dec('110'));
print(bin2dec('11111111'));
print(bin2dec('1'));
if __name__=="__main__":
main();
screenshot
Expected output:

please answer in python print Cannot divide anything but numbers. else - print n. 5. (+15)...
Can someone solve this practice exam question, python 3
5. (+15) Write a function bin 2dec ( ) that takes a string representation of any length binary number and returns the decimal equivalent without using any type conversions. Remember that the binary representation ofa number has a power of 2 in each position, starting with 2° in the right most position and increasing by 1 as it moves left (e.g. 222120) loina dec (nun det >>> bin2dec('110') 6 >>>bin2dec('11111111' )...
PLEASE HELP! python code
Problem 4. Define the function pythagorian_coprimes (n=100) that prints all pairs of positive integer numbers (a, b) such that c = a + b is also a whole number and 1 <c<n. Include only those triples that are co-prime (do not have any common divisors other than 1). For example, (3, 4, 5) is okay but (30, 40, 50) should be skipped. Help: As a starting example, examine the function pythagorian_triples that yields all triples. Modify...
PYTHON 3 Object Oriented Programming
***a9q3.py file below***
class GradeItem(object):
# A Grade Item is anything a course uses in a grading scheme,
# like a test or an assignment. It has a score, which is assessed by
# an instructor, and a maximum value, set by the instructor, and a weight,
# which defines how much the item counts towards a final grade.
def __init__(self, weight, scored=None, out_of=None):
"""
Purpose:
Initialize the GradeItem object.
Preconditions:
:param weight: the weight...
please answer "def turn_payouts(move_a, move_b):" in
python.
Notes Two players will face each other. They each decide independently to "cooperate" or "cheat". If they both cooperated, they each win two points. If they both cheated, nobody wins anything. one cheats, the cheater gets +3 and the cooperator loses a point. That wasn't very kind! One turn is defined as each player making a choice, and winning or losing some points as a result. Shared history against this player is available...