Skip to content

Latest commit

 

History

History
30 lines (25 loc) · 1.03 KB

week9_readme.md

File metadata and controls

30 lines (25 loc) · 1.03 KB

WEEK 9

DAY 12 | 3 October | 12. Python 3 API and CGI

Summary

  • For loop can make iterations with in the range (with being mentioning the range)
x = [1,2,3,4,5]
for i in x:
    x = i * i
    print(x)
  • In python List comprehension can utilize conditional statements to modify existing list or tuple and can store the modify values another list/tuple which creates statements in one line only and makes more readable and efficient
x = [1,2,3,4,5]
y=[i*i for i in x]
y

# o/p: [1, 4, 9, 16, 25]
  • Function is a set of statements executed when the function call until it is not perform any operations.
  • To define the function can use def keyword before the function name
def iiec():
	print("hi")
iiec()
  • Parentheses used in the function to call the function to perform the operation in the block of code in function.