Python Forum
Newb: Simple Explicit Formula
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Newb: Simple Explicit Formula
#2
raw_input (in Python2) and input (the equivalent in Python3) return str. you need to convert that to int or float to use in calculations

Python 2.7.12 (default, Nov 19 2016, 06:48:10) 
[GCC 5.4.0 20160609] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> x = raw_input('some number: ')
some number: 3
>>> x
'3'
>>> type(x)
<type 'str'>
>>> int(x)
3
>>> float(x)
3.0
Reply


Messages In This Thread
Newb: Simple Explicit Formula - by Duplicitous - May-05-2017, 06:48 PM
RE: Newb: Simple Explicit Formula - by buran - May-05-2017, 07:03 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Python newb need help Fictile 1 221 Apr-02-2024, 03:28 AM
Last Post: buran
  NameError issue with daughter's newb code MrGonk 2 1,459 Sep-16-2021, 01:29 PM
Last Post: BashBedlam
  Python “Formula” Package: How do I parse Excel formula with a range of cells? JaneTan 1 2,691 Jul-12-2021, 11:09 AM
Last Post: jefsummers
  Being explicit about the items inside a tuple argument rudihammad 3 2,465 Dec-04-2019, 08:10 AM
Last Post: perfringo
  Simple newb string question Involute 2 2,224 Sep-08-2019, 12:50 AM
Last Post: Involute
  please help this newb install pygame iofhua 7 5,954 May-15-2019, 01:09 PM
Last Post: buran
  Newb question: Debugging + Linting Python in Visual Studio Code Drone4four 1 2,438 Apr-15-2019, 06:19 AM
Last Post: perfringo
  Newb question about %02d %04d bennylava 30 19,562 Mar-05-2019, 11:23 PM
Last Post: snippsat
  Pthyon 3 question (newb) bennylava 11 5,892 Feb-28-2019, 06:04 PM
Last Post: buran
  newb selfie PatM 5 3,625 Feb-19-2019, 12:20 AM
Last Post: snippsat

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020