Created
September 2, 2022 10:20
-
-
Save liketaurus/7eefd7010f112ef183dac4a6b270476e to your computer and use it in GitHub Desktop.
Simple forms (GUI) in Google Colab (km to miles)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kmToMile = 0.6214 | |
#@title Перетворення кілометрів на милі | |
km = 310.2 #@param {type:"slider", min:0, max:1000, step:0.1} | |
print("{:} km = {:.1f} miles!".format(km, km*kmToMile)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
kmToMile = 0.6214 | |
import ipywidgets as widgets | |
slider = widgets.IntSlider(value=0, max=1000) | |
print("Відстань в кілометрах:") | |
display(slider) | |
from IPython.display import display | |
button = widgets.Button(description="Порахувати") | |
output = widgets.Output() | |
def on_button_clicked(b): | |
with output: | |
print("{:} km = {:.1f} miles!".format(slider.value, slider.value*kmToMile)) | |
button.on_click(on_button_clicked) | |
display(button, output) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment