Question

Im getting the same output but I'm assuming I'm forgetting to incorporate the objective of evaluating in increments of 1 unit? How do I code that?

Instructions from your Teacher: run tests Write a program that prints to three significant figures the values of f(x) from x

0 0
Add a comment Improve this question Transcribed image text
Answer #1

f.py - D:/Coding/Python/f.py (3.7.4) File Edit Format Run Options Window Help import math def f(x): #If x<8, return sqrt (x)

OUTPUT :

======================= RESTART: D: /Coding/Python/f.py - 0.000 1.000 1.414 1.732 2.000 2.236 2.449 2.646 2.828 2.828 2.828 >

CODE :

import math
def f(x):
#If x<8, return sqrt(x)
if x<8:
return math.sqrt(x)
#Return square root of 8
return 8**0.5

#Loop from 0 to 10
for x in range(11):
#Print f(x) rounded to 3 decimal points
print('%.3f'%f(x))

Add a comment
Know the answer?
Add Answer to:
Im getting the same output but I'm assuming I'm forgetting to incorporate the objective of evaluating...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • i'm trouble getting my program to print this output and repeat until asked to quit the...

    i'm trouble getting my program to print this output and repeat until asked to quit the program Enter a telephone number using letterss (EXIT to quit): GET LOAN The corresponding telephone number is: 438-5626 Here's my code: #include <stdio.h> #include <string.h> char getNumber(char aC) { char c = ' '; switch (aC) { case 'A': case 'B': case 'C': c = '2'; break; case 'D': case 'E': case 'F': c = '3'; break; case 'G': case 'H': case 'I': c...

  • I'm getting errors that i can't figure out. I need help fixing them. particularly focus on...

    I'm getting errors that i can't figure out. I need help fixing them. particularly focus on the errors they are highlighted in bold on the list code: #include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> #include <ctype.h> #include "stack.h" #include "booleanEvaluation.h" #include "booleanWithError.h" /* evaluatePostfix * input: a postfix expression * output: T, F, or E * * Uses a stack to evaluates the postfix expression and returns the result as a string where "T" denotes true and "F" denotes...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT