[Tutor] Stuck on some basics re floats

Matthew Polack matthew.polack at htlc.vic.edu.au
Tue Jul 17 19:52:24 EDT 2018


I'm a teacher trying to learn Python with my students.

I am trying to make a very simple 'unit calculator' program...but I get an
error ..I think python is treating my num1 variable as a text string...not
an integer.

How do I fix this?


- Matt

print ("How many inches would you like to convert? ")
num1 = input('Enter inches here')
print ("You have entered",num1, "inches")
convert = num1 * 2.54
print ("This is", convert, "centimetres")

Traceback (most recent call last):
  File "convert.py", line 10, in <module>
    convert = num1 * 2.54
TypeError: can't multiply sequence by non-int of type 'float'

Matthew Polack | Teacher

[image: Emailbanner3.png]

Trinity Drive  |  PO Box 822

Horsham Victoria 3402

p. 03 5382 2529   m. 0402456854

e. matthew.polack at htlc.vic.edu.au

w. www.htlc.vic.edu.au

**Disclaimer: *Whilst every attempt has been made to ensure that material 
contained in this email is free from computer viruses or other defects, the 
attached files are provided, and may only be used, on the basis that the 
user assumes all responsibility for use of the material transmitted. This 
email is intended only for the use of the individual or entity named above 
and may contain information that is confidential and privileged. If you are 
not the intended recipient, please note that any dissemination, 
distribution or copying of this email is strictly prohibited. If you have 
received this email in error, please notify us immediately by return email 
or telephone +61 3 5382 2529** and destroy the original message.*

More information about the Tutor mailing list