88.6k views
1 vote
how to create a code in pyton to ask the user to enter the number of switches and calculate the possible outcomes that can come from those many numbers of switches(on/off). Please help me with this​

User Tigrish
by
6.2k points

1 Answer

4 votes

amount = int(input("How many switches? "))

if amount == 0:

print("There are no outcomes for 0 switches")

else:

print("With {} switch(es), there are {} outcomes.".format(amount, 2**amount))

how to create a code in pyton to ask the user to enter the number of switches and-example-1
User Ola Karlsson
by
5.8k points