12 Replies - 720 Views - Last Post: 16 May 2014 - 03:00 PM Rate Topic: -----

#1 python beginner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-May 14

How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:06 AM

c =1
For row in range(1,5):
       If raw==1:
               Print "miles","",
              Print "kilometres"
      else:
          c=c*10
          print c,"","",
          for col in range(1,3):
                    s=c*1.61
          Print s 



Please help me find where the problem is and provide me the best solution ,..as i am a beginner ...!

This post has been edited by jon.kiparsky: 16 May 2014 - 02:56 PM
Reason for edit:: [code] tags


Is This A Good Question/Topic? 0
  • +

Replies To: How to form table in python which displays miles to kilomete

#2 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:13 AM

What is your specific question, error, etc?
Was This Post Helpful? 0
  • +
  • -

#3 Jeff_F  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 23-November 13

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:16 AM

Hi.. I'll post one version that will work just fine. But first why do you want to do this process using a table??
input = raw_input("Enter Miles: ")
try:
    miles = float(input)
    kilometers = miles * 1.6
    print miles, " Miles is ", kilometers, " Kilometers."
except:
    print "Enter a number"

Was This Post Helpful? 0
  • +
  • -

#4 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:20 AM

@jeff_f: let's not dump code for folks sans explanation.. it short circuits the educational process and butts up against that "don't ask folks to do your homework for you".
Was This Post Helpful? 1
  • +
  • -

#5 python beginner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-May 14

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:24 AM

View Postmodi123_1, on 16 May 2014 - 07:13 AM, said:

What is your specific question, error, etc?


I want the output in the form of a table .
Output should be like this:
Miles. Kilometres
1. 1.61
10. 16.1
100. 161
Was This Post Helpful? 0
  • +
  • -

#6 Jeff_F  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 23-November 13

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:25 AM

View Postmodi123_1, on 16 May 2014 - 07:20 AM, said:

@jeff_f: let's not dump code for folks sans explanation.. it short circuits the educational process and butts up against that "don't ask folks to do your homework for you".


In the last part of my reply I do ask why the OP wants to use a table to provide the results he wants. And as for the code dump I simply was trying to get him/her to get the thought process going. Sorry for breaking the rules, I guess.
Was This Post Helpful? 0
  • +
  • -

#7 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:29 AM

Gotcha. Just a reminder (especially when school semesters are winding down and folks are scrambling to get projects done they've neglected the entire semester!)
Was This Post Helpful? 1
  • +
  • -

#8 Jeff_F  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 23-November 13

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:31 AM

View Postmodi123_1, on 16 May 2014 - 07:29 AM, said:

Gotcha. Just a reminder.



Not an issue. I need to refresh my memory on how to help new usurers to programming and a new language. It's been some time since I've done this.

Have a great day,
Jeff
Was This Post Helpful? 0
  • +
  • -

#9 python beginner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-May 14

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:32 AM

@modi ...i didn knw that i was breaking the rules..i am sorry ...i am new to this site as well as to this programming language.i thought this site would really help me solve all the doubts. But i think i m wrong...anyways thanks @jeff_f :no: :bored:
Was This Post Helpful? 0
  • +
  • -

#10 modi123_1  Icon User is online

  • Suitor #2
  • member icon



Reputation: 13545
  • View blog
  • Posts: 54,057
  • Joined: 12-June 08

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:36 AM

@python beginner - The site is about education and working together to find solutions, but definitely not about asking people to do the work for you. Just keep that in mind when you are puttering about! ;)
Was This Post Helpful? 1
  • +
  • -

#11 python beginner  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 4
  • Joined: 16-May 14

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 07:40 AM

Oh so you think i putforth this question as a part of my homework?? Then you are wrong mr. I am learning python for i am trying to learn something new ..... :helpsmilie:
Was This Post Helpful? 0
  • +
  • -

#12 Marbelous  Icon User is offline

  • D.I.C Head

Reputation: 42
  • View blog
  • Posts: 133
  • Joined: 12-November 12

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 10:36 AM

Well you did say "and provide me best solution" but what we really want is for people to post the error traceback they are getting and ask specific questions rather than just asking us to figure it out for them.

Anyway, have you noticed that you spelled "row" wrong in line 3???

Also, please use code tags so we can see proper indentation. Select your code and click the [CODE] button and it will format automatically. Indentation is critical in python and without it we can't determine what your program is trying to do.
Was This Post Helpful? 0
  • +
  • -

#13 jon.kiparsky  Icon User is offline

  • Chinga la migra
  • member icon


Reputation: 10714
  • View blog
  • Posts: 18,348
  • Joined: 19-March 11

Re: How to form table in python which displays miles to kilomete

Posted 16 May 2014 - 03:00 PM

View Postpython beginner, on 16 May 2014 - 09:06 AM, said:

c =1
For row in range(1,5):
       If raw==1:
               Print "miles","",
              Print "kilometres"
      else:
          c=c*10
          print c,"","",
          for col in range(1,3):
                    s=c*1.61
          Print s 



Please help me find where the problem is and provide me the best solution ,..as i am a beginner ...!



one obvious problem is that 'raw' != 'row'. Typos matter.

A second obvious problem is that print should not be capitalized.

If you fix those things and still have trouble, please provide the error output or some indication of what problem you're trying to solve. That would be very helpful.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1