0% found this document useful (0 votes)
5 views11 pages

Python

This document outlines an experiment focused on writing procedural programs using functions in Python, specifically utilizing dictionaries and lists. It includes objectives, outcomes, and a series of programming tasks such as generating a Fibonacci sequence, finding the GCD of a number, and manipulating dictionary keys. The document concludes with references for further learning about Python programming.

Uploaded by

ffirebase334
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
5 views11 pages

Python

This document outlines an experiment focused on writing procedural programs using functions in Python, specifically utilizing dictionaries and lists. It includes objectives, outcomes, and a series of programming tasks such as generating a Fibonacci sequence, finding the GCD of a number, and manipulating dictionary keys. The document concludes with references for further learning about Python programming.

Uploaded by

ffirebase334
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Experiment No: 2

Topic: To write procedural program using functions in Python. To use dictionaries


and/or lists and/or range in python and demonstrate list functions in Python.

Prerequisite: Knowledge of some programming language like C, Java

Mapping With CSL405.2


COs:
Objective: - To write procedural program using functions in Python.

- To use dictionaries and lists in python and demonstrate dictionaries


and/or lists and/or range in python.
Outcome: - Ability to write program using functions in Python

- Ability to demonstrate use of list and dictionary functions

Bloom’s Apply
Taxonomy
Theory/ Steps/ -Default Atguments
Algorithm/
Procedure: -Variable length arguments

Positional arguments

These are the arguments passed to a function in correct positional order. Here the
number of arguments and their positions in the funtction definition should match
exactly with the number of arguments and their positions in the funtction call.

Keyword Argument

These are those arguments that identify the parameters by their names.

def grocery(item, price) grocery(item='sugar', price=

50.50) # function call grocery(price= 75.25, item='dal',)

# function call

Default Arguments

We can mention some default value for the function parameters in the definition.

def grocery(item, price=45.70)

Variable length arguments


Sometimes the programmer does not know how many values a function may
receive. In that case, the programmer cannot decide how many arguments to be
given in the function definition Find more about variable length arguments and
write in your write-up Reading multiple inputs in one line. We can read multiple
inputs in one line as follows.
Experiments:

1. Write a program using functions in python to

generate Fibonacci sequence upto number n.

2. Write a program using functions in Python to find a GCD of a number.

3. Write a program to represent Item’s ID as a key using dictionary.

Make a list of details of item as its multiple values.

Hint:
Items = {

“Butter” : [350, 50],

“Jam” : [400, 15]

4. Write a program using functions in python for following requirements:

- Adding keys into dictionary

- Removing keys from dictionary

- Updating keys into dictionary

- Display the values of list by accessing its key

- Add item details into list.

5. Design your own application based on any domain having minimum 05


Functions.
Deliverables: Example
1. Write a program using functions in python to generate
Fibonacci sequence upto number n.

OUTPUT :
2. Write a program using functions in Python to find a GCD of a number.

OUTPUT :
3. Write a program to represent Item’s ID as a key using dictionary.
Make a list of details of item as its multiple values.
Hint:
Items = {
“Butter” : [350, 50],
“Jam” : [400, 15]
}
Write a program using functions in python for following requirements:
- Adding keys into dictionary
- Removing keys from dictionary
- Updating keys into dictionary
- Display the values of list by accessing its key
- Add item details into list.

OUTPUT :
5. Design your own application based on any domain having minimum 05 Functions.

OUTPUT :

Conclusion: Thus we have successfully understand and implemented basic commands in python

References: https://www.python.org/ https://www.tutorialspoint.com/


https://www.w3schools.com/python/
References: https://www.python.org/ https://www.tutorialspoint.com/
https://www.w3schools.com/python/

You might also like