![]() |
| ||
| A little help tweaking the my code Hi guys, I have a friend at school and she's taken Unix 2. She gave me a copy of her work assignment so that I could improve my scripting skills (Still a begginner at python and programming). This is the assignment: Write a script that will prompt the user to input a number between 1 and 10. You need to output: 1. The number they entered, with an explanation of what the number is. 2. The square of the inputted number. Conditions: 1. You must check that the number is between 1 and 10, if not, clear the screen ask the user agian. 2. You must have an exit for the user, other than entering a number. 3. Use at least one sub function. Ok so that it! And this is what I made so far: 1 #! /usr/bin/python The problem with the code is that it loops the way I wanted; but it won't exit out of the loop. I know its something simple, but i'm not seeing is yet... |
| ||
| Re: A little help tweaking the my code This is something similar to what you coded. I didn't use the 'clear the screen' thingy because that would make it OS specific, and our instructor says that it is better to leave a record on the screen anyway. #! /usr/bin/python |
| ||
| Re: A little help tweaking the my code Nice clean code there Lardmeister. Did you switch from C# to Python? |
| ||
| Re: A little help tweaking the my code That is clean code! I guest i needed to add some comments. But hey, thanks for the help. |
| All times are GMT -4. The time now is 9:11 pm. |
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC