Functions and a lot more!

def function_name(parameters):
"""docstring"""
statement(s)
#function to print an odd or even no.
def
evenOdd(x):
if (x % 2 == 0):print "even"else:print "odd"
#to call the above function 
evenOdd(4)
output: even
#importing  module calc.pyimport calc
print(add(10, 2))
from fib import fibonacci
newlist = [expression for item in iterable if condition == True]
colors = ["pink", "blue", "crimson", "green", "magenta"]

newlist = [x for x in colors if "m" in x]

print(newlist)
mytuple = ("apple", "banana", "cherry")
myit = iter(mytuple)

print(next(myit))
print(next(myit))
print(next(myit))
mytuple = (“apple”, “banana”, “cherry”)for x in mytuple:
print(x)
def mygenerator():
print('First item')
yield 10

print('Second item')
yield 20

print('Last item')
yield 30

--

--

--

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

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

KWoC’ 18 | Project Report

What Should a PostgreSQL Migrator do?

Test Design of native app automation

5 Important Data Structures in Javascript

GraphQL versus REST

How to move large MySQL Database from one server to another ?

Salesforce — Introductory Guide

Debunking the FUD about data version control implementations

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Aditi Pateriya

Aditi Pateriya

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

More from Medium

5 Reasons Why You Should Open a Micro-savings Account

Solving the problem of induction

“Common Project Risks and Agile Mitigations, Part 7, Everything Else” from an Old Blog

CS373 Spring 2022: Alexander Han