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
2 #
3 # 1 and 10
4
5 import os
6 import sys
7
8 number = ""
9 while number > 0:
10 number = int(raw_input("\n\nChoose a number between 1 and 10: "))
11 print "This is the number you choosed", number
12 print " Square root of the number is",
13 print number * number
14
15 if number == 0:
16 print "\nThis needs to be a bigger number."
17 elif number > 10:
18 os.system("clear")
19 print "Opps!"
20
21 raw_input("\n\nTo exit program press the enter key. ")
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...