This forum is now read-only. Please use our new forums at discuss.codecademy.com.

Functions, Part I Forum

View Course » View Exercise

675 points
504f7d254b4add0002092c7e_951075113
Submitted by
William Gao
about 4 years ago

Why doesn't this pass

What is wrong with my code

<?php
$round = round(M_PI);
print $round;
?>

<?php
$rounddecimal = round(MPI, 3);
print $round_decimal;
?>


6 votes

permalink

Hope That Helps

<?php
// Try rounding a floating point number to an integer
// and print it to the screen
$round = round(M_PI);
echo $round
?>
</p>
<p>
<?php
// Try rounding a floating point number to 3 decimal places
// and print it to the screen
$test = round(M_PI, 3);
echo $test
?>

930 points
D0c56867482aff13d5a22b8efd699bb9?s=140&d=retro
Submitted by
roun512
about 4 years ago

3 Comments

541e34b780ff338f3c003014_125062677 Amanuel about 3 years ago

THX

Picture Carlos Cañellas Tovar almost 3 years ago

Thank you! So that's the problem with being two PHP.

Picture Carlos Cañellas Tovar almost 3 years ago

And the exercise only uses one. Please, somebody fix it.


2 votes

permalink

The variable $rounddecimal isn't equal to $round_decimal

772 points
53b0526052f8637f7a002a50_498371852
Submitted by
Ben
about 4 years ago

3 Comments

504f7d254b4add0002092c7e_951075113 William Gao about 4 years ago

Even if I fix it, it still gives me the error message

52565eeb80ff337232001e7d_158831513 brennanpringle_4f151ba89c99ab0001018 almost 4 years ago

You're also missing the underscore for the M_PI constant in the $rounddecimal variable.

Picture Carlos Cañellas Tovar almost 3 years ago

He's not forgetting. Notice the italic that's made with underlines.


1 vote

permalink

When you print your round decimal you have added an underscore to the variable name.
Does that fix it?

250 points
Picture
Submitted by
Simon Craig
about 4 years ago


0 votes

permalink

Never mind, I should have put 3 instead of two

675 points
504f7d254b4add0002092c7e_951075113
Submitted by
William Gao
about 4 years ago


-3 votes

permalink

<?php
$roundUpToTwo = round(M_PI , 2);
echo $roundUpToTwo;
?>

1247 points
516f11ce38353b4b45000ca8_354054466
Submitted by
Kaushik Kishore
about 4 years ago

1 Comment

504f7d254b4add0002092c7e_951075113 William Gao about 4 years ago

It still says Oops, try again! Your second call to round() should print a floating point number with exactly 3 digits after the decimal.