Python Forum
Built in Functions not working
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Built in Functions not working
#1
Basic built in functions like len(),str(),int() and float() do not work in a text.py file but do in IDLE. Does anyone know why and how to fix this. I'm kind of stuck on this until I can move on to the next task.

len("python")
str(100)
int("1")
float(100)

int("110")
int(20.54)

float("16.4")
float(99)

Results in IDLE:

Python 3.6.2 (v3.6.2:5fd33b5, Jul 8 2017, 04:57:36) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>>
RESTART: C:\Users\mhoneycutt.EMSTEC\AppData\Local\Programs\Python\Python36\test1.py
>>>
Reply
#2
Please be more descriptive of the problem.

If what you posted is the contents of text.py, you aren't printing anything. You would need something like

print(int("1"))
as an entry
If it ain't broke, I just haven't gotten to it yet.
OS: Windows 10, openSuse 42.3, freeBSD 11, Raspian "Stretch"
Python 3.6.5, IDE: PyCharm 2018 Community Edition
Reply
#3
There is a difference between typing code in the interactive repl (IDLE) or executing a script.
The abbreviation repl stands for Read-Evaluate-Print-Loop.

When entering the code into IDLE, you get always the last Output and additional output which is printed via the print function to stdout.

Executing a Python program does it not. There you have explicit to print the output. Your assumption that a script does the same, is not logical. If a program does this, it's very verbose and useless at the end.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply
#4
That makes complete sense. I can't believe I didn't realize this. Thanks for the reply.
Reply
#5
No problem. Beginners can run into it. Sometimes we forget how it was as we started with programming.
Almost dead, but too lazy to die: https://sourceserver.info
All humans together. We don't need politicians!
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Why built in functions are defined as class? quazirfan 5 2,776 Oct-23-2021, 01:20 PM
Last Post: Gribouillis
  Question about functions(built-in) Jinja2Exploitation 2 1,934 Nov-15-2020, 02:13 PM
Last Post: jefsummers
  Does anyone have unicurses panel functions working on a Windows 10 platform? pjfarley3 0 1,457 Oct-11-2020, 04:41 AM
Last Post: pjfarley3
  Called Functions Not Working WhatAmIDoing09 3 2,552 Jul-12-2019, 07:02 PM
Last Post: ichabod801
  Working on nested functions boxerboy1168 2 2,591 Dec-28-2018, 07:54 AM
Last Post: Gribouillis
  How to retrieve all and only built-in functions from interactive interpreter perfringo 4 3,388 Aug-08-2018, 04:25 PM
Last Post: DeaD_EyE

Forum Jump:

User Panel Messages

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