[closed] Homework 1.09

Just to be sure:

The input of the program (var x) is always a positive decimal number.

Eg:

  • 3.14 --> 3
  • 6.5 --> 7
  • 123.98 --> 124
  • 2.0 --> 2

but not integers such as:

  • 2
  • 7678

(meaning that I will always find the decimal point)

Am I right?

asked 23 Feb '12, 06:37

Unai%20Herr%C3%A1n's gravatar image

Unai Herrán
2102418
accept rate: 15%

closed 23 Feb '12, 10:53

The question has been closed for the following reason "The question is answered, right answer was accepted" by Unai Herrán 23 Feb '12, 10:53


3 Answers:

Doesn't matter, I figured that if I add .0 to a number it will convert it to a decimal numer

x=1

x=x+0.0

print x

will show:

1.0

link

answered 23 Feb '12, 06:44

Unai%20Herr%C3%A1n's gravatar image

Unai Herrán
2102418

edited 23 Feb '12, 06:51

1

Exactly. That was covered in lectures too.

(23 Feb '12, 06:46) Snezhana Snezhana's gravatar image

Yes, since it says it's always a decimal number, it should always have a decimal portion. The decimal portion might be 0. In that case, it would just be 2.0.

link

answered 23 Feb '12, 06:40

Glen's gravatar image

Glen
7823

You're right, just remember that spaces are not allowed (I'm sure you do remember that and what you've typed is just for more readability:) and also there could be a case like " 27. ", which is also decimal, in fact.

link

answered 23 Feb '12, 06:43

Snezhana's gravatar image

Snezhana
1.6k11529

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "Title")
  • image?![alt text](/path/img.jpg "Title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Tags:

×15,314
×97

Asked: 23 Feb '12, 06:37

Seen: 366 times

Last updated: 23 Feb '12, 10:53