Jump to content

Any coders here?


geofferz
 Share

Recommended Posts

Just wrote my first ever programme! In python. Probably look somewhat inelegant

 

Might make it into a handy Web app for often asked questions. 

 

age = int(input("How old are you? "))
if age >= 24:
    print ("Direct access") 
elif age >= 21 <24:
    length = int(input("How many years have you been riding? "))
    if length >=2:
        print ("After 2 years riding on an A2 licence you can take an unrestricted DAS test")
    else:
        print ("Once you've been riding on an A2 licence for 2 years then you can do your DAS on an unresitricted bike")
elif age >=19 <21:
    print ("A2 licence")
elif age >=17 <19:
    print ("CBT")
else:
    print ("When you're 17 you can do your CBT")
 

 

Link to comment
Share on other sites

6 hours ago, geofferz said:

Just wrote my first ever programme! In python. Probably look somewhat inelegant

 

Might make it into a handy Web app for often asked questions. 

 

age = int(input("How old are you? "))
if age >= 24:
    print ("Direct access") 
elif age >= 21 <24:
    length = int(input("How many years have you been riding? "))
    if length >=2:
        print ("After 2 years riding on an A2 licence you can take an unrestricted DAS test")
    else:
        print ("Once you've been riding on an A2 licence for 2 years then you can do your DAS on an unresitricted bike")
elif age >=19 <21:
    print ("A2 licence")
elif age >=17 <19:
    print ("CBT")
else:
    print ("When you're 17 you can do your CBT")
 

 

It’s been *cough* 34 years since I last did by proper coding - though some will argue that COBOL wasn’t proper coding - excluding some Lotus Notes development) but that looks remarkably Basic like (which I only did briefly in 1983). 

Edited by Steve_M
Link to comment
Share on other sites

👍 

So your next challenge, if you accept it, is to rewrite it, so that all the logic that decides things comes first and all the print statements come at the end. 

This is called "separation of concerns". ie the bits concerned with printing should be separate from the bits concerned with deciding what to print.

Link to comment
Share on other sites

1 hour ago, bonio said:

👍 

So your next challenge, if you accept it, is to rewrite it, so that all the logic that decides things comes first and all the print statements come at the end. 

This is called "separation of concerns". ie the bits concerned with printing should be separate from the bits concerned with deciding what to print.

yeah good idea.  I also can't work out why elif age 19 has to be before 17 or it doesn't work but hey, it works so I ain't touching it! 

Link to comment
Share on other sites

I'm no python person, but I think it should be

Quote

elif 19 <= age < 21:

so it reads like it would in regular maths: "else, if 19 is less than or equal to the age, and the age is less than 21".

Same for one a couple of lines later.

Link to comment
Share on other sites

6 hours ago, Tiggie said:

10 PRINT "TIGGIE RULES"

20 GOTO 10

RUN

 

That's about all the coding I can remember :mrgreen:

 

> 10 print “Mawsley is best “;

> 20 goto 10

> 30 rem FIXES TIGGIE’S FORMATTING ERROR

  • Haha 1
Link to comment
Share on other sites

6 hours ago, Bender said:

Looks very similar to basic, I used to do 6502 machine code/assembly. I should have stuck at it 😭 yes I'm showing my age.


Coding in Assembly is an almost sexual experience imo.

 

*Yes, I’m showing my life-long inability to meet women and have actual sexual experiences.

  • Haha 1
Link to comment
Share on other sites

2 minutes ago, Mawsley said:


Coding in Assembly is an almost sexual experience imo.

 

*Yes, I’m showing my life-long inability to meet women and have actual sexual experiences.

The first little prog I made myself, all written and checked on paper first, compiled and run, hmmm that didn't work, checked and checked and then realised it was running so quickly it was just a blip, I had to put huge loops in it to slow it down, couldn't believe the speed.

Link to comment
Share on other sites

1 minute ago, Bender said:

The first little prog I made myself, all written and checked on paper first, compiled and run, hmmm that didn't work, checked and checked and then realised it was running so quickly it was just a blip, I had to put huge loops in it to slow it down, couldn't believe the speed.


Which pretty much covers my sexual technique, which is why I refer to my wife as my debugger.

  • Haha 3
Link to comment
Share on other sites

7 hours ago, bonio said:

I'm no python person, but I think it should be

so it reads like it would in regular maths: "else, if 19 is less than or equal to the age, and the age is less than 21".

Same for one a couple of lines later.

You're bang on mate - not sure how it didn't error. It now says if age <= 19 and age <21 

 

I'd forgotten my syntax layout. Or operator or whatever its called. 

 

Just trying to see how I can host it as a webapp now. 

Edited by geofferz
  • Like 1
Link to comment
Share on other sites

11 hours ago, Steve_M said:

It’s been *cough* 34 years since I last did by proper coding - though some will argue that COBOL wasn’t proper coding - excluding some Lotus Notes development) but that looks remarkably Basic like (which I only did briefly in 1983). 

I cheated and asked chat gpt to make it more elegant and it did. Current code is

 

age = int(input("How old are you? "))

if age < 16:
    print("When you're 16 you can do a CBT then ride a 50cc moped")
elif age == 16:
    print("You can ride a moped; when you're 17 you can do a CBT then ride a 125")
elif age >=17 and age <19:
    print("You can do a CBT then ride a 125 on L plates.  When you're 19 you can do an A1 course and ride a 125 with no plates")
elif age == 19:
    print("You can take your CBT and ride a 125 on L plates, or do an A1 course and ride a 125 with no plates")
elif age < 21:
    print("A2 licence")
elif age >= 24:
    print("Direct access")
else:
    length = int(input("How many years have you been riding? "))
    if length >= 2:
        print("After 2 years riding on an A2 licence, you can take an unrestricted DAS test")
    else:
        print("Once you've been riding on an A2 licence for 2 years, then you can do your DAS on an unrestricted bike")
 

 

 

Edited by geofferz
  • Like 1
Link to comment
Share on other sites

Classic ChatGPT effort @geofferz: deceptively convincing yet demonstrably wrong.

Quote

elif age == 19:
    print("You can take your CBT and ride a 125 on L plates, or do an A1 course and ride a 125 with no plates")

But if you're 19, you can take the A2 test. This is just one of the things it got wrong 🤦‍♂️.

Don't ask it to do a better job; it just apologises and comes up with a different form of wrong.

 

Link to comment
Share on other sites

On 07/12/2023 at 00:35, bonio said:

Classic ChatGPT effort @geofferz: deceptively convincing yet demonstrably wrong.

But if you're 19, you can take the A2 test. This is just one of the things it got wrong 🤦‍♂️.

Don't ask it to do a better job; it just apologises and comes up with a different form of wrong.

 

Is that not my error from the start? 

 

Good point to check though. Who was it recently who asked it a maths question and it was just wrong? Then asked it to check and it was like oh yeah sorry. Crazy, how does that happen? Calculators don't get sums wrong do they? 

Link to comment
Share on other sites

No, your code was correct, the mistake belongs to ChatGPT.

12 hours ago, geofferz said:

Crazy, how does that happen? Calculators don't get sums wrong do they? 

 

It's not a calculator. It's a machine that produces a sequence of words in a convincing order. But it's not checking itself to see if the words describe the real world (or the real rules of maths) or not. Ask it how to get from Aldgate East to Turnham Green and chances are it will come up with nonsense. Ask it to write a sci fi novel, and it will perform brilliantly. Oddly, it's those tasks that we consider to be truly human - creative, imaginative tasks - that it does really well at. Tasks we think computers should do well at - computation, navigation - it is embarrassing bad at.

 

 

Link to comment
Share on other sites

13 hours ago, geofferz said:

Is that not my error from the start? 

 

Good point to check though. Who was it recently who asked it a maths question and it was just wrong? Then asked it to check and it was like oh yeah sorry. Crazy, how does that happen? Calculators don't get sums wrong do they? 

Made by humans that's the problem 😂

 

Remember pentium CPU's ? Some clever geek worked out that if you gave it really complicated maths to do it went  wrong, there was a bug in the floating point unit. Missing data in the lookup tables led to the algorithm winging it 😂

 

Sounds like nothing has changed.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

  • Welcome to The Motorbike Forum.

    Sign in or register an account to join in.

×
×
  • Create New...

Important Information

Terms of Use Privacy Policy Guidelines We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.

Please Sign In or Sign Up