PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Tuesday, June 28, 2022

[FIXED] how to convert strings to float

 June 28, 2022     graph, input, tkinter     No comments   

Issue

code image

Hello, I am trying to write a code that takes in a number of inputs and outputs the graph that they form, (ex. quadratic equations, and cubic). In the image linked I am trying to get in the inputs as entrys from a window that I have created using Tkinter, however, when I go to work with the values I need to convert them into float numbers, however, I don’t know how I can it.

Can someone help me, please?


Solution

here there is no function 'type' instead use 'delete' and 'insert' the '0' represents the cursor position (i.e in starting) and 'end' denotes till end

from tkinter import *
root=Tk() 
def conversion():
    global a
    global b
    global c
    global d
    for i in (a,b,c,d):
        k=float(i.get())
        i.delete(0,'end')
        i.insert(0,k)
a=Entry(root,text='3')
a. pack() 
b=Entry(root)
b.pack() 
c=Entry(root)
c.pack() 
d=Entry(root)
d.pack() 
buttonl=Button(root, text="press",command=conversion)
buttonl.pack() 
root .mainloop() 


Answered By - kaleintesh
Answer Checked By - Senaida (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing