Exploring the Future...until we get there

Author: G2 (Page 1 of 10)

Python Tutorial # 1 (Guessing Game)

Let’s get rolling with our Python tutorials by starting off with some basic assumptions:

1) You have already installed Python on your machine.

2) You have successfully used the Integrated Development Environment (IDE) that either came with Python or that you installed separately.

3) You know how to save your Python files in some convenient place that you can access later for further editing / improvement.

Of course there are several other assumptions that we could mention, like the idea that you have a laptop, access to the internet, an actual desire to code, etc., but those first three seem like enough danger to start with (and if anyone is forcing you to code against your will, seek medical attention immediately). If one or all of the first three are not true, then go about getting yourself situated with Python before digging in here.

I’m going to skip the parts about getting Python installed on your computer, deciding which IDE to use, and all the rest. For now, we’re just going to jump in at the point where we will actually be in danger of drowning: the point where we start…to code.

In this tutorial, we’re going to code the most simplistic and monotonous guessing game perhaps ever played by anyone. I’m not staking claims to this code as my original creation. It most certainly is not. You can find variations of this game all over the web since it does a fantastic job of introducing you to some very basic Python language concepts. We will also not claim to be proud of this game’s entertainment value, and will only use it to illustrate how to get started on your way to developing better programs that do more useful stuff.

Warning! I am a beginning programmer, perhaps even more infantile in my development path than you are. Mistakes will be made, and THAT’S OKAY. Mistakes are how we learn. If you’re willing to take a turn on the coding dance floor with me, let’s just agree that we’ll have a lot of fun at the same time that we may miss a beat every now and then. If others awkwardly stare, turn a blind eye and keep coding.

As I type within my block of text, I will try to offer comments for many of the things that I discuss within this post so that you will have a pretty good idea of what I did even after you leave this blog and perhaps use this same code for your own purposes. I’m a technical writer by trade, so I’m all about helping you understand important concepts as we come to them. However, because we are learning together, all will not necessarily be revealed all the time.

Let’s get started…

First off, a couple of definitions, since they will help you to understand this content better.

Comment – #Anything that you type in Python as a comment should be preceded by a hashtag (#). This means that whatever you type after the # is useful to you and others as a reminder of what’s going on with the code. Otherwise, it is ignored by Python and does not affect the code in any way.

Variable – Oh no, sounds like Algebra! Don’t worry. Let’s restrict this definition to something very simple: a placeholder, something of your own choosing to store a value in the computer’s memory for recall later on.

HERE’S WHERE WE START CODING…

#Guessing Game (a title for our own purposes)

#Let’s create a variable called “secret_number” to represent the number to be guessed. Let’s set its value at “10.”

secret_number = 10

#Now let’s create a second variable called “player_guess” to represent the guess the player offers each time. We’ll set it to ‘0.’

player_guess = 0

#Next, we will set up a “while loop” so that, as long as the player’s guess does not equal the secret number, the indented code beneath it will run, that is until the player DOES guess the secret number. At that point, the loop ends, and so does the game.

while player_guess != secret_number:

print(“What is the secret number?”)

player_guess = int(input())

if player_guess == secret_number:

print(“Yay…You win!”)

HERE’S WHERE WE STOP CODING

In your IDE, you would type in the above code (probably without the comments, although you can certainly introduce your own to remind yourself of what’s going on with the code). Then you press a Run button or something similar to get your code to run.

If you are a beginner like me, it is VERY likely that there will be an error or two that will cause your program not to run as intended. That’s expected and absolutely okay. It doesn’t mean that you weren’t meant to code or that it’s time to seriously start thinking about a Plan B. No, it probably just means you left out a colon or something. Relax! Go back through everything and check it twice, thrice, even four times is nice.

Once you get your Guessing Game to run correctly, type in a few incorrect guesses, followed by the correct answer (in our case, it’s ’10’ but you can change the value, then play the game again as many times as you like).

Here is the sample code as it looks inside my IDE (note that the indents are important. If you removed them, you should put them back in. No, seriously put them back now!)

If this is the first time you actually created a program and it ran successfully…

I want to offer you a sincere CONGRATULATIONS! Seriously. This is an amazing feeling, right? That’s the magic of Python, and there’s a lot more where that came from.

Stay tuned. Python Tutorial #2 is coming soon. We’ll go through this same code again, but with a fine tooth comb to explain some of the elements we mostly passed over this time around. And we’ll add some cool new elements to make our game twice as exciting as it is right now. See you there!

Python Tutorials

It’s been a while. I admit it. Stating the obvious isn’t cool. But I’m back now and hoping to stay in better touch. This blog has been through a lot, which is to say…I’ve been through a lot. No need to go into the details, since many of them might be the same as the trials and tribulations you’ve also been through. If we’re talking about the same thing (and we probably are), most of them stem from that dirty, dastardly, despicable little germ – COVID.

‘Nuff said. Let’s forget about it for now and move on to more enjoyable topics, like coding.

Right around the middle of summer, while I was visiting family in Colorado, I stumbled quite unexpectedly onto what I’m daring to categorize as a new passion. I can’t explain it, and I really don’t even remember how it happened. I kept hearing about Python, so I did a little digging, watched a few videos, mucked around on a few websites, and presto, change-o, I’m learning coding – and I can’t get enough of it.

So, without further ado, here’s the deal: I’m going to start doing some tutorials for my reading audience, and possibly start a YouTube channel of my own regarding the same. Crazy? To be sure. I have no business doing such things at this point in my learning, and that’s why I will most certainly proceed, unhindered by the fact that I’m totally unqualified to go venturing into such uncharted programming waters.

Stay tuned. I’m still figuring out the best approach, but I think I’m closing in on it. Most likely, the tutorials will focus around some simple games to teach us (me included) some of the first and most basic concepts regarding the Python language. Maybe a guessing game? Quite possibly.

Short and Sweet

Hope everyone is doing well this lazy Sunday afternoon. Here in the NW FL Panhandle, we are getting a good soaking from Tropical Storm Cristobal, but not too alarmed about her doing much harm, at least not in our neck of the woods.

I have been continuing to write a great deal as a result of the Covid-19 pandemic. I’ve been among those fortunate enough to continue working from home and I’m so thankful for that. A major benefit of the down time has been the opportunity to get several of my short stories posted to my online account with Amazon’s KDP.

As a side benefit of the extra time at home, I’ve been reading back through some of my older stories (say from a decade ago, or even two in some cases) and evaluating their content from my current writing perspective.

Some of the takeaways from the time spent are described below. With effort, some of our most stubborn bad habits can be improved over time.

  1. Short words are usually better than longer ones. I know I know, it’s kind of fun to try out that word we just learned because we just love the way it rolls off the pen. By all means. But we always need to be aware of our reader and perhaps dip into the deep well of loquaciousness only once in a great while.
  2. Short sentences are usually better than longer ones. Some of mine droned on much too long. In my last post Icebergs (link below), I outlined how whittling down your writing to the bare minimum is a practice in brevity we can all stand to impose on ourselves. Whether as a writing exercise, or just as a way of keeping our content crisp, deleting or crossing through can be cathartic and energizing. It’s amazing how many words we discover are just not necessary when we are forced to prune our word garden down to the barest essentials (that whole last sentence could be stricken).
  3. Short paragraphs are usually better than long ones. It’s easy to get carried away in the moment, when the ideas are sprouting forth like new buds on the creeping vine. On and on we go. Before we know it, we have thirteen sentences all sitting snugly together in an unbroken block of intimidating text. Readers’ eyes are looking for visual breathing room moment by moment. Short paragraphs of perhaps 3-7 sentences can lend the needed space. Easier on the eye than great swaths of continuous text (“much like you see here,” he said, sarcastically).
  4. If you truly are a writer, parting ways with beauty should not scare you. What does that mean? Simply that, no matter how lovely your last sentence, your last paragraph, or even your last chapter may be, you should be unafraid to delete it decisively, knowing with conviction that it’s not the last beautiful thing you will ever write. Not by a long shot. Edit with impunity.
  5. How much time you invest in your writing may have little to do with how good your story is. If you are not investing time, effort, and possibly money in your pursuit of improving your writing, you may ultimately become frustrated by the fact that you keep hitting the same brick wall. If such is the case, ask yourself why, then chase down the remedy with conviction.

Hope that helps. Probably none of it is anything you haven’t heard a dozen times before. But seeing such pointers yet again may help them stick even better in your writing head. Don’t fall so deeply in love with words on the page if they lend little to the purpose of your story. How essential are they? What do they contribute to the setting, the theme, the plot, the forward movement? If the answer is “Nothing, but they’re so pretty,” chase them away with the backspace key. Your reader will thank you.

Writing Exercise: Open up one of your previous stories in your favorite writing software. Beginning with some logical starting point, scroll down and highlight approximately 1000 words. Copy and paste this section somewhere else where you can work on it. Challenge yourself to whittle it down to 750 words. Is it better? Is the essential meaning still there? Do you like the result? Now cut down what’s left to just 500 words. Is it still good? If so, you have just learned a valuable lesson about your own writing. Tighten it up!

Links:

Please check out my Author Page at:

www.amazon.com/author/garygunter

Icebergs

Icebergs

In the past two weeks, a couple of writing situations presented themselves to me that wound up being quite challenging to fix. And they were mirror opposites of one another. I had two stories, both good candidates for Amazon KDP, and both with length issues. The first one was too long, and the second too short. I wanted both of them to land around the 7500 mark for word count (my restrictions, of course, not Amazon’s).

In my ongoing efforts to improve my approach to writing in general, I have recently stayed focused on the principles of “Show, Don’t Tell” and the “Theory of Omission.” The two are quite related, and both came into play as part of my efforts to fix my conundrum. If you are unfamiliar with these guidelines, Wikipedia has useful topics on each, and I would encourage you to read up as a great way for improving your own writing (Iceberg Theory is Hemingway’s and the reason for this post’s title).

It didn’t take much time for me to realize that the easier of the two tasks would be adding content to the one, rather than stripping away sentences from the other. Why? Probably because it takes more effort to decide what has to be yanked out than it does to just plunk in more good stuff. So, we’re only going to talk about the pain, and not the pleasure.

An analogy might be having a garden that needs to be weeded. In some cases, it might be hard to figure out where the plants that you want to keep end, and where the weeds start. If you can picture in your mind a garden that has gotten more than a little out of hand, the idea of having to go in there and find the invaders so you can dig them out feels visually daunting.

Imagine pushing the good stuff carefully out of the way to get to those pesky weeds. Down in the dirt, sweaty, grimy, irritated, thinking about visiting the produce section more often instead of deluding yourself that organic produce grown with your own sweat and tears (maybe blood?) is the better way to go.

Okay, I’m overblowing this on purpose. The point being, if you don’t get to the weeds, you’re going to lose the garden, including the stuff you want to eat. Might as well get started.

I stared at my story, realizing that about 2000 words had to go. I vowed I would never put myself in this same situation again.

With that in mind, here are some guidelines for you to ponder, so that you can better avoid getting into this same predicament. These are offered in the form of questions that you will want to ask yourself:

  1. Have you made an outline of your story, so that you have a good idea of its beginning, its end, and most of the stuff that happens in the middle?
  2. How long do you want your story to be? Is it a short short story, short story, novelette, novella, or novel? (There are other word-count breakdowns, but those are the main ones you will likely run into.)

Those two questions are pivotal as you approach your goal of working within a semi-established story length that will (hopefully) accommodate everything you want to communicate as vital parts of your storytelling.

Going back to the garden analogy, wouldn’t it always make for a better experience if you took the time to lay your garden out? If you decided what plants would go where? If you were careful the whole time to ensure that you took everything slow, worked steadily, made sure the weeds stayed under control in the first place?

Yes, of course. But you didn’t listen to sage advice and now your vegetables are growing up and over your back fence, while also threatening to join you in the kitchen as a vine without end.

Okay, that’s it for the garden! Here’s what you do with your troublesome story, again offered in the form of questions that you will want to ask yourself:

  1. Does your story start at the right place in the overall progression of events? If it starts out too far away from the end, and this is part of your word-count problem, nudge the beginning and the ending closer together.
  2. Are you over-explaining things (telling, not showing)? If so, take the time to figure out the details that are nice, but not critical to include. Get out your paring knife and start whittling things down (that may be where the blood comes in).
  3. Is there too much dialog? Why is everyone talking so much? Is the conversation moving the story along in efficient manner? If not, tell some of your characters to shut the bleep up!
  4. How much of your iceberg is showing? (This is related to number 2 above). Don’t underestimate your reader. Hone your craft so that you give them just enough to cause an anxious turn of the page, not so much that they feel weighted down by too much description. Icebergs that are top heavy will flip unexpectedly.
  5. Even if you did have an outline of your story, it’s possible that you still went substantially over your word count. Why? Two reasons that are most likely: either there’s more to your story than you thought, and the additional words are actually vital; you’ve done too much meandering off the main path. If that’s the case, go through all the elements of the story and ask:
  • Are all my characters necessary?
  • Are all my scenes necessary?
  • Are all the places in my scenes necessary?
  • Are all my sentences as tight and succinct as they can be?
  • What have I missed? Where can I improve? Have I really dug deep? Have I really let go of all the fluff? Am I holding on to aspects of the story because of my emotional connection to them, or because they are actually crucial to the structure of my story?

Well, good news, I was able to trim the fat from my bloated short story by about 1500 words or so, and now I think it makes for better reading. I also hope not to repeat that torturous task too many times in the future. It was not fun.

Have fun in your gardens and on your keyboards and here’s to summertime writing!

Thanks!

Links to my short stories are here:

Mariazell & the Workshops of WeeBitten

Book cover
Mariazell & the Workshops of WeeBitten

Just posted the above short story up to Amazon’s Kindle Direct Publishing (KDP) yesterday. It came together really well and really fast. The only part I’m probably not thrilled about is the cover. I have not yet invested the time in acquiring that skill set to any great degree, but I’d like to think one day I might. In the meantime, KDP offers a quite rudimentary version of cover design software as part of its overall offerings, so I thought I’d go that quick and dirty route, even as I acknowledge the visual could be much stronger.

While I don’t want to give too much of the story away, I think I’m revealing little when I say that the element of snow globes plays a part in the plot. Of course, I did a small bit of research on that commodity and found that it all started with a man named Erwin Perzy, a maker of surgical instruments, who was looking for a better way to focus light in surgical lamps. Without going into the details (you can click on the link below for the Wikipedia article) his quest accidentally led him to the start of his snow globe business. Never know where your path is going to lead you.

The basilica in Mariazell was Perzy’s inspiration at the time for the model he used in his first snow globe. The more the name Mariazell stuck in my mind, the more I decided it should serve as the name for my short story’s main character (she started as Helene–not nearly as alluring).

There’s quite a bit more I could share with you about how the story began, but I don’t want to be presumptuous. I will say, however, that it falls into my personal categorization system as a Toggle Switch. If you want to understand more about that process (which I use pretty often, and it’s a little weird, and that’s why I love it), you can click the second link below to go directly to that post.

Anyway, I hope you are inspired to give my short little story, which you can get to directly by clicking the third link below.

Happy writing!

Links:

For the Wikipedia story about snow globes: https://en.wikipedia.org/wiki/Snow_globe

For the entry on this blog describing my Toggle Switches:

https://floodedplanet.com/living-on-writers-block/

To get directly to my book on Amazon:

Kindle Create

As a follow-up to my last post about Amazon’s Kindle Direct Publishing (KDP), here is what I’ve experienced so far using the free software download, Kindle Create. This is KDP’s app to assist self-publishers in getting their manuscripts uploaded quickly.

As mentioned, Kindle Create is free, and is compatible with both Windows and Apple operating systems. I won’t go into the details for downloading the application, since it’s pretty straightforward, with everything you need to do so offered right there on the KDP website. Once you are there, the marketing is pretty alluring, and is certainly what caused my own buy-in. Because I’m not very proficient in HTML as a skill set, I was happy to have this option.

Once you have the app on your desktop, you just open it up and start the process by creating a new project. This action essentially kicks off the entire process that will be necessary to complete to satisfy KDP’s requirements for a formatted manuscript. This is what is later accessed by Kindle users (or anyone with a tablet or smartphone) to purchase and read your eBook.

Overall, Kindle Create is pretty basic. There are only three themes to choose from. The HTML tools are also quite rudimentary. It was for this reason that I found some of my formatting that came with my MSWord document somewhat skewed in translation. And I wasn’t able to fix it, so I had to opt for a different, less desirable look on some pages than what I had hoped for.

One thing to keep very much in mind is the fact that text that looks correct on one platform may not look good on another. For this reason, Kindle Create allowed me to preview what each page of my eBook will look like on a phone, a tablet, and a Kindle Reader.

One nice feature I noticed in the app was its ability to provide pretty good guidance in the way of the expected front matter (table of contents, epigraph, prologue, preface, foreword, etc.), and the same, as well, on the back matter. This made it easier to figure out what to include and in what order it would most likely be organized.

All in all, the interface is similar to what I encounter on this blog using WordPress, which can be described as providing what the writer needs to communicate with the reader, if only minimally so. If that writer needs more bells and whistles, they will need to look elsewhere using some other more robust tool.

Once all text formatting and content is satisfactory, the last step is to click the Publish button. This puts everything in a proprietary format that is then uploaded to the KDP website for selection by the subscriber.

To sum up, I would say that for those who are not HTML-savvy (that’s my camp), Kindle Create provides an easy, straightforward, basic tool for getting this rather tedious and not-so-fun component of the overall e-publishing process done.

Happy writing!

KDP

Kinda Defeats the Purpose? No, certainly not. This is Kindle Direct Publishing. I’m going to share with you what’s involved in pursuing this option of self-publishing.

I don’t remember how I learned about KDP, but probably in the same way you might have…you just did. Now that I have discovered it, and have made the decision to get on with it, the choice has really lit a fire underneath my writing desk (without actually burning it down…yet).

I have finalized my manuscript for my first installment in a sci-fi trilogy, starting with the title The Falling of Metal. That, of course, prompted me to make my first attempt at the upload. It’s more involved than I had hoped, but then I should have known better. The devil is always in the details.

I’ll be the first to admit that I’m only going to be covering what has already been detailed by many others, no doubt, as they also attempted to self-publish on KDP, either blissfully happy in their success at having accomplished the feat, or still reeling from the agony of something less.

I must also admit that, were it not for the love I have in my heart for the craft of writing, I might also give up. This aint easy so far by any stretch. Hence, this effort to show you the pitfalls I have already suffered so that you won’t go a-steppin’ in ’em yourselves.

My next post will be about the Kindle Create application (free download) that facilitates the whole process of getting your manuscript into the Amazon space. In my humble opinion, a bit clunky, but overall still a pretty good way to approach it.

Stay tuned.

Redefining Blog – Again

Hello, Happy Fellow Reader / Writer. We are once again redefining what this blog is going to be moving forward. We started out with a blog that was going to be a fun place to read about all things relating to water. Then Climate Change got in the way. Then we made the shift from that horribly depressing topic to one that more fully embraced writing, with a heavy emphasis on how AI, Robotics, and advances in technology generally speaking, could give us lots of ideas for stories (sci-fi, fantasy, etc).

Now that I am in the thick of my attempt to self-publish on Amazon KDP, I find it most satisfying to share with you the trials and tribulations involved in that heady endeavor.

So…moving forward, as we always must, please look forward to enjoying future reads about my struggles, my strife, my small steps up to the top of the self-publishing mountain as we slog through the process that precedes standing on the summit of success.

Whisper in the CRISPR

It has only been a few short years since the advent of CRISPR, and one instance of ethical impropriety (the one that we know of, and-Wow!-what a doozie) in the usage of this strangely simplified process for carrying out gene editing has already occurred. There will be more. Perhaps many more.

Such overstepping is the whisper that comes along with the usage of this technology. It’s too tempting for some. Some of us cannot resist the temptation to trespass where we dare not tread. But with a new technology that is cheap to manufacture, small enough to ship without much fuss, and apparently easy enough to learn, how do we legislate our way out of the desires, the yearnings to explore, the inevitability to answer questions we never should have asked? We won’t.

This particular researcher only revealed his actions after the deed was already done, and apparently only because it was leaked before he could mount his justifications for changing the human germline in a way that simply goes beyond logical explanation. Well intentioned or not, you can’t undo that. What’s done is done. Those children are altered irrevocably. Some experts have stated that they will possibly suffer in unexpected ways as a result of this one individual’s tinkering. I would have to agree.

We, as a species, will go about addressing the possibility of other such scary prospects in the manner we always do, with big organizations full of big brains documenting all kinds of rules and regulations designed to prevent labs around the world from engaging in risky business such as this researcher undertook, doing his work in plain sight at the university that employed him.

It should work…mostly. Most people don’t want to break rules on purpose and will go out of their way to stay within the bounds of the law. But then there are those scientists, those laboratories in countries around the world, who will skim up close to the edge, feeling the excitement of daring to do something taboo. Will somebody step over the line in a big time way within the next 3-5 years? I’d put money on it.

I equate such daredevilish behavior to the driving habits of those among us on any given highway on any given day, essentially flaunting, not only the law, but good judgment, as well. All the laws on the books don’t stop them from driving like idiots, as though they were the only one on the road who counted, and everyone else being placed in danger as a result is not their problem.

So we’ll listen to that whisper in the CRISPR, so full of promise, so bursting with risk. How will the future play out? We won’t know until we get there, and we can only hope Pandora hasn’t peeked inside her box.

Original Recipe or Extra CRISPR

The idea—the dream and the nightmare—of designer babies has been with us for longer than most of us probably suspect. But the ability to act on the impulse has never been easier, thanks to a new technology known, rather comically, as CRISPR. If you haven’t encountered a news story or two regarding this cutting edge tech, I’d be quite surprised (unless you’re someone who closely follows the Kardashians, in which case you are excused…no seriously, please go…no wait, maybe the Kardashians will use CRISPR to further enhance, so…at least stay tuned).

CRISPR, in a nutshell, offers a revolutionary new tool in the world of gene modification by introducing much more precision in the manner by which a particular strand of DNA is sliced, as well as the manner in which it may be spliced, or altered with new bits of inserted DNA.

Let’s not go into the technicalities of the process, fascinating though they may be (genuinely). Let’s instead state that, aside from the obvious benefits to be realized by such a powerful addition to our arsenal of disease fighting tools, the allure of using it for more commercialized (profitable) purposes is just as obvious. Enter stage right…the designer baby.

Imaginings of designer babies (some would say the products of eugenics by a more subtle, less onerous name) have been around for at least as long as they’ve been making Ken and Barbie, and possibly as far back as say, Mengele, or the ancient Greeks. Wherever the actual truth may lie in there (I’m gonna go with the Greeks, although I’m quite sure ancient Chinese culture probably beat them to the punch somehow), human imaginings of changing each new generation in ways that evolution is simply not capable of have been hanging around since time immemorial.

Of course, as would be expected, the main focus for CRISPR is to introduce new protocols that address existing human-related diseases, such as Sickle Cell Anemia, or Huntington’s, or HIV. No doubt, this is noble and worthy work that should unquestionably be pursued.

But what about the day that surely must come, and probably sooner rather than later, when the conversations you have with your primary care physician, your gynecologist, your obstetrician take on a different character? What happens when somebody throws out the idea that there are now technologies that can greatly increase (perhaps even guarantee?) the chances that your child will be that little girl you always wanted, and that her eyes will be blue, her blonde hair slightly wavy, her height exemplary, and her IQ well above the average? And the price for such desirable traits? Not nearly as expensive as you might have thought and you can pay it off like you do your car.

So you find yourself, referral in hand, walking through the pretty stainless steel glass doorway, surrounded on all sides by beautiful people of all shapes and sizes soaring heights and lighter skin tones? They sure look pretty/handsome (godlike in proportion and structure), their complexions flawless, their crystalline eyes staring down on you, their full lips all but accusing you of taking too long to get to this point, their posted IQs all but insinuating that the decision is a no brainer. My Gawd, you utter. What’s there to think about? You can hardly believe you’ve been granted this choice…of turning yourself around and high-tailing it back through those doors before it’s too late. Original recipe is just fine by you.

Slippery slopes don’t always appear as such until a deluge has covered over the skies and the dry cracked earth turns to slick, broken bone treachery. Such is the case with technologies that blow onto the scene so quickly, with so much promise, so much potential, so much profit to be had.

Such abruptness (I think this is what they call “disruptive technologies” nowadays) prompts some concerned groups to demand that we all collectively stomp on the brakes until we can have a better look at the future. Others will tamp down any such admonishments, much preferring something that tends not to be stopped easily once set in motion, like a jet, or maybe even a rocket.

Whatever may come, it’s coming soon, and the definition of the privileged versus the deprived will take on a whole different meaning. One that accounts for, not only what you have, but also what you have become.

« Older posts

© 2021 Flooded Planet

Theme by Anders NorenUp ↑