programming, java, software, PHP, C programming, programming languages, visual, Pascal, Perl, XML program, UNIX, cyber program, C++, HTML, CSS, Python syntax, software, what is computer, programming, programming languages, computer programming, what is coding, what is programming, contract programming, need a programmer, cyber program, tmbmnadim, Alpha Codist, python, Alpha Codist, blogger,
Python Syntax 3- Alpha Codist |
Name of syntax | What it does | Example | Execute |
nameofliist.sort() | To sort items in ascending order | n = [1, 4, 6, 7, 9] n.sort() print(n) |
[1, 4, 6, 7, 9] |
nameofliist.reverse() | To sort items in descending order | o = [1, 4, 6, 7, 9] o.sort() o.reverse() print(o) |
[9, 7, 6, 4, 1] |
() Parenthesis | To create a tuple. It is almost the same as a list. Just you can not edit it from outside. But you can read data from outside. | print('') # for a space between line p = ("alpha codist", "Corona Attack", 6, 9, 8) # -->> p.append("Corona Attack is a game") # This returns error print(p) |
('alpha codist', 'Corona Attack', 6, 9, 8) |
def | To define a function. | def alphacodist(): print("Alpha Codist is the best...") alphacodist() |
Alpha Codist is the best... |
{} | To create a dictionary | print('') # for a space between line q = { "Easy": 5, "Normal": 10, "Hard": 15 } print(q["Easy"])
|
5 |
range() | to get a range. | print('') # for a space between line for r in range(0, 9): print(r) |
0 1 2 3 4 5 6 7 8 |
quit() | to quit code. | print("Want to quit??") quit() print("I called quit!!!") |
Want to quit?? |
return | To return something. | def alpha():
s = "Alpha Codist is the best..." return s print(alpha()) |
Alpha Codist is the best... |
COMMENTS