Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
21 views
3 pages
Lab - Week 5 (2021)
İTÜ BIL100E notları
Uploaded by
erdemsimsek234
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Lab_Week 5 (2021) For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
0 ratings
0% found this document useful (0 votes)
21 views
3 pages
Lab - Week 5 (2021)
İTÜ BIL100E notları
Uploaded by
erdemsimsek234
AI-enhanced title
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Lab_Week 5 (2021) For Later
0%
0% found this document useful, undefined
0%
, undefined
Embed
Share
Print
Report
Download now
Download
You are on page 1
/ 3
Search
Fullscreen
Functions Int lab session, you are going to learn; © Value-returning functions, includin Writing value-returning functions Using value-returning functions ©. Functions returning multiple values © Using library functions and the import statement © Modules, including: © The random and math modules ‘© Grouping your own functions in modules 1) Consider following statements and see the results # Function definition def myprint(s1, print(st) 4 Function call myprint(“Barcelona") myprint("Real Madrid”) # Addition def Fun (x,y): result = x+y return result print(Fun(5,3))2) _ Inthe following example, argument is being passed by reference and the reference is being overwritten inside the called function. # pass by reference exanple def ChangeRefer(mylist): mylist = [1,2,3,4] # This assigns a new reference print("First Values : ", mylist) # Now call ChangeRefer function mylist = (1@,20,3@] ChangeRefer( mylist ) print("Secondary Values : ", mylist) # default parameters def printinfo( name, age = 23 ): print("Name: ", name) print("Age: ", age) # Now call printinfo function printinfo( age=19, name="Tasmanian Devil” ) printinfo( nane="Bugs Bunny" ) 3) A. Consider following example about import statement and random number generation. See the results. Seize the difference from random import randint #randint is a function print(randint(@, 100)) import random #random is a module print(random.randint(@,109)) B, Generating random numbers with different ways. See the results.randrange function import random # Select an even number in 160 <= number < 100 print("randrange(100, 1090, 2) : ", random.randrange(100, 1000, 2)) # Select another number in 100 <= number < 1000 print("randrange(102, 102, 3) : ", random.randrange(10@, 1000, 3)) # uniform function print ("Random Float uniform(18, 81) : ", random.uniform(18, 81)) print ("Random Float uniform(19, 38) : ", random.uniform(19, 38)) 4) Consider following statements about using functions for different goals. See the results. # List of directory locations import sys print(sys.path) # how to print pi from math import pi print(pi) # Function that defines an area of a circle import math def area_of_circle(r): arta * math.pi return a print(area_of_circle(3))
You might also like
Chapter-2 Function
PDF
100% (1)
Chapter-2 Function
40 pages
Functions:: Python Programming Unit-4
PDF
No ratings yet
Functions:: Python Programming Unit-4
18 pages
Python Notes
PDF
No ratings yet
Python Notes
50 pages
Python Unit3
PDF
No ratings yet
Python Unit3
28 pages
Functions UDF 2
PDF
No ratings yet
Functions UDF 2
54 pages
CS (XII) Ch-2 Functions Notes
PDF
No ratings yet
CS (XII) Ch-2 Functions Notes
50 pages
Unit 4
PDF
No ratings yet
Unit 4
70 pages
Unit Ii
PDF
No ratings yet
Unit Ii
82 pages
Python Unit 2
PDF
No ratings yet
Python Unit 2
45 pages
PPS Unit 3
PDF
No ratings yet
PPS Unit 3
50 pages
Computer
PDF
No ratings yet
Computer
35 pages
Code Reusability
PDF
No ratings yet
Code Reusability
33 pages
Chapter 6 Function - Combined
PDF
No ratings yet
Chapter 6 Function - Combined
44 pages
FoP Ch03 Functions
PDF
No ratings yet
FoP Ch03 Functions
44 pages
Python
PDF
No ratings yet
Python
23 pages
CH 3 Function
PDF
No ratings yet
CH 3 Function
31 pages
Notes
PDF
No ratings yet
Notes
20 pages
Xii Cs Function Notes
PDF
No ratings yet
Xii Cs Function Notes
46 pages
Unit 3
PDF
No ratings yet
Unit 3
29 pages
Functions 2
PDF
No ratings yet
Functions 2
31 pages
Functions
PDF
No ratings yet
Functions
30 pages
Unit - II Python Notes
PDF
No ratings yet
Unit - II Python Notes
28 pages
Python Functions
PDF
No ratings yet
Python Functions
20 pages
PY Mod 2
PDF
No ratings yet
PY Mod 2
16 pages
Functions-Builtin & Function Defined in Modules
PDF
No ratings yet
Functions-Builtin & Function Defined in Modules
20 pages
02 Functions
PDF
No ratings yet
02 Functions
10 pages
Functionnnn
PDF
No ratings yet
Functionnnn
21 pages
Lec3 Func Module Files
PDF
No ratings yet
Lec3 Func Module Files
40 pages
18mit14c U2
PDF
No ratings yet
18mit14c U2
24 pages
UIS 20200504 Classwork 62832 1
PDF
No ratings yet
UIS 20200504 Classwork 62832 1
10 pages
Exploring Python Functions Reading - Functions
PDF
No ratings yet
Exploring Python Functions Reading - Functions
9 pages
ASSINGMENT
PDF
No ratings yet
ASSINGMENT
23 pages
Python Unit 2
PDF
No ratings yet
Python Unit 2
25 pages
Sem 3 Python Module III Final
PDF
No ratings yet
Sem 3 Python Module III Final
20 pages
Function CC
PDF
No ratings yet
Function CC
6 pages
Functions
PDF
No ratings yet
Functions
22 pages
Python Functions - Unit3 1
PDF
No ratings yet
Python Functions - Unit3 1
25 pages
8 - Function 2
PDF
No ratings yet
8 - Function 2
44 pages
Publication 3 5798 6270
PDF
No ratings yet
Publication 3 5798 6270
8 pages
برمجه م 4
PDF
No ratings yet
برمجه م 4
14 pages
PY0101EN 3 3 Functions
PDF
No ratings yet
PY0101EN 3 3 Functions
11 pages
Python Programming Module 2
PDF
No ratings yet
Python Programming Module 2
11 pages
Functions
PDF
No ratings yet
Functions
28 pages
Lab 6 Functions
PDF
No ratings yet
Lab 6 Functions
10 pages
Functions in Python
PDF
No ratings yet
Functions in Python
7 pages
Q11) PYTHON Programming
PDF
No ratings yet
Q11) PYTHON Programming
7 pages
CCD Module15-PL101 01
PDF
No ratings yet
CCD Module15-PL101 01
12 pages
Unit-1 Part-2
PDF
No ratings yet
Unit-1 Part-2
12 pages
Python Unit 4
PDF
No ratings yet
Python Unit 4
11 pages
FoPM3 Functions and Modules
PDF
No ratings yet
FoPM3 Functions and Modules
6 pages
Lecture1 Functions
PDF
No ratings yet
Lecture1 Functions
10 pages
Function Notes
PDF
No ratings yet
Function Notes
6 pages
Lab 6 Function
PDF
No ratings yet
Lab 6 Function
7 pages
Functions
PDF
No ratings yet
Functions
9 pages
Functions in Python
PDF
No ratings yet
Functions in Python
10 pages
Chapter 6 Solution PDF
PDF
No ratings yet
Chapter 6 Solution PDF
7 pages
Lab 4 - Functional Programming: Practice
PDF
No ratings yet
Lab 4 - Functional Programming: Practice
2 pages
Class Test Function
PDF
No ratings yet
Class Test Function
3 pages
SEN1011, Lab Manual - Week8 Loops and Functions Step1: Loops
PDF
No ratings yet
SEN1011, Lab Manual - Week8 Loops and Functions Step1: Loops
2 pages