Learn python by creating a simple CATculator
A computer program that calculates your cat's age in human years.
What is a CATculator?
A CATculator as I like to call it is a computer program that converts your cat's age to human age.
Let's get started.....
Pseudocode
If you're new to coding, the term pseudocode will probably look confusing to you. However, there's nothing to be worried about because I'm going to explain it to you as I would to a five-year-old.
What is a pseudo code?
Pseudocode(Algorithm), describes the specific steps that your computer needs to follow to achieve the desired result. Pseudocode is written in plain English, that's the reason why it is so important before writing your computer program.
CATculator pseudo code
Step1 - Ask the user for the Cat's name
Step2 - Ask the user for the Cat's age
Step3 - Multiply the Cat's age by the number fifteen(15) to get the cat's age in human years
Output to the user - "Your Cat" cat_name "is" cat_age "years old in human years".
The main reason for this article is to Learn python and improve your programming skills by building a computer program. So I will be discussing some basic python keywords that we'll use in this project. Let's dive right in.....
Variable or Vary-able?
A variable in programming is a value that can change depending on conditions or information passed to the program. Maybe it should have been called vary-able after all. An example of a variable in python is;
#Example of a variable
cat_name = 'Lily'
Input(), print() and int() function .
In python, an input function is used to get input from the user.
# Python input() function Example
cat_age = input("What is your cat's age? ")
A print() function on the other hand is used to output data on the screen.
# Python print() function Example
Print('cat_age')
The int() function converts a specified value into an integer number. The int() function converts a string to an integer
# python int() function Example
int('100')
output:
100
Source code for CATculator
# code for CATculator
cat_name = input("what is your cat's name? ")
cat_age = input("what is your cat's age? ")
human_age = int(cat_age) * 15
print("Your cat", cat_name, "is", human_age, "Years old in human years.")
Conclusion
If the steps above were followed correctly, Congrats you just built a CATculator๐. The main goal for me in writing this article is to make you grasp programming keywords easily. I will be writing more articles not only on python but on other programming languages....and trust me you don't want to miss out. Follow me for more_Thank you๐.