I have begun the exciting journey of learning my first language post-bootcamp: Python! A senior engineer friend of mine once described learning new coding languages as “more like learning a new accent rather than an entire language” and so far I completely agree. There are more similarities then differences: variables work the same, there are the same data types (strings, integers, booleans, floats, etc.), string interpolation works the same…the list goes on and on. Once you understand the basic foundation of one language, the next one comes to you much more quickly and easily.
1. Print instead of console.log
Need to print something to the console? No more console.logs; simply type the command print() with whatever you wanted printed inside the parentheses.
print("Hello World") # Hello World
P.S. Want to comment out code in Python? Simply use the pound/hash sign (#), just like with Ruby.
2. Using Different Quotations in Strings is Crucial
Using quotes inside a string? Make sure to use different quotations (for example, single quotes and double quotes) so the computer can properly understand what needs to be printed.
3. Use Underscores for Large Integers
If you have a very large integer that you would usually separate with commas, you can use underscores for better readability. Simply place them wherever you would normally place commas, like so:
large_int = 123_456_789
another_large_int = 1_000_000
large_int is the same as writing 123,456,789.
another_large_int is the same as writing 1,000,000. The computer ignores the underscores, but it is extremely helpful for human eyes when trying to read large numbers.
4. Booleans begin with capitals.
true_boolean = True
false_boolean = False
5. Division always returns a float.
print(10 / 5) # 2.0
Characteristics like this are the reason why Python is a great choice when building applications that require a lot of math.
These are my main takeaways from learning just a couple of different Python methods and being introduced to Python data types. I have been really enjoying learning Python through Dr. Angela Yu’s Python course on Udemy, which you can check out here. As always, the Python documentation is also a great place to dig deeper. Happy coding!