Hey everyone! Hope all is well. I've created this thread to hopefully help aid those who are looking to or are currently learning Python and may need some guidance. Below I'll outline some useful programs/tips/etc to help you.
Firstly, you need to make sure you have Python installed and an IDE (a program that simulates a coding environment). Google is your friend here, below I'll name off some IDE's that you can use:
- IDLE (I personally use this for college)
- PyCharm (I hear its a favorite but never tried it)
- Visual Studio (I have it and it functions well, visually appealing to)
Once you have that taken care of, you are ready to start coding Python! But where should you start? Well that all depends on your reasoning, I started coding Python because of college but others may want it as a skill or hobby. Below I've linked some useful resources when it comes to learning Python:
https://stackoverflow.com/
https://www.w3schools.com/python/
https://www.codecademy.com/catalog/language/python
https://docs.python.org/3/
I've personally used all of these to help aid in my coding exercises/projects and understanding certain topics. Of course, Youtube has some very useful tutorials as well and I would never recommend not using them!
Now let's change pace here and say you have started coding Python, maybe you have made your first program! My first Python project was to code a program that calculated the area of a circle given any radius. Below is that code:
Code:
variable_pi = 3.14 #value of pi rounded for simplicity
variable_radius = float(input('What is the radius of the circle? ')) #input from user regarding circle radius
variable_area = (variable_pi * variable_radius **2) #area formula of a circle
print ('The area of the circle with given radius', variable_radius, 'is:', variable_area) #print statement that calls on our my radius and area variables
Now maybe this may look confusing to the beginner but this was actually extremely easy to code given Python's simple syntax. It's not like other languages where you have to focus on curly braces, etc but rather just watch your indentation and use of colons! But with that aside back to dissecting this code. You'll want to familiarize yourself with some lingo as you start coding with Python. Such as:
- Variables
- Comments
- Syntax
- Data types (strings, ints, floats)
Just to name a few and of course the ones used in my beginner Python program. Everything program in Python will have these and it's a good foundation to know what these are.
Variables: This right here is a variable. It is used to store a value of sorts, in this instance the float value of Pi.
Comments: This is a user comment. They are initiated by the '#' symbol and is just basically text not read by the program which aids the programmer/user of the program with understanding the code/program as an entity.
Code:
#input from user regarding circle radius
Syntax: Picture syntax as the grammar rules in your language. All programming languages have them and will throw a syntax error is not properly formatted. In Python, common syntax errors are forgetting to indent or put a colon on specific statements.
Data types: In Python there are multiple data types. The first 3 you'll most likely come across are strings, integers and floats. I look at strings just like text or words. They are used to build sentences, etc. Integers are whole numbers and are used for mathematical functions in a program. Lastly, floats are decimals and have the same purpose as ints do in Python, just that they aren't a whole number.
In short, these are some of the basic concepts in Python and most users will start here and work up. I myself am still a beginner but peer help has gotten me far so why not share this info here. Hope this helps someone and let me know if I missed something!