Mittpunktsformeln i Python: Skillnad mellan sidversioner
Hoppa till navigering
Hoppa till sök
Hakan (diskussion | bidrag) |
Hakan (diskussion | bidrag) |
||
| (3 mellanliggande sidversioner av samma användare visas inte) | |||
| Rad 1: | Rad 1: | ||
[[Kategori:Python]] [[Kategori:Ma2c]] [[Kategori:Geometri]] | [[Kategori:Python]] [[Kategori:Ma2c]] [[Kategori:Geometri]] | ||
{{python|[[Python|Python-hjälp]] och [https://wikiskola.se/index.php?title{{=}}Kategori:Python Fler uppgifter]}} | {{python|[[Python|Python-hjälp]] och [https://wikiskola.se/index.php?title{{=}}Kategori:Python Fler uppgifter]}} | ||
[[Fil:Python-basic-image-exercise-73.png| | [[Fil:Python-basic-image-exercise-73.png|300px|höger]] | ||
{{malruta| '''Kom igång med programmering i matematiken.''' | {{malruta| '''Kom igång med programmering i matematiken.''' | ||
| Rad 23: | Rad 23: | ||
<pre> | <pre> | ||
print('\nCalculate the midpoint of a line :') | |||
x1 = float(input('The value of x (the first endpoint) ')) | |||
y1 = float(input('The value of y (the first endpoint) ')) | |||
print("The | |||
print("The | x2 = float(input('The value of x (the second endpoint) ')) | ||
print(" | y2 = float(input('The value of y (the second endpoint) ')) | ||
x_m_point = (x1 + x2)/2 | |||
y_m_point = (y1 + y2)/2 | |||
print(); | |||
print("The midpoint of line is :") | |||
print( "The midpoint's x value is: ",x_m_point) | |||
print( "The midpoint's y value is: ",y_m_point) | |||
print(); | |||
</pre> | </pre> | ||
Uppgiften är inspirerad av [https://www.w3resource.com/python-exercises/python-basic-exercise-73.php w3resource] | Uppgiften är inspirerad av [https://www.w3resource.com/python-exercises/python-basic-exercise-73.php w3resource] | ||
Se diskussionssidan för fler kodexempel. | |||
Nuvarande version från 29 januari 2019 kl. 09.50

Mittpunktsformeln
| Uppgift |
|---|
Mittpunktsformeln
|
Python-koden
print('\nCalculate the midpoint of a line :')
x1 = float(input('The value of x (the first endpoint) '))
y1 = float(input('The value of y (the first endpoint) '))
x2 = float(input('The value of x (the second endpoint) '))
y2 = float(input('The value of y (the second endpoint) '))
x_m_point = (x1 + x2)/2
y_m_point = (y1 + y2)/2
print();
print("The midpoint of line is :")
print( "The midpoint's x value is: ",x_m_point)
print( "The midpoint's y value is: ",y_m_point)
print();
Uppgiften är inspirerad av w3resource
Se diskussionssidan för fler kodexempel.

