My Favorite programming language: Python
![the-actual-symbol-of-the-Python-programming-language-in-front-of-lines-of-code-300x200.jpg](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmQn6PnH7u52UZdbe6UvpC2A4kEiwWUHnMbf54hupz4VqM/the-actual-symbol-of-the-Python-programming-language-in-front-of-lines-of-code-300x200.jpg)
image source
![cyxkEVqiiLy2ofdgrJNxeZC3WCHPBwR7MjUDzY4kBNr81LetETmuDWKvqCPmaSADqzr7cvw5uMJgEuBeuvuxazYG8zoQXWgA6qkN5Yo32DcRzka1VLsrb2BJSkBrF9yjpHU.png](https://steemitimages.com/640x0/https://cdn.steemitimages.com/DQmRDGakkjKoaVympAAufuzPBV4RV5JAPaBNHW5UvyKR6qr/cyxkEVqiiLy2ofdgrJNxeZC3WCHPBwR7MjUDzY4kBNr81LetETmuDWKvqCPmaSADqzr7cvw5uMJgEuBeuvuxazYG8zoQXWgA6qkN5Yo32DcRzka1VLsrb2BJSkBrF9yjpHU.png)
Good day steemians, I am overjoyed for being able to take part of this contest organized by @zerotoinfinity community. It is an opportunity for me as a computer science student to take part as programming is part of the core courses I am doing. In fact, there are many programming languages. Few of such are; Java, Python, Javascript, C++, C#, CSS, Php, ruby, etc.
All the programming languages have its unique syntax that makes it differ from other programming languages. With regarding to the syntaxes, I chose python as my favorite programming language.
Why is python my favorite programming language?
Python is a very simple language which is very straight forward syntax. It was created by Guido Van Rossum and was initially invented in 1989. The latest version of python is currently python 3. Python enables programmers to program without boilerplate code
Python is very identifiable and hence makes it a powerful programming language. This programming language is widely used in Artificial intelligence, Neural networks, natural language Generation and other advanced fields of Computer science. Below are the standard data types in python
- Numbers
- String
- List
- Tuple
- Dictionary
Numbers
Python is capable of supporting four types of numbers .These are float, integer, complex and long
Integer(int): numbers which has no decimal.
Eg.
myint = 4
Float: Numbers which has a decimal point.
Eg.
myfloat = 4.0
Complex: numbers which has imaginary values. Eg 3.14j
long: Eg 1343142L
String
Strings must be in either single qoute or double quote.
Eg.
mystring = 'Hello'
mystring = "Hello"
List
List are one of the most versatile in python. A list consist of items which are separated by commas and are enclosed by square brackets [ ]. Values that are stored in a list can be access using ( [ ] and [ : ] ) with zero(0) being the beginning of the list and working their way to -1 as an end.
For example
list= [ 'abcd', '201', '1.52', 'John' ]
print(list)
print(list[0])
print(list[1:3])
print(list[2:])
This is the result
Tuples
Tuple is another data type which is similar to list. The items in tuples too are separated by commas. The main difference between tuple and list is that; list are enclosed within brackets[ ] and elements in it can be altered, whilst elements in tuples are enclosed in parentheses() and can not be Change.
Dictionary
Unlike list and tuple, dictionary elements are kept in curly brackets{ }
Eg.
Person = { " first_name": "bravo3", " last_name": "Joseph"}
The relsult
Some basic arithmetic in python
Operator | Description | Example |
---|---|---|
+ | Addition | 5+3 |
- | subtraction | 5-3 |
* | Multiplication | 5*3 |
/ | Division | 5/3 |
** | exponentiation | 5**3 |
% | Remainder | 5%3 |
// | floor division | 5//3 |
Functions
Functions are built to structure programs. Most programming languages recognize functions. Below are few functions which can use to format data data which can be altered in python.
append() method: this is use to add a list to another list.
Eg.
list= [ 'abcd', '201', '1.52', 'John' ]
list2 = [ 10, 'bravo3' ]
list.append(list2)
print(list)
This will output
Getting the length of a list
We can get the length of list using len() method
Eg.
list= [ 'abcd', '201', '1.52', 'John' ]
print(len(list))
The output will be:
We can also add or remove item into and from a list.
Eg.
list= [ 'abcd', '201', '1.52', 'John' ]
list.pop() # removes the last value in the list
print(list)
The result
Note: comment does not execute by python. We write single line comment in our codes by starting it with # follow by the comment statement.
Multiple line comment is done by either writing it between single triple quote(''' )or double triple quote.(""")
Python also takes input from the user using the syntax input()
Eg.
source code
result
I entered my name
Below are aspects you can use the knowledge of python for;
- Data Science
- Web development
- Machine learning
- Scripting
And many more
Conclusion
Python as a programming language whch contains simple syntaxes for easy understanding. There are many statement in python which is not include here, but I hope with this, you would get to know that python is a great programmable language one must learn if targeted of being one of the careers mentioned in the content already. My final regards goes to @zero-to-infinity for this great contest.
Nice to read your post .
Keep posting and stay with our community.
Thank you
You are very welcomed moderator