[Tutor] How to check if user input is an integer

2013-03-29 Thread Ghadir Ghasemi
Hi guys I am trying to create part of a vending machine. The section below is if the user wants to insert 50p coins. It works but when I entered a non integer like 'dfsdf', the program just broke. Is there a way that the program can check if the input is an integer, and if it is, then the

[Tutor] help with storing money variable

2013-02-19 Thread Ghadir Ghasemi
Hi guys, Iam halfway through my vending machine program that I started earlier. I ran into a problem. When the user inserts some money, The money variable is not stored for until the user buys an item. So what happens is when the users inserts some coins and then trys to buy an item the money

[Tutor] Binary Addition

2013-02-13 Thread Ghadir Ghasemi
Hi guys can you tell me what is wrong with this code?. It says unexpected indent and the bottom of the code everytime I run it. Thank you on=True while on == True: def eight_digit_binary1(message): response1 = input(message) while len(response1) 8: response1 =

[Tutor] Additional help

2013-02-10 Thread Ghadir Ghasemi
Hi guys, I wondered if you knew what I could add to this code so that when the user enters 1 from the menu and then doesn't enter a valid binary number the program should ask them over and over again until valid binary number is entered. here is the code: def show_menu():

[Tutor] python help!

2013-02-09 Thread Ghadir Ghasemi
Hi guys can you tell me what is wrong with the second part of this code(elif choice == '2'). When I type something other than 0-255, it correctly asks again for an input but when I enter a number from 0-255 it does nothing : def show_menu(): print(===) print(1-binary to

[Tutor] (no subject)

2013-02-04 Thread Ghadir Ghasemi
hi guys, this is the first bit of my program converting from binary to decimal without use of built in functions. binnum = input(Please enter a binary number: ) decnum = 0 rank = 1 for i in reversed(binnum): decnum += rank * int(i) rank *= 2 print(decnum). When I first tested the

[Tutor] Help!

2013-01-28 Thread Ghadir Ghasemi
Hi guys I wanted to make a program called Binary/decimal converter. But I want to do it the hard way e.g. not using built in python functions. Can you give me an idea about how I can do that? Thank you. ___ Tutor maillist - Tutor@python.org To

[Tutor] Binary/Decimal convertor

2013-01-11 Thread Ghadir Ghasemi
Hi, I made a program called binary/denary convertor. Can anyone tell me about how I could stop the user entering a binary number with more than 8 numbers or 8 bit by repeating the question over and over until they do enter a correct binary number( 8-bit or less) Here is the code. I started off

[Tutor] Vending machine program

2013-01-04 Thread Ghadir Ghasemi
H I wanted to create a program called vending machine and I wondered if you could do it so I can find out how to do it. Here is how it should work like: A food vending machine accepts 10p, 20p, 50p and £1 coins. One or more coins are inserted and the current credit is calculated and displayed.

[Tutor] stuck on a new program

2013-01-04 Thread Ghadir Ghasemi
Hi guys I recently created a binary to denary and denary to binary convertor program. It is pretty much finished but I can't get it to work. Can you spot the fault in it please and tell me how it coul be fixed? print(==) print(1 = binary to denary) print(2 = denary to binary)