Quantcast

A community for students. Sign up today!

Here's the question you clicked on:

55 members online
  • 0 replying
  • 0 viewing

Aoxx

  • one year ago

Ok, I am trying to do a program on my own (from scratch) to try and test things I am learning through these videos. I want to be able to have multiple loops that are defined and called upon later in the program upon user input but I cant figure out how to do it or what this is even called. (function maybe?) as an example: ***Ok, so It doesnt give me enough room so I will be putting the code in a comment.***

  • This Question is Closed
  1. Aoxx
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    Num_Days = 0 ##Number of days Total_Work_Value = 0 ##Assesed value of worked hours Total_Val_Count = 0 ##Total increasing value for tracking Day1_Tickets = 0 ##Value to be looked back on for day 2 goals def Agent_Hours: Calls = float(raw_input("How many calls did you take?")) Tickets = float(raw_input("How many tickets were resolved?")) Created = float(raw_input("How many tickets did you create?")) Day1 = Calls + Tickets + Created Num_Days += 1 print "Day:",Num_Days print "Your total score for today is:",Day1 Total_Val_Count += Day1 Day1_Tickets += Tickets ##Thinking this might need to change to a variable Total_Work_Value += Day1

  2. Aoxx
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I know that there is probably a lot of mistakes in this block so PLEASE feel free to correct me (My feelings dont get hurt easy) and of course any explanation of corrects would help tons.

  3. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    "...I want to be able to have multiple loops that are defined and called upon later in the program upon user input..." This is control of flow and it is done through loops and conditional statements. They are generally tied together through different functions. For example, this is a pretty typical format for a beginner in psudocode: ``` def function(data): do stuff with data ## Main function: data = 0 print "Enter -1 to stop entering numbers" while data > -1: data = input function(data) ``` As you learn more, this changes to something more like this: ``` def function1(): while true: data = input if data is valid type return data else send error to user def function2(data): do stuff with data ## Main function: data = 0 print "Enter -1 to stop entering numbers" while data > -1: data = function1() function2(data) ``` The difference is that in the second one you are using conditional statements and perhaps even an exception handler to validate the user input.

  4. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    As for trying your code, when I paste regular text from here is all ends up on one line, so I would have to do all sorts of reformatting to get it to work and see. By putting ``` (the one on the ~) above and below on blank lines, it makes it into a formatted block that copies right. There are also code sharing sites like http://dpaste.com and http://pastebin.com . With those you can easily do even large chunks of code.

  5. Aoxx
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/1398141/

  6. Aoxx
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    http://dpaste.com/1398149/ Sorry I did see one issue and corrected it, but it still is not doing anything

  7. Aoxx
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 0

    I actually figured out what I wanted to do, thank you for your input.

  8. e.mccormick
    • one year ago
    Best Response
    You've already chosen the best response.
    Medals 1

    Good! Debugging problems is a great skill to learn.

  9. Not the answer you are looking for?
    Search for more explanations.

    • Attachments:

Ask your own question

Ask a Question
Find more explanations on OpenStudy

Your question is ready. Sign up for free to start getting answers.

spraguer (Moderator)
5 → View Detailed Profile

is replying to Can someone tell me what button the professor is hitting...

23

  • Teamwork 19 Teammate
  • Problem Solving 19 Hero
  • You have blocked this person.
  • ✔ You're a fan Checking fan status...

Thanks for being so helpful in mathematics. If you are getting quality help, make sure you spread the word about OpenStudy.

This is the testimonial you wrote.
You haven't written a testimonial for Owlfred.