Jupyter Interactive Widget not executing properly

风格不统一 提交于 2021-02-11 15:02:48

问题


I am using jupyte notebook

This is the Code

from ipywidgets import interact

define a function to work with (cubes the number)

def myfunction(arg): return arg+1 interact(myfunction, arg=9);

The result showing is 10 instead it should be showing a slider

Showing: enter image description here

Instead it show: enter image description here


回答1:


I can't tell exactly what went wrong with what you did because there are formatting issues with your post -- you need to indent the code 4 spaces when you ask the question to make it look right, which effects the meaning because Python is sensitive to white space.

I modified your text and got it to work for me

from ipywidgets import interact

def myfunction(arg): 
    return arg+1 

interact(myfunction, arg=9)

Screenshot:



来源:https://stackoverflow.com/questions/53516965/jupyter-interactive-widget-not-executing-properly

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!