440,036 Members | 1,963 Online
Need help? Post your question and get tips & solutions from a community of 440,036 IT Pros & Developers. It's quick & easy.

# Problems for a beginner

5 Replies

 100+ P: 126 One misstake you have made (I havent run any of the code, And i wont cuz im in a hurry). Expand|Select|Wrap|Line Numbers else x == 15: Else is not suposed to have any boolean statments. Replace it with someting like this: Expand|Select|Wrap|Line Numbers elif x == 15:     #youre code here.   else:     print "Numer %d not in range." % x Apr 9 '08 #2

 100+ P: 314 Make Smygis' suggested change and then there is a syntax error on line 153 where it reads: a = ((b1+b2)*h)/2) There is an extra closing parenthesis so you should either remove it or add an extra opening parenthesis where appropriate Apr 9 '08 #3

 P: 3 Thanks guys, it worked perfect. The only thing I would like to add now it to repeat the question for what number on the menu, but I don't want to repeat all of the code. I read a little bit about loops, but I am not sure how to make it. Like right before x is defined so when the first math function is made, it will ask again if you want to use another function. Then repeating all of the code without typing it out again. How is this possible? Apr 10 '08 #4

 Expert Mod 2.5K+ P: 2,851 Something like this: Expand|Select|Wrap|Line Numbers while True:     print "Formulas"     print "--------------------------------------------"     ....................     print " |    16.Exit                               |     print "--------------------------------------------"       x = int(raw_input("What formula would you like to use?  "))       if x == 1:         .......     if x == 16:         break I suggest using raw_input, which always returns a string. If you create a function for your code, you can substitute return for break. Apr 10 '08 #5

 P: 3 Thanks, it worked perfectly! Apr 11 '08 #6