Information about cookies on this page

Our website uses cookies to ensure the functionality of the website, to collect and analyze information about the performance and usage of the website. Privacy Policy

  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in
  
  • Courses
    • Discord
    • Twitter
    • Linkedin
    • Facebook
    • Instagram
  • Pricing
  • English
  • Čeština
  • Deutsch
  • Русский
Sign inStart free
  • Courses
  • Pricing

Community

Sign in

A New Chat

Building a program in small steps makes for a long chat: the plan, a piece, a run, the next piece, a change. Every message stays in the chat, and so does every version of the program in it: the one you attached at the start and each piece the assistant wrote since. What the chat doesn't have is what you changed in the editor yourself without attaching the program again.

Say you built Mia's report in one chat, as in the exercises before. After the discount, Mia tried out a price of £7 a started half hour for a week, and you changed walk_price() yourself, without attaching the program again. Then, in the same chat, you asked for the longest walk, said that the rest should stay as it was, and asked for the whole program. One answer began:

Here is the whole program with longest_walk added and a "Longest:" line at the end of print_report:

def walk_price(minutes):
    half_hours = minutes // 30
    if minutes % 30 > 0:
        half_hours = half_hours + 1
    return half_hours * 6

That's the old price. The assistant left the rest as it was, as you asked, but as it was in the chat, not in your editor. Pasted in, the program would charge £6 again. The other answers in that chat brought the old price back too.

In a short chat, attaching the program again after you change it is enough, as in Finding Mistakes with AI. When a chat has grown long, with many versions of the program in it, start a new one with New chat. Attach the program as it is now and say in a sentence what it does: the assistant then works from your program and nothing else. The chat in this exercise is new, and the program in the editor is the report with the week's price of £7.

Instructions

  1. 1

    Attach script.py and say in a sentence what the program does. Ask for the next piece: a function longest_walk(walks) that returns the longest walk, and a line at the end of print_report() that prints it after Longest:. Say that the rest stays as it is, and ask for the whole program, so that you can paste it in one go. Then send it.

  2. 2

    Copy the program from the answer and paste it into the editor in place of yours. Run it: the report has a new last line, Longest: 60, and the total is Total: 51: at £7 a started half hour, the walks cost 56, less the £5 off.

Back

5/7

  1. 1. A Plan Before Code
  2. 2. One Piece at a Time
  3. 3. Quiz: The Piece Just Added
  4. 4. Leave the Rest as It Is
  5. 5. A New Chat
  6. 6. Quiz: A Long Chat
  7. 7. Summary
Next

Start programming for free

By signing up, you agree to the Terms of Service and Privacy Policy.

Or sign up with: