Technology Round 3: Python

Python is ranked as the third most popular programming language based on hackernoon.com in 2018. It is used in a wide range of tasks such as but not limited to: :

  • Web development
  • Software development
  • Data analysis
  • Machine learning
  • Network programming
  • Etc……….

 

Boolean

Comparisons a = 4, b = 8, c = 10
– a == a : True
– a < b: True
– a != a: False
– b <= c: True

If statement

a = 40
b = 267
if b > a:
print(“b is greater than a”)

Indentation
a = 42
b = 200
if b > a:
     print(“b is greater than a”)

Elif statement( Elif = Else if)

a = 4
b= 4
if b > a:
     print(“b is greater than a”)
elif a == b:
     print(“a and b are equal”)

Else statement

a = 250
b = 50
if b > a:
      print(‘b is greater than a”)
elif a == b:
      print(“a and b are equal”)
else:
     print(“a is greater than b”)

Loops

for i in ‘Python’:

print ‘My code :’, i

 

My code : p

My code : y

My code : t

My code : h

My code : o

My code : n

 

List:

supplies = [‘pen’, ‘apple’, ‘mango’]

for supply in supplies:

print ‘Current supply :’, supply

 

Current supply :pen

Current supply :book

Current supply :mango

 

Break statement:

fruits = [‘mango’, ‘grape’, ‘orange’]

for x in fruits:

print (x)

if x == ‘grape’

break

 

mango

grape

 

Range function:

for x in range(5):

print(x)

 

0

1

2

3

4

 

Leave a Reply

Your email address will not be published. Required fields are marked *