Kaja Blackwing avatar

A Noob's Adventures in Coding: Chat Bot

steampunkkaja

Published: 30 Jan 2023 › Updated: 30 Jan 2023A Noob's Adventures in Coding: Chat Bot

A Noob's Adventures in Coding: Chat Bot

I'm new to Python, so this took over an hour of trial and error to get right, and since my knowledge of technical Russian is extremely lacking, I'm not going to write in my usual bilingual format. Anyway, I thought I might share this little adventure. The first step was to program a computer to process inputs. This is a simple function:

image.png

Note that these are lines 4 and 5. That's because this simple operation is part of a larger program that I wrote around the input exercise. This is the beginnings of a chat bot:

image.png

This is a very simple Python program, I think we can all agree. However, when I decided to write a Russian version (I am making literal Russian bots!), the program more than doubled in size from 19 lines to 55 and contains not one, but two nested while loops! The reason has to do with a quirk of Russian grammar. If you can't figure it out from looking at the code, let me know, and I'll happily explain.

image.png
image.png

Actually, I need to explain anyway, because in order to write a while loop that did what I wanted (reporting the value of the ones place in any given integer), I experimented with a separate program to see if I could get the computer to do what I want, and then copy and paste the relevant code blocks into the chat program. This is what I came up with:

image.png

The extra "print" commands are in there to show me that the program is performing the correct calculations. This is the output, from an input of 59:

image.png

Once I have that value, I can assign a grammar variable to it, which will alter the chat bot's output accordingly. I'm sure there's a more efficient way to do this, but I haven't gotten to that point yet. As of this post, I have been playing around with Python for exactly one week, so I don't really know what I'm doing. Granted, this isn't my first programming language (that would be industrial g-code), so I'm not completely new to coding.

Oh, I guess I should show you Kaja-bot's output!

image.png

Anyway, I had fun. What do you think? Am I right to find this mildly humourous, or am I just needlessly giddy from staring at a screen for too long?

Leave A Noob's Adventures in Coding: Chat Bot to:

Written by

2D and 3D artist, toymaker, engineer, history buff, scifi/fantasy writer, chicken farmer, arachnophile and all-around nature lover, hunter of deer and mushrooms.

Read more #coding posts


Best Posts From Kaja Blackwing

We have not curated any of steampunkkaja's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.

More Posts From Kaja Blackwing