(Challenge) Value Table Calculator | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula grƔtis
+ 4

(Challenge) Value Table Calculator

Write a program that take the following inputs expression: (example: ā€œsin(x)ā€) independent variable: (example: ā€œxā€) var min: example: ā€œ-10ā€ var max: example: ā€œ+10ā€ step: example: ā€œ0.1ā€ and generate a table, based on the inputs, printing the value of the stepped independent variable and the expression. Reasonable simple in python, ...

26th Dec 2017, 10:23 PM
Markus R
Markus R - avatar
6 Respostas
+ 8
this my initial code for sin/ cos /tan https://code.sololearn.com/c8iZREZeV903/?ref=app
27th Dec 2017, 12:03 AM
Mohammad Dakdouk
Mohammad Dakdouk - avatar
+ 2
https://code.sololearn.com/cl65x6dj8sO3/?ref=app
27th Dec 2017, 7:08 AM
Kodirbek Makharov
Kodirbek Makharov - avatar
+ 2
Good initial work! Try to be more generic and to support all mathematical expressions that your programming language understands ... For example also more complex things like 2*x + sin(x) + (x*cos(x)). In python this can be done without writing a complex parser ...
27th Dec 2017, 8:05 AM
Markus R
Markus R - avatar
+ 2
https://code.sololearn.com/cy9ZcWkI3wZP/?ref=app Hereā€™s an attempt in python that allows additionally expressions for the min / max and step values ...
28th Dec 2017, 8:14 AM
Markus R
Markus R - avatar
+ 1
Markus, with eval :) ? I update my answer
27th Dec 2017, 12:15 PM
Kodirbek Makharov
Kodirbek Makharov - avatar
+ 1
Exactly ... eval is the magic command ...
27th Dec 2017, 2:27 PM
Markus R
Markus R - avatar