Hey Guys,
Firstly like to say this is a great forum and has helped me a great deal in regards to learling a bit about python!
But I have two programs which I require help with if possible :(
Program 1 - To search a text file for a user inputted word and display the lines in which that word occurs..
file_name = open ('test.txt', "r")
f = file_name
line = f.readline()
find_word = raw_input("Enter word to search here:")
if find_word in file_name:
print f.readline(find_word)
f.close()`
Program 2 - *To calculate entry cost to swimming pool, I'm struggling with trying to make an if statement which will result in if there is 2 adults and 3 children then the entrance cost is $15 and not sure how to deal with invaild input? *
(This is the exact specification)
"Develop a program to calculate the entrance fee to a swimming pool, given the following pricing scheme:
adults £5, concessions £3, children under 16 £2, family groups (up to two adults and 3 children) £15.
Your system should calculate the cheapest fee for a given group and** should behave in a friendly manner
if invalid input is entered."**
while loop == 1:
print "Welcome"
print "What would you like to do?:"
print " "
print "1) Calculate entrance cost"
print "2) Leave swimming centre"
print " "
choice = int(raw_input("Choose your option: ").strip())
if choice == 1:
add1 = input("Adults: ")
add2 = input("Concessions: ")
add3 = input("Children: ")
print add1, "+", add2, "+", add3, "answer=", add1 *5 + add2 *3 + add3 *2
elif choice == 2:
loop = 0
If anyone is out there that can help me it will mean a great deal and I will be very greateful!!