Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
21 views

Passing List String Function

The document discusses passing different types of arguments to functions in Python including strings and lists. It provides examples of passing a string to a function to count vowels, jumble the string, and more. It also demonstrates passing a list to a function to modify values, calculate sums and averages, and work with nested lists.

Uploaded by

iitiansrd2025
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
21 views

Passing List String Function

The document discusses passing different types of arguments to functions in Python including strings and lists. It provides examples of passing a string to a function to count vowels, jumble the string, and more. It also demonstrates passing a list to a function to modify values, calculate sums and averages, and work with nested lists.

Uploaded by

iitiansrd2025
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

PASSING OF DIFFERENT TYPES OF

ARGUMENTS
WORKING WITH FUNCTION
Passing String to function
 Functioncan accept string as a parameter
 As per Python, string is immutable type, so function
can access the value of string but cannot alter the
string
 To modify string, the trick is to take another string
and concatenate the modified value of parameter
string in the newly created string.
 Let us see few examples of passing string to
function…
Passing string to function and count how
many vowels in it
Program to count how many times any
character is present in string
Program to Jumble the given string by passing
it to function using temporary string
Passing List to function
 We can also pass List to any function asparameter
 Due to the mutable nature of List, function can alter
the list of values in place.
 It is mostly used in data structure like sorting, stack,
queue etc.
 Let ussee how to pass List to function by few
examples:
Passing list to function,
and just double each
value
Passing list to function to double the
odd values and half the even values
Passing nested list to function and print all those values
which are at diagonal position in the form of matrix
Passing list to function to calculate sumand average of
all numbers and return it in the form of tuple
Passing list to function to calculate sumand average of
all numbers and return it in the form of tuple

You might also like