guys ,, I have an assignment

  • (2 Pages)
  • +
  • 1
  • 2

19 Replies - 1197 Views - Last Post: 21 April 2013 - 01:25 AM Rate Topic: -----

#16 101newbie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 17-April 13

Re: guys ,, I have an assignment

Posted 20 April 2013 - 03:55 PM

thanks you guys :)/>

Mek ,, now what about this ? I tried to run my code but there is an error with it can you advise me ?

#insert time
print ("Please give me a time matching hh:mm pattern :",) #waiting till accepted value entered
match="false"
while match=="false":
number=input()
result=re.match("^(?:(/>/>?:(/>/>[01]?\d|2[0-3]):)/>/>?([0-5]?\d):)/>/>?([0-5]?\d)$",number) #matching pattern hh:mm
if result:
match="true"
else:
print("error retry")
if result :
print ("proceeding")
else:
print ("wrong input")
num=number.split(":") #splitting time to hours and minutes
hour=(num[0])
minute=(num[1])
try :
hour=float(hour)
minute=float(minute)
except:
print("error has happend")
hour=hour+(minutes/60) #adding extra angle of hour pointer
min_ang = ((minute/60)*360)
hour_ang = (hour/12)*360
if hour_ang>=360:
hour_ang=0
angle=abs(hour_ang-min_ang)
print (angle)

Was This Post Helpful? 0
  • +
  • -

#17 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3608
  • View blog
  • Posts: 12,399
  • Joined: 12-December 12

Re: guys ,, I have an assignment

Posted 20 April 2013 - 04:24 PM

If you have errors then post them, together with confirmation of which lines they refer to in your posted code.

Your code has no indentations which, as has already been mentioned, is crucial in Python.

print ("Please give me a time matching hh:mm pattern :",) # lose the spare comma at the end,

Was This Post Helpful? 0
  • +
  • -

#18 101newbie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 17-April 13

Re: guys ,, I have an assignment

Posted 20 April 2013 - 04:43 PM

View Postandrewsw, on 20 April 2013 - 04:24 PM, said:

If you have errors then post them, together with confirmation of which lines they refer to in your posted code.

thanks Andrewsw
at line 05
 number= input() 

it says Indentationerror :expected an indented block
Was This Post Helpful? 0
  • +
  • -

#19 andrewsw  Icon User is online

  • It's just been revoked!
  • member icon

Reputation: 3608
  • View blog
  • Posts: 12,399
  • Joined: 12-December 12

Re: guys ,, I have an assignment

Posted 20 April 2013 - 04:47 PM

View Post101newbie, on 20 April 2013 - 11:43 PM, said:

View Postandrewsw, on 20 April 2013 - 04:24 PM, said:

If you have errors then post them, together with confirmation of which lines they refer to in your posted code.

thanks Andrewsw
at line 05
 number= input() 

it says Indentationerror :expected an indented block

Yes, so what is this error message telling you?
Was This Post Helpful? 2
  • +
  • -

#20 Mekire  Icon User is offline

  • D.I.C Head

Reputation: 116
  • View blog
  • Posts: 212
  • Joined: 11-January 13

Re: guys ,, I have an assignment

Posted 21 April 2013 - 01:25 AM

I had assumed previously that your lack of indentation was just you pasting your code into your replies incorrectly. If you really don't understand how to indent python code you need to go back to the beginning. This will be covered very early on in any python tutorial. In other languages like C, indenting is voluntary (but still highly encouraged). In python it is part of the syntax of the language.

-Mek
Was This Post Helpful? 3
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2