Posts

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 Update on the Calculator: Now with Parentheses

Image
This second edition of the calculator took longer than expected. Originally, I thought it was going to be some complex, but easy to implement, code. However, it came to appear almost as an impossible task. Worse, for almost a month, our professor has not had the situation where he could come to class, so for most of the time since the last post we had to work on our own. However, after several written up concepts and reviews from others students and failed attempts, I've coded up this new calculator. Here it is on Github. The prior calculator was very basic, it did less than a calculator one could get for free at a convention. The code for it was too simple, the new calculator had to be mostly remade or greatly modified at several key places. However, I did get this completed only a few days ago. The new calculator is quite close to a basic scientific calculator. It can now do order of operations. One can input several numbers and operators, and the calculator will foll

A Very Basic Calculator

Image
It's been another busy time. I've had to dealt with the holiday season and the return of college. I was also doing exploration into Pygame for a project. However, I am back and ready to program. I've got a calculator to show. With a new semester, I've got another class for programming. The professor told us we were going to start off by doing our finale project: Making a useful calculator capable of doing actions beyond what a scientific calculator can do. This is to be done in Visual Basic. For the moment, however, we were told to make a calculator capable of simple calculations such as adding or multiplication. One of those simple calculators like the basic calculator on iPhones (when not in scientific mode). This was a mildly difficult task. I had to learn some basics about how calculators work. The display was rather easy, as with most Visual Basic programs. Here is the code for it. In summary, the calculator has functions for these tasks: Display. Chan

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 with an ASCII n