The document contains Python code solutions to various exercises involving lists, tuples, dictionaries and string manipulation. The exercises include tasks like creating lists from user input, storing Fibonacci numbers in a list, mapping month names to numbers using a dictionary, counting character frequencies in a string, and converting a date string to a date tuple. The solutions demonstrate basic list, tuple, dictionary and string operations in Python.
The Key Difference between a List and a Tuple. The main difference between lists and a tuples is the fact that lists are mutable whereas tuples are immutable. A mutable data type means that a python object of this type can be modified. Let's create a list and assign it to a variable.
The Key Difference between a List and a Tuple. The main difference between lists and a tuples is the fact that lists are mutable whereas tuples are immutable. A mutable data type means that a python object of this type can be modified. Let's create a list and assign it to a variable.
METHODS DESCRIPTION
copy() They copy() method returns a shallow copy of the dictionary.
clear() The clear() method removes all items from the dictionary.
pop() Removes and returns an element from a dictionary having the given key.
popitem() Removes the arbitrary key-value pair from the dictionary and returns it as tuple.
get() It is a conventional method to access a value for a key.
dictionary_name.values() returns a list of all the values available in a given dictionary.
str() Produces a printable string representation of a dictionary.
update() Adds dictionary dict2’s key-values pairs to dict
setdefault() Set dict[key]=default if key is not already in dict
keys() Returns list of dictionary dict’s keys
items() Returns a list of dict’s (key, value) tuple pairs
has_key() Returns true if key in dictionary dict, false otherwise
fromkeys() Create a new dictionary with keys from seq and values set to value.
type() Returns the type of the passed variable.
cmp() Compares elements of both dict.
Functions
Function
Type of Function
Algebraic Function
Trigonometric Function
Logarithmic Function
Integral Function
Rational Fraction
Rational Function
Explicie & Implicit Function
Unique Values of Function
Odd & Even Function
Properties of Odd-Even Functions
Homogeneous Function
Linear Function
Inverse Function
Sampling of Function
Piece-wise Function
Sketch the Function
Straight Line
Domain & Range
Ordered Pairs
Ordered Pairs from Function
Function in Different Domains
Increasing-Decreasing Function
Modulo Function
Sub-equations of Modulo Function
Inequality
Inequalities
Properties of Inequalities
Transitivity
Addition and subtraction
Multiplication and Division
Additive inverse
Multiplicative Inverse
Interval Notion In Inequality
Answer Set
For Real Numbers
For Integers
Compound Statements
Linear Inequality
Quadratic Inequality
Quotients and Absolute Inequalities
METHODS DESCRIPTION
copy() They copy() method returns a shallow copy of the dictionary.
clear() The clear() method removes all items from the dictionary.
pop() Removes and returns an element from a dictionary having the given key.
popitem() Removes the arbitrary key-value pair from the dictionary and returns it as tuple.
get() It is a conventional method to access a value for a key.
dictionary_name.values() returns a list of all the values available in a given dictionary.
str() Produces a printable string representation of a dictionary.
update() Adds dictionary dict2’s key-values pairs to dict
setdefault() Set dict[key]=default if key is not already in dict
keys() Returns list of dictionary dict’s keys
items() Returns a list of dict’s (key, value) tuple pairs
has_key() Returns true if key in dictionary dict, false otherwise
fromkeys() Create a new dictionary with keys from seq and values set to value.
type() Returns the type of the passed variable.
cmp() Compares elements of both dict.
Functions
Function
Type of Function
Algebraic Function
Trigonometric Function
Logarithmic Function
Integral Function
Rational Fraction
Rational Function
Explicie & Implicit Function
Unique Values of Function
Odd & Even Function
Properties of Odd-Even Functions
Homogeneous Function
Linear Function
Inverse Function
Sampling of Function
Piece-wise Function
Sketch the Function
Straight Line
Domain & Range
Ordered Pairs
Ordered Pairs from Function
Function in Different Domains
Increasing-Decreasing Function
Modulo Function
Sub-equations of Modulo Function
Inequality
Inequalities
Properties of Inequalities
Transitivity
Addition and subtraction
Multiplication and Division
Additive inverse
Multiplicative Inverse
Interval Notion In Inequality
Answer Set
For Real Numbers
For Integers
Compound Statements
Linear Inequality
Quadratic Inequality
Quotients and Absolute Inequalities
Ethnobotany and Ethnopharmacology:
Ethnobotany in herbal drug evaluation,
Impact of Ethnobotany in traditional medicine,
New development in herbals,
Bio-prospecting tools for drug discovery,
Role of Ethnopharmacology in drug evaluation,
Reverse Pharmacology.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
Synthetic Fiber Construction in lab .pptxPavel ( NSTU)
Synthetic fiber production is a fascinating and complex field that blends chemistry, engineering, and environmental science. By understanding these aspects, students can gain a comprehensive view of synthetic fiber production, its impact on society and the environment, and the potential for future innovations. Synthetic fibers play a crucial role in modern society, impacting various aspects of daily life, industry, and the environment. ynthetic fibers are integral to modern life, offering a range of benefits from cost-effectiveness and versatility to innovative applications and performance characteristics. While they pose environmental challenges, ongoing research and development aim to create more sustainable and eco-friendly alternatives. Understanding the importance of synthetic fibers helps in appreciating their role in the economy, industry, and daily life, while also emphasizing the need for sustainable practices and innovation.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
This is a presentation by Dada Robert in a Your Skill Boost masterclass organised by the Excellence Foundation for South Sudan (EFSS) on Saturday, the 25th and Sunday, the 26th of May 2024.
He discussed the concept of quality improvement, emphasizing its applicability to various aspects of life, including personal, project, and program improvements. He defined quality as doing the right thing at the right time in the right way to achieve the best possible results and discussed the concept of the "gap" between what we know and what we do, and how this gap represents the areas we need to improve. He explained the scientific approach to quality improvement, which involves systematic performance analysis, testing and learning, and implementing change ideas. He also highlighted the importance of client focus and a team approach to quality improvement.
The Indian economy is classified into different sectors to simplify the analysis and understanding of economic activities. For Class 10, it's essential to grasp the sectors of the Indian economy, understand their characteristics, and recognize their importance. This guide will provide detailed notes on the Sectors of the Indian Economy Class 10, using specific long-tail keywords to enhance comprehension.
For more information, visit-www.vavaclasses.com
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
We all have good and bad thoughts from time to time and situation to situation. We are bombarded daily with spiraling thoughts(both negative and positive) creating all-consuming feel , making us difficult to manage with associated suffering. Good thoughts are like our Mob Signal (Positive thought) amidst noise(negative thought) in the atmosphere. Negative thoughts like noise outweigh positive thoughts. These thoughts often create unwanted confusion, trouble, stress and frustration in our mind as well as chaos in our physical world. Negative thoughts are also known as “distorted thinking”.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
3. Exercise: more list creation
1 Ask the user to enter an integer, n
Store the square of all the odd numbers less than
n in a list
Print this list
2
3
7. Hint: string to list/tuple
Here is an easy way to convert a string to a list of
characters.
Try this:
In []: x =’hello’
In []:print(list(x))
In []:print(tuple(x))
8. Exercise: list of Fibonacci
1 Ask the user to enter an integer, n(≥ 1)
2 Store the first n numbers of the Fibonnaci series in
a list
Print this list
3
9. Solution
n =int(input()) a, b = 0,
1
result = [0]
for I in range(n-1):
result.append(b)
a, b = b, a+b
print(result)
10. Exercise: square a list of integers
1 Ask the user to enter a list of integers separated by
spaces
Convert this into a list of integers but square each
element
Print this list
2
3
For example, if the user enters 1 2 3 4, print:
[1, 4, 9, 16]
12. Exercise: list of tuples
1 Ask the user to enter a list of integers separated by
spaces
Convert this into a list of integers but square each
element
Store the integer and its square in a tuple, put this
into a list
Print this list
2
3
4
For example, if the user enters 1 2 3 4, print:
[(1, 1), (2, 4), (3, 9), (4, 16)]
14. Hint: iterating over a list of tuples
Consider the following code:
In []: data = [(1, 1), (2, 4), (3, 9), (4,
16)]
We can iterate over this as follows:
In []:for x, y in data:
.....:print(x, y)
15. Exercise: list methods
1 Ask the user to enter a string
Convert this into a list of characters
Sort this list in ascending order
Now eliminate any repeated values in this list
Print this list
2
3
4
5
For example, if the user enters hello, print:
[’e’,’h’,’l’,’o’]
19. Exercise: simple dictionaries
1 Ask the user for a list of integers separated by
spaces
For each integer, store the string version as the
key and the square of the integer value as the
value in a dictionary.
Print the resulting dictionary
2
3
For example if the user enters "1 3 5", print:
{’1’: 1,’3’: 9,’5’: 25}
Hint: simply print the resulting dictionary
21. Exercise: mapping using dicts
1 Create a mapping from 3 character month name to
month number
2 Hint: for example {’jan’: 1, ’dec’: 12}
Ask the user for a 3 character month code
lower/upper mixed
Print the month number corresponding to the
month the user entered.
3
4
For example if the user enters "Jul", print:
7
24. Aside: using enumerate
months = (’janfebmaraprmayjunjul’+
’augsepoctnovdec’).split()
month2mm = {}
for i, month in enumerate(months):
month2mm[month] = i + 1
#Is easier/nicer than this:
for I inrange(len(months)):
month2mm[months[i]] = i + 1
25. Exercise: dictionaries
1 Ask the user to enter a string
Convert this to lower case
Count the number of occurrences of each
character in the string
Hint: use a dict
Print the result in sorted order of the characters
2
3
4
5
For example, if the user enters helloo, print:
e 1
h 1
l 2
o 2
26. Solution
text =input().lower()
result = {}
for char in text:
if char in result:
result[char] += 1
else:
result[char] = 1
for char in sorted(result):
print(char, result[char])
27. Problem: datestring to date tuple
You are given date strings of the form “29 Jul, 2009”, or
“4 January 2008”. In other words a number, a string
and another number, with a comma sometimes
separating the items.
Write a program that takes such a string as input and
prints a tuple (yyyy, mm, dd) where all three elements
are ints.
28. Solution
months = (’janfebmaraprmayjunjul’+
’augsepoctnovdec’).split()
month2mm = {}
for i, month in enumerate(months):
month2mm[month] = i + 1
date =input()
date = date.replace(’,’,’’) day, month,
year = date.split()
dd, yyyy =int(day),int(year)
mon = month[:3].lower()
mm = month2mm[mon] print((yyyy,
mm, dd))
FOSSEE Team (FOSSEE – IITB) Basic Python 30 / 31