Write a computer program in the python programming lanuage that:
1. Asks the user to enter up to three mobile telephone numbers in a single screen.
2. For those numbered entered, displays the list of numbers entered and clearly displays the mobile network belongs to alongside. You program should also indicate if a number entered does not belong to a valid mobile network.
3. Continues to run until the user indicates that they have finished entering phone numbers.
Number Prefix Mobile Network
083 3 Ireland
085 Meteor
086 O2
087 Vodafone
and this is what i have done.
import easygui
RunProgram = "Yes"
prompt = "Enter mobile phone numbers: "
Title = "Mobile phone networks"
options = ["Mobile Number 1: ","Mobile Number 2: ","Mobile Number 3: "]
userinput = []
t
while RunProgram == "Yes":
userinput = easygui.multenterbox(prompt,Title,options)
mobOne = userinput[0]
mobTwo = userinput[1]
mobThree = userinput[2]
posOne = mobOne.find('8')
posTwo = mobTwo.find('8')
posThree = mobTwo.find('8')
prefixOne = mobOne[posOne+1:3]
prefixTwo = mobTwo[posTwo+1:3]
prefixThree = mobThree[posThree+1:3]
networks = ['3','5','6','7']
three = "3 Ireland Network"
meteor = "Meteor Network"
Otwo = "O2 Network"
Vod = "Vodafone Network"
if prefixOne == networks[0]:
easygui.msgbox(mobOne + " is on the " + three)
elif prefixOne == networks[1]:
easygui.msgbox(mobOne + " is on the " + meteor)
elif prefixOne == networks[2]:
easygui.msgbox(mobOne + " is on the " + Otwo)
elif prefixOne == networks[3]:
easygui.msgbox(mobOne + " is on the " + Vod)
elif prefixOne != networks[0] or prefixOne != networks[1] or prefixOne != networks[2] or prefixOne != networks[3]:
easygui.msgbox(mobOne + " is not a valid network")
if prefixTwo == networks[0]:
easygui.msgbox(mobTwo + " is on the " + three)
elif prefixTwo == networks[1]:
easygui.msgbox(mobTwo + " is on the " + meteor)
elif prefixTwo == networks[2]:
easygui.msgbox(mobTwo + " is on the " + Otwo)
elif prefixTwo == networks[3]:
easygui.msgbox(mobTwo + " is on the " + Vod)
elif prefixTwo != networks[0] or prefixTwo != networks[1] or prefixTwo != networks[2] or prefixTwo != networks[3]:
easygui.msgbox(mobTwo + " is not a valid network")
if prefixThree == networks[0]:
easygui.msgbox(mobThree + " is on the " + three)
elif prefixThree == networks[1]:
easygui.msgbox(mobThree + " is on the " + meteor)
elif prefixThree == networks[2]:
easygui.msgbox(mobThree + " is on the " + Otwo)
elif prefixThree == networks[3]:
easygui.msgbox(mobThree + " is on the " + Vod)
elif prefixThree != networks[0] or prefixThree != networks[1] or prefixThree != networks[2] or prefixThree != networks[3]:
easygui.msgbox(mobThree + " is not a valid network")
RunProgram = easygui.enterbox("Would you like to enter more mobile numbers? Yes/No")
i have the programme working, but i want it shorter is there anyway 2 put the if statements into forloops, and to display the message in a single easygui.msg.box?
Edited by Roger, 20 January 2011 - 04:28 PM.


Sign In
Create Account

Back to top









