geofferz Posted December 6, 2023 Posted December 6, 2023 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") Quote
Steve_M Posted December 6, 2023 Posted December 6, 2023 (edited) 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 December 6, 2023 by Steve_M Quote
bonio Posted December 6, 2023 Posted December 6, 2023 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. Quote
geofferz Posted December 6, 2023 Author Posted December 6, 2023 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! Quote
peepae Posted December 6, 2023 Posted December 6, 2023 47 minutes ago, geofferz said: or it doesn't work but hey, it works so I ain't touching it! This - you're already a developer. This is our motto. 2 Quote
bonio Posted December 6, 2023 Posted December 6, 2023 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. Quote
Fiddlesticks Posted December 6, 2023 Posted December 6, 2023 Nice.. Put five coders in a room and you'll get six different opinions. Here's my 2¢ - add a line for the 16 y/o who wants to ride a 50cc. Quote
Tiggie Posted December 6, 2023 Posted December 6, 2023 10 PRINT "TIGGIE RULES" 20 GOTO 10 RUN That's about all the coding I can remember 4 Quote
Bender Posted December 6, 2023 Posted December 6, 2023 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. Quote
Mawsley Posted December 6, 2023 Posted December 6, 2023 6 hours ago, Tiggie said: 10 PRINT "TIGGIE RULES" 20 GOTO 10 RUN That's about all the coding I can remember > 10 print “Mawsley is best “; > 20 goto 10 > 30 rem FIXES TIGGIE’S FORMATTING ERROR 1 Quote
Mawsley Posted December 6, 2023 Posted December 6, 2023 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. 1 Quote
Bender Posted December 6, 2023 Posted December 6, 2023 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. Quote
Mawsley Posted December 6, 2023 Posted December 6, 2023 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. 3 Quote
geofferz Posted December 6, 2023 Author Posted December 6, 2023 (edited) 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 December 6, 2023 by geofferz 1 Quote
geofferz Posted December 6, 2023 Author Posted December 6, 2023 (edited) 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 December 6, 2023 by geofferz 1 Quote
geofferz Posted December 6, 2023 Author Posted December 6, 2023 Now trying to get it hosted as an unauthenticated webapp which is proving tricky Quote
megaross Posted December 6, 2023 Posted December 6, 2023 I'm a lead dev so I'm now the guy who says things like "Back in my day we used to do manual memory management, we used to poke and peek the memory. And we didn't have stack overflow or chat gpt. We had books and IRC groups!" I hate coding though. Quote
bonio Posted December 7, 2023 Posted December 7, 2023 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. Quote
geofferz Posted December 8, 2023 Author Posted December 8, 2023 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? Quote
bonio Posted December 8, 2023 Posted December 8, 2023 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. Quote
Bender Posted December 8, 2023 Posted December 8, 2023 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. Quote
fullscreenaging Posted December 8, 2023 Posted December 8, 2023 It’s not that clever yet. From X 1 5 Quote
geofferz Posted December 8, 2023 Author Posted December 8, 2023 1 minute ago, fullscreenaging said: It’s not that clever yet. From X Haha! Love it. Quote
Essem Posted December 17, 2023 Posted December 17, 2023 Get access to GitHub copilot, it will write the code for you pretty much 1 Quote
Recommended Posts
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.