Aditi Pateriya
5 min readJun 21, 2021

--

python-keywords
a=1
or
int i=10
#if statement synatx 
if condition:
statement1
statement2
#program to illustrate If statement
i = 10
if(i > 15):
print ("I am greater than 15")
print ("I am Not in if")
output will be I am Not in if as 10 < 15
#if-else statement syntax
if expression :
Statement
else
Statement
#program to illustate if else
i = 10
if(i > 20):
print ("I am greater than 20")
else:
print ("I am lesser than 20")
for iterator_var in sequence:
statements(s)
#example using for statement
n = 6
for i in range(0, n):
print(i)
Output:0
1
2
3
4
5
prints numbers from 0 to n-1
while expression:
statement(s)
#example using while
i=0
while(i< 3):
i=i+ 1
print("Hello world")
for iterating_var in sequence:
for iterating_var in sequence:
statements(s)
statements(s)
#This is a single line comment 
print("Hello, World!")
#This is a comment
#in multiple
#lines
print("Hello, World!")
"""
This is a comment
in multiple
lines
"""
a #by default the string datatype 
int a #variable a is an integer data type
float a #variable a is a float data type
print('This sentence is output to the screen') #for output 
output :This sentence is output to the screen
>>> num = input('Enter a number: ')#input using prompt
Enter a number: 10
>>> num
'10'
#list syntax
list_name=[item1,item2,item3]
list = ["apple", "banana", "cherry"]
print(list)
#synatx
dict_name={key:value pairs}
Adict = {
"brand": "Ford",
"model": "Mustang",
"year": 1800
}
#syntax
tuple name=("statement")
A_tuple = ("hello")
a = "Hello, World!" #string is a collection of characters 
print(a[1])#you access each element of the array using a sqbracket.

--

--

Aditi Pateriya

A curious learner , an engineer by profession , exploring the world through writings