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
Python Syntax
Name of syntax
|
What it does
|
Example
|
Execute
|
Prints strings
|
print(“Hello World!!!”)
|
Hello World!!!
|
|
Prints Integers
|
print(50*90) or
print(4500)
print(‘*’ * 10)
|
4500
**********
|
|
Prints Boolean Etc.
|
print(50=50)
|
True
|
|
Prints variables
|
a = 50
print(a)
|
50
|
|
Takes input from the user
|
name = input(“Name: ”)
print(‘Hi’ + name)
|
Name: Alpha Codist
Hi Alpha Codist
|
|
Transforms numeric strings to integers
|
(1) a = “40”
print(a * 3)
(2) b= ‘20’
a =int(b)
print(a * 3)
|
(1) 404040
(2) 60
|
|
Converts to strings
|
(1) a = 40
print(a * 3)
(2) b= 20
a =str(b)
print(a * 3)
|
(1) 120
(2) 202020
|
|
For importing modules
|
Import math
|
(This imports the math module)
|
|
For comparing
|
a = 10
if (a == 10):
print('a is equal to ten')
else:
print('a is not equal to ten')
|
a is equal to ten
|
|
b = 9
if (b == 10):
print('b is equal to ten')
else:
print('b is not equal to ten')
|
b is not equal to ten
|
||
Creating loop
|
c = input("c: ")
c = int(c)
while (c < 10):
print("c is less than equal to ten")
c += 1
else:
print("c is too large")
|
c: 5
c is less than equal to ten
c is less than equal to ten
c is less than equal to ten
c is less than equal to ten
c is less than equal to ten
c is too large
|
COMMENTS