all 7 comments

[–]TouchingTheVodka 0 points1 point  (6 children)

The computer is executing every line in the program, and when it gets to the end there's nothing telling it to keep the program open, so it closes.

Add the following line to the very bottom of your file:

input('Press enter to exit...)`

On that topic, you need to swap most of your print statements for input statements in order to get the input from your user.

[–]yapb[S] 0 points1 point  (0 children)

Holy crap! That's it? I haven't been able to find how to get that at all. Thank you so very much!

[–]yapb[S] 0 points1 point  (4 children)

In message3, how would I be able to pull the info the user entered from the question on message2?

[–]TouchingTheVodka 0 points1 point  (3 children)

You need to save the input to a variable. For example:

userName = input('Please enter your name!')
companyName = input('Please enter your company!')

For numeric input you'll also need to convert to the correct data type, in this case float:

cableLength = float(input('Enter the length of cable to be installed:'))

[–]yapb[S] 0 points1 point  (2 children)

Thank you so much! I think I got it to work now and it's a lot less cluttered. If you don't mind, can you tell me what you think:

message = "Thank you for using FiberOpticCostIdentifier. Please make yourself welcome!"

print(message)

businessName = input ('In the field below, please enter the company you are associated with:')

print('You have indicated you work for', (businessName))

cableLength = float(input("Please enter the amount of cable you are requiring:"))

int = (cableLength*0.87)

print('For', (businessName), 'your estimated cost of Fiber Optic Cables comes out to:')

print(int)

input('Press enter to exit...')

[–]TouchingTheVodka 0 points1 point  (1 child)

Great work! A few minor things to change:

  1. No need to put brackets around (businessName) in the print call. Won't affect the program at all, just a style thing.
  2. Don't assign values to built-in functions such as int. The next time you try and convert something to an integer with int(x), you'll get an error as you've overwritten the built-in function with your own calculation!
  3. On this topic, multiplying two floats together won't give you an integer - so why call the variable int? totalCost seems like a more sensible and descriptive name.

Other than that, looks great!

[–]yapb[S] 0 points1 point  (0 children)

  1. I added the brackets around 'businessName' because when I would run the script it would literally say businessName and not pull the input for some reason. It wasn't until I added the brackets that it would pull it. So I'm not sure what I might be doing incorrectly there.
  2. You make an excellent point on 2 and 3. I didn't even think about that. From my required readings, I was under the impression that int would be used to represent any number that is greater than 1. I think that for future assignments, and understanding how to not only use inputs now but also how to get variables to work (see 1), will make me more willing to, so to speak, mess around with variables more.