Integers, Strings, Floats, Booleans, and Prints!

     Hey, welcome back to another article on python basics. If you haven't seen my previous posts, read them before this one. You actually have to unless you already have an Integrated development environment (IDE). This is post #2. In this lesson, I'll be showing you how to use integers, strings, floats, and booleans. Also, I'll show you the print statement so you can use them. First up, I will be showing you strings.

What You Can Do With This Stuff


    Strings are basically just something in quotes. So "HELLO" is a string, "I am a god" is a string, even "jdhskljfhf shnfcljk" is a string. Strings are very useful when you are telling the user something, or whatever you see in the picture above (guessing game I made, not the whole thing). Also, by quotes, I mean "double quotes" or 'single quotes'. So that basically sums up my explanation on strings. Onto the next one! In Idle, if you see something green, it is a string.

A String

    Next up is the integer. An integer is just a whole number. Like 1 is an integer, 2 in an integer, 9821730987409827094273912837409127490170928743 is an integer. Now, remember how I said anything in quotes is a string, I meant ANYTHING. "123" looks like an integer because it is a whole number, but it is in quotes, so it's a string. Integers are also useful in python because you can do calculations with them, show the number of something the user asks, and more. I used Integers in the guessing game I made, lots of them. That is my explanation on integers, and we're moving on to our next subject now.

An Integer

    Our next subject is floats. Floats are decimals. Any number with .SOME RANDOM NUMBER(S) is a float. For example, 9.8 or 2.65 in a float because they are decimals. Now, if you don't know what decimals are, I really can't help, I'm not the math teacher here! But there is a catch like the integers. 9.0 looks like it should be an integer because it equals 9, but anything with a point and a number is a float, even 0. Also, anything with just a number than a point is a float too. Like 1. is a float, 903409128304982134013. is a float. Floats can be used to show amounts of money, fractions, and more. Strings and integers are more popular, but floats are used a lot also. Now we will be moving on to our next subject, booleans.
Floats

    Booleans are True and False statements. You can use them to check if something is true or false. You can also have the program tell you if an equation is true or false. Like 3 + 3 = 7 will return false if you type that in your python shell (see post # 1). But back to the subject, booleans are very useful in python and are used in many things such as for loops and while loops (later post). The only booleans in python are True and False. The first letter of the booleans must always be capitalized. If you have IDLE, a boolean correctly typed should turn yellow/orange. That is all I have on booleans, were going on to our last subject now. Print statements. I won't add a picture because I think I explained enough on how to type it in.

    Print statements are literally one of the most used things in python other than if statements (later post). With print statements, we can use all the things I just explains. With print statements, you can type it in and tell the program to print something and when you run the program, it will print what you wanted it to in the python shell. To make a print statement, type print(). In the parenthesis, you need to put what you want to print. So if you want to print hello, type print("Hello") and save your file with ctrl/cmd+s. After that press Run>>Run Module, or press f5 to run your program. And that's it, you have just learned some of the basics of python. The next post will be the last post of python basics one and we will be moving on to python basics 2, which cover, if, else, elif, for, and while. The last post of python basics one covers operators and variables. If you learned something from this, leave a comment and check out my other posts! Thanks for reading!


Comments