Posts

Showing posts with the label Python

Finding Fibonacci Numbers

Image
Hello, I know this has been a while since my prior post and I have not gotten out any video yet doing a tutorial on a program I did. I have been having a busy week at university and I've been rather skeptical on the program I was originally going to use for the tutorial, as it's overly complicated for its results. I may actually use this program for my tutorial as it would be easier to explain and is less complicated. For now I'll continue with this program. You may find the program here on Github. I guess I won't have to give much explanation on the Fibonacci sequence. Basically, it's a sequence where a term is the sum of the two prior terms. This program, when inputted a number n, will return the nth term in the Fibonacci sequence. It works by making the a list of all terms within the Fibonacci sequence from 0 to n and returning the last item in the list.  As its does the regular method, it works accurately for even large numbers and should work up to the lim...

Counting Palindromes with a Certain Ending & an Announcement

Hello. With this small program comes a large, important update. I shall talk about it right after going over this small program. The Program In relations to the prior post about a program finding the next program. I have been tasked to make a program where it must find how many palindromes with a certain length exist with a certain ending. It turned out to be an easy task and I was able to code up the program in an afternoon. You can find it here on github. The programs simply requests from the user a number to serve as the ending of a palindrome and a number serving as the length of the numbers being looked at. After getting two valid integers for both, by making sure they are positive integers, the program then does the following equation: z = roundup(length of numbers being looked at / 2) - length of first inputted number If z is greater than or equal to 0, the program will return 10^z . Otherwise, it will return 0. For instance, let's find the amount of palind...

Finding the next Palindrome

Image
Hello, here's a quick post I'm making for a simple program. There will likely be another as my professor is currently making me do more basic programs at this point instead of a more major project like the calculator. This programs does one task: when given a number, it will find the next palindrome after the number. You can find it here on github . It does some other tasks as well such as validating if the input was a number and making sure the number can be turned into an integer. The finding of the next palindrome is done by checking the first half of the number and comparing its reverse to the latter half of the number. If the reversed first half is larger than the latter half, the output will just be the first half combined with the latter half being the reversed first half. In odd length numbers, the middle number is increased by 1.  If the reversed first half is smaller than or equal to the latter half, the output will be the first half plus 1 and the rever...

A Text Replacing Program

Wow. As the calculator is put to the back burner for the moment, I've gotten time to work on other programs and get a post out at a decent time. Hopefully I'll be able to keep this up. The class has been tasked to write a conditional character replacement program. The objective is to replace characters in a text file which aren't in specific words or adjacent to specific characters. This was apparently a difficult task for many, even myself. However, with some review from the other classmates in the class, I've created a method for replacing a certain character under specific conditions. The program can be found here on github. The program works basically in the following way: Text is inputted from a file. Each line of text in the file is to put into a list as an item. The restricted words, restricted characters, the character to be replaced, and the character to replace, are inputted by the user within the console. The user can input multiple restricted words an...

An Encryption And Decryption Program

It's back to the schedule, so here's my latest creation . A python program that does encryption and decryption in both the Caesar Cipher and the Vigenère Cipher. When given a message with a key, the program shall input the two into an encryption function which will return the encrypted message unless there are errors. For show, the encrypted message is outputted to the console and then placed into the decryption function along with its key, which returns the message decrypted. The Caesar Cipher does the following: Get the message and key Validate message and key  Make sure the message is a string made up of ASCII characters (and only visible ones; the ones from char 33 to 126) and the key is an integer  Print to console the problems and stop if validation fails For every letter in the message  Get the current letter and its ASCII number  If the ASCII number of the current letter plus the key is above 126  Add to the output string the character...

An algorithm to set text in files to arrays

Image
This post took a little too long to get out. It has been a busy week. Every class I had required me to either write an essay or take a test. I have also started to do some multiplayer HOI4 games with friends.Thus I did not have time to write up this post. At least it is still less than two weeks since the last post. Regardless, here is something I have made that was not a computer science project. With my work in the prior post about prime factorization, I used some of Python's functions to get a list of prime numbers from a text file. This led me to try some things further with the reading/writing functions. This is a simple function that takes lines from a text file and puts them into lists. You can find it here on Github . The following is the basic steps: Check to see what tag is the current line. The line with a tag is indicated by it starting with a hashtag Add all lines to the list related to that tag until the current line is a tag  Check to see what tag is the...

A Prime Factorization Algorithm that Uses a Text File

Image
A post that is at least within two week of the last one? This will hopefully be the new norm. I was about to get this out two days prior, but Github had some issues when I was about to upload it on the first day. I got this uploaded to Github the yesterday, but it was late, so I didn't make a post. Nevertheless, it's time to talk about this code. I have created a python program that shall do prime factorization when given an integer. You can find it here on Github .  The Background So this is another program requested by my computer science teacher. He demanded a program that would be given a number and return the prime factors of it along with how many times each was used (and specifically in the order you see in the program's output). Initially, I though this was an easy program. There's a rule I've known since middle school on how to prime factorize: Start by dividing the number by 2 for as many times possible When you can no longer divide by 2, div...

A Quadratic Equation Solver & What I have been doing.

Image
  Indeed. It has been a long time. Right here I got a code for solving a quadratic equation. I'll get to that in a moment after I talk about why I have not been posting much to here. So when I starting posting in late 2017 and early 2018, there wasn't much I had to show. All I had were some previous works done for a class along with a very simple idle game. The main reason I stopped posting was there were nothing interesting to tell about. I was also not in a position to do much more, I had to do some intense studying for the rest of the school year. It also wasn't until the second semester of last year that my computer science class got into coding, and even then it was super simple stuff. My computer was in a rather problematic state. There was not enough memory for engines and was getting slow. Things have changed since then. I have gotten a new laptop that can do way more than what my old computer can. Thus, I can now use engines like Unity or Unreal witho...

Aesthetico Ultimate Designer - A Python Turtle Program

Image
In the last post on my previous work, I tried to use a program I made in my Python class. It used the Turtle module to make lines. However, it seems that I forgot to save the code for that (and I didn't have a Repl account back then). So I just put something else up instead.  Over December, I've tried to remake that program I once made before on REPL . This is the best thing I could recreate, since I did not have anything to build upon other than the memory of it.  It's a simple program. It will ask which direction and degree the line should turn to. It then asks what type of line to make, and then it creates the line. You can continue on and create more lines, or simply end it.  I tried to keep up this somewhat professional and Aesthetic look back when I first made it long ago. I used colours from an Aesthetic colour pallet, and I had every word between dashes. I will say, it somewhat looks cool.   I will say, however, that this remake is n...

Previous Works - A Loop Drawing

Image
Unfortunately, I did not get much done over the past few days. My houses wi-fi was performing too badly to work, was down for some days, and I had to study for semester exams. However, I've also been spending too much time on strategy games recently. Thereby, I will be showing another previous work . This is a Python program I made this year for a class I took. The main program is not much more than the turtle designing. I got quite interested in making circles, which could be seen.The name Droopy doesn't have much story to it. During the time I was making this, I was listening to music by C418. Three of his songs refer to a "Droopy," which is where I got the name from. The next post will definately be about the idle game with advancements I made in there. After that, I may put that program on the backburner and do something else.