Python- Creating Dictionary,
Accessing and Modifying key: value Pairs in Dictionaries
Built-In Functions used on Dictionaries,
Dictionary Methods
Removing items from dictionary
Learn how to use lists in Java, how to use List<T> and ArrayList<T>, how to process lists of elements.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-lists
Python- Creating Dictionary,
Accessing and Modifying key: value Pairs in Dictionaries
Built-In Functions used on Dictionaries,
Dictionary Methods
Removing items from dictionary
Learn how to use lists in Java, how to use List<T> and ArrayList<T>, how to process lists of elements.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-lists
String literals in python are surrounded by either single quotation marks, or double quotation marks. Strings can be output to screen using the print function. For example: print("hello"). Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.
A function is a set of statements that take inputs, do some specific computation and produces output. The idea is to put some commonly or repeatedly done task together and make a function, so that instead of writing the same code again and again for different inputs, we can call the function.
Python provides built-in functions like print(), etc. but we can also create your own functions. These functions are called user-defined functions.
Java Foundations: Maps, Lambda and Stream APISvetlin Nakov
Learn how to work with maps in Java, how to use the Map<K, V> interface and the API classes HashMap<K,V> and TreeMap<K, V>. Learn how to work with lambda expressions and how to use the Java stream API to process sequences of elements, how to filter, transform and order sequences.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-maps-lambda-and-stream-api/
Learn how to use arrays in Java, how to enter array, how to traverse an array, how to print array and more array operations.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-arrays
Chapter 22. Lambda Expressions and LINQIntro C# Book
In this chapter we will become acquainted with some of the advanced capabilities of the C# language. To be more specific, we will pay attention on how to make queries to collections, using lambda expressions and LINQ, and how to add functionality to already created classes, using extension methods. We will get to know the anonymous types, describe their usage briefly and discuss lambda expressions and show in practice how most of the built-in lambda functions work. Afterwards, we will pay more attention to the LINQ syntax – we will learn what it is, how it works and what queries we can build with it. In the end, we will get to know the meaning of the keywords in LINQ, and demonstrate their capabilities with lots of examples.
In this chapter we will review how to work with text files in C#. We will explain what a stream is, what its purpose is, and how to use it. We will explain what a text file is and how can you read and write data to a text file and how to deal with different character encodings. We will demonstrate and explain the good practices for exception handling when working with files. All of this will be demonstrated with many examples in this chapter
In this chapter we are going to get familiar with some of the basic presentations of data in programming: lists and linear data structures. Very often in order to solve a given problem we need to work with a sequence of elements. For example, to read completely this book we have to read sequentially each page, i.e. to traverse sequentially each of the elements of the set of the pages in the book. Depending on the task, we have to apply different operations on this set of data. In this chapter we will introduce the concept of abstract data types (ADT) and will explain how a certain ADT can have multiple different implementations. After that we shall explore how and when to use lists and their implementations (linked list, doubly-linked list and array-list). We are going to see how for a given task one structure may be more convenient than another. We are going to consider the structures "stack" and "queue", as well as their applications. We are going to get familiar with some implementations of these structures.
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
String literals in python are surrounded by either single quotation marks, or double quotation marks. Strings can be output to screen using the print function. For example: print("hello"). Like many other popular programming languages, strings in Python are arrays of bytes representing unicode characters.
A function is a set of statements that take inputs, do some specific computation and produces output. The idea is to put some commonly or repeatedly done task together and make a function, so that instead of writing the same code again and again for different inputs, we can call the function.
Python provides built-in functions like print(), etc. but we can also create your own functions. These functions are called user-defined functions.
Java Foundations: Maps, Lambda and Stream APISvetlin Nakov
Learn how to work with maps in Java, how to use the Map<K, V> interface and the API classes HashMap<K,V> and TreeMap<K, V>. Learn how to work with lambda expressions and how to use the Java stream API to process sequences of elements, how to filter, transform and order sequences.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-maps-lambda-and-stream-api/
Learn how to use arrays in Java, how to enter array, how to traverse an array, how to print array and more array operations.
Watch the video lesson and access the hands-on exercises here: https://softuni.org/code-lessons/java-foundations-certification-arrays
Chapter 22. Lambda Expressions and LINQIntro C# Book
In this chapter we will become acquainted with some of the advanced capabilities of the C# language. To be more specific, we will pay attention on how to make queries to collections, using lambda expressions and LINQ, and how to add functionality to already created classes, using extension methods. We will get to know the anonymous types, describe their usage briefly and discuss lambda expressions and show in practice how most of the built-in lambda functions work. Afterwards, we will pay more attention to the LINQ syntax – we will learn what it is, how it works and what queries we can build with it. In the end, we will get to know the meaning of the keywords in LINQ, and demonstrate their capabilities with lots of examples.
In this chapter we will review how to work with text files in C#. We will explain what a stream is, what its purpose is, and how to use it. We will explain what a text file is and how can you read and write data to a text file and how to deal with different character encodings. We will demonstrate and explain the good practices for exception handling when working with files. All of this will be demonstrated with many examples in this chapter
In this chapter we are going to get familiar with some of the basic presentations of data in programming: lists and linear data structures. Very often in order to solve a given problem we need to work with a sequence of elements. For example, to read completely this book we have to read sequentially each page, i.e. to traverse sequentially each of the elements of the set of the pages in the book. Depending on the task, we have to apply different operations on this set of data. In this chapter we will introduce the concept of abstract data types (ADT) and will explain how a certain ADT can have multiple different implementations. After that we shall explore how and when to use lists and their implementations (linked list, doubly-linked list and array-list). We are going to see how for a given task one structure may be more convenient than another. We are going to consider the structures "stack" and "queue", as well as their applications. We are going to get familiar with some implementations of these structures.
In this chapter we will learn about arrays as a way to work with sequences of elements of the same type. We will explain what arrays are, how we declare, create, instantiate and use them. We will examine one-dimensional and multidimensional arrays. We will learn different ways to iterate through the array, read from the standard input and write to the standard output. We will give many example exercises, which can be solved using arrays and we will show how useful they really are.
A brief introduction to functional programming.
Even if slides present some simple Python code, functional programming patterns applies to other languages too.
Textbook Solutions refer https://pythonxiisolutions.blogspot.com/
Practical's Solutions refer https://prippython12.blogspot.com/
It is difficult to manage a single list of instructions. Thus large program are broken down into smaller units known as functions. Functions can be invoked from other parts of the program. it make program more readable and understandable making program easy to manage.
MATLAB/SIMULINK for Engineering Applications day 2:Introduction to simulinkreddyprasad reddyvari
3 days Hands on workshop on MATLAB/SIMULINK for Engineering Applications:
this workshop aims to make students to aware of MATLAB to do own projects in engineering life with best available technology E-Simulink Softwares and tools.
In this presentation, You will get to know about Function Literal,Higher Order Function,Partial Function,Partial Applied Function,Nested Function,Closures.
Similar to Python programming- Part IV(Functions) (20)
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
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.
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
The Roman Empire A Historical Colossus.pdfkaushalkr1407
The Roman Empire, a vast and enduring power, stands as one of history's most remarkable civilizations, leaving an indelible imprint on the world. It emerged from the Roman Republic, transitioning into an imperial powerhouse under the leadership of Augustus Caesar in 27 BCE. This transformation marked the beginning of an era defined by unprecedented territorial expansion, architectural marvels, and profound cultural influence.
The empire's roots lie in the city of Rome, founded, according to legend, by Romulus in 753 BCE. Over centuries, Rome evolved from a small settlement to a formidable republic, characterized by a complex political system with elected officials and checks on power. However, internal strife, class conflicts, and military ambitions paved the way for the end of the Republic. Julius Caesar’s dictatorship and subsequent assassination in 44 BCE created a power vacuum, leading to a civil war. Octavian, later Augustus, emerged victorious, heralding the Roman Empire’s birth.
Under Augustus, the empire experienced the Pax Romana, a 200-year period of relative peace and stability. Augustus reformed the military, established efficient administrative systems, and initiated grand construction projects. The empire's borders expanded, encompassing territories from Britain to Egypt and from Spain to the Euphrates. Roman legions, renowned for their discipline and engineering prowess, secured and maintained these vast territories, building roads, fortifications, and cities that facilitated control and integration.
The Roman Empire’s society was hierarchical, with a rigid class system. At the top were the patricians, wealthy elites who held significant political power. Below them were the plebeians, free citizens with limited political influence, and the vast numbers of slaves who formed the backbone of the economy. The family unit was central, governed by the paterfamilias, the male head who held absolute authority.
Culturally, the Romans were eclectic, absorbing and adapting elements from the civilizations they encountered, particularly the Greeks. Roman art, literature, and philosophy reflected this synthesis, creating a rich cultural tapestry. Latin, the Roman language, became the lingua franca of the Western world, influencing numerous modern languages.
Roman architecture and engineering achievements were monumental. They perfected the arch, vault, and dome, constructing enduring structures like the Colosseum, Pantheon, and aqueducts. These engineering marvels not only showcased Roman ingenuity but also served practical purposes, from public entertainment to water supply.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
2. Functions
• Built-in functions
• input()
• print()
• eval() function
The function eval() is used to evaluate the value of a string
Eg:
>>>eval(‘15’)
15
>>>eval(’15+10’)
25
05-11-2021 meghav@kannuruniv.ac.in 2
3. Functions
Composition
• The value returned by a function may be used as an argument for another
function in a nested manner .
eg:
>>>n=eval(input(‘Enter a number’))
Enter a number 56
>>>n
56
>>>e=eval(input(‘Enter an arithmetic expression:’))
Enter an arithmetic expression: 12.0+13.0*2
>>>e
38.0
05-11-2021 meghav@kannuruniv.ac.in 3
4. Functions
type() function
• Values or objects in Python are classified into types of classes
• type() function return the type of a value
• eg:
>>>print(type(12),type(12.5),type(‘hello’),type(int))
<class‘int‘><class 'float’><class‘str’><class 'type’>
round() function
• The round function
• n rounds a number up to specific number of decimal places,
eg:
>>>print(round(89.652,2),round(89.635),round(89.635,0))
89.65 90 90.0
>>>print(round(34.12,1)round(-34.63))
34.1 -35
05-11-2021 meghav@kannuruniv.ac.in 4
5. Functions
pow() function
• pow(a,b) computes ab
• Random number generation
random() function
• generates a random number in the range [0,1]
• Python module random contains this function
import random
if random.random()<0.5
print(‘Player A plays the first game’)
randint() function
• Chooses an integer in the specified range()
• randint(1,n) will randomly generate a number in the range 1 to n
05-11-2021 meghav@kannuruniv.ac.in 5
6. Functions
• Functions from math Module
Function Description
ceil(x) returns the smallest integer greater than or equal to x
floor(x) returns the largest integer less than or equal to x
fabs(x) returns the absolute value of x
exp(x) returns the value of expression e**x
log(x,b) returns the log(x) to the base b
log10(x) returns the log(x) to the base 10
pow(x,y) xy
sqrt(x) square root of x
05-11-2021 meghav@kannuruniv.ac.in 6
7. Functions
• Functions from math Module
Function Description
sin(x) sine of x in radians
tan(x) tangent of x in radians
cos(x) cosine of x in radians
acos(x) inverse cosine of x in radians
asin(x) inverse sine of x in radians
atan(x) inverse tangent of x in radians
degrees(x) returns a value in degree equivalent of input value x( in radians)
radians(x) returns a value in radian equivalent of input value x( in degrees)
05-11-2021 meghav@kannuruniv.ac.in 7
8. Functions from math Module
• examples:
>>> import math as m
>>>m.ceil(3.4)
4
>>>m.floor(3.7)
3
>>>m.fabs(-3)
3
>>>m.exp(2)
7.38905609893
>>>m.log(32,2)
5.0
>>>m.log10(100)
2.0
>>>m.pow(3,3)
27.0
>>>m.sqrt(65)
8.0622577
>>>m.cos(m.pi)
-1.0
>>>m.sin(m.pi/2)
1.0
>>>m.tan(m.pi/4)
0.999999
>>>m.acos(1)
0.0
>>>m.asin(1)
1.57079632
>>>m.atan(1)
0.7853981
05-11-2021 meghav@kannuruniv.ac.in 8
9. Function definition and calling the function
def function_name(comma_separated_list_of_parameters):
statements
• Just below def, begin with four spaces- indentation
• Every Python module has a built-in variable called _name_
-containing the name of the module
05-11-2021 meghav@kannuruniv.ac.in 9
10. Function definition and calling the function
• Eg:
def triangle():
print(‘ *’)
print(‘**’)
print(‘***’)
print(‘****’)
def square(): triangle(), square()-callee function
print(‘****’) main() – caller function
print(‘****’)
print(‘****’)
print(‘****’)
def main():
triangle()
print()
square()
if _name_==‘_main_’
main()
print(‘End of Program’)
05-11-2021 meghav@kannuruniv.ac.in 10
11. Fruitful function vs void function
• A function that returns a value if often called a fruitful function
• A function that does not return a value is called a void function
Default Parameter Values
• The function parameters may be assigned initial values, also called default
values
>>>areaRectangle(5)
• The default parameters must not be followed by non-default parameters
>>>def areaRectangle(length=10,breadth) #Syntax error
05-11-2021 meghav@kannuruniv.ac.in 11
12. return statement
• The return keyword is to exit a function and return a value.
Eg1:
def myfunction():
return 3+3
print(myfunction())
Eg2:
• Statements after the return line will not be executed:
def myfunction():
return 3+3
print("Hello, World!")
print(myfunction())
05-11-2021 meghav@kannuruniv.ac.in 12
13. Keyword Arguments
• You can also send arguments with the syntax
key = value
• This way the order of the arguments does not matter
Eg:
def my_function(child3, child2, child1):
print("The youngest child is " + child3)
my_function(child1="Emil",child2="Tobias",child3="Linus")
05-11-2021 meghav@kannuruniv.ac.in 13
14. Scope and lifetime of variable
• A variable is only available from inside the region it is created.
This is called scope.
Local Scope
• A variable created inside a function belongs to the local scope of
that function, and can only be used inside that function
def myfunc():
x = 300
print(x)
myfunc()
05-11-2021 meghav@kannuruniv.ac.in 14
15. Scope and lifetime of variable
Function Inside Function
• As explained in the example above, the variable x is not available
outside the function, but it is available for any function inside the
function
def myfunc():
x = 300
def myinnerfunc():
print(x)
myinnerfunc()
myfunc()
05-11-2021 meghav@kannuruniv.ac.in 15
16. Scope and lifetime of variable
Global Scope
• A variable created in the main body of the Python code is a
global variable and belongs to the global scope.
• Global variables are available from within any scope, global and
local.
x = 300
def myfunc():
print(x)
myfunc()
print(x)
05-11-2021 meghav@kannuruniv.ac.in 16
17. Scope and lifetime of variable
Naming Variables
• If you operate with the same variable name inside and outside of
a function
• Python will treat them as two separate variables, one available in
the global scope (outside the function) and one available in the
local scope (inside the function):
x = 300
def myfunc():
x = 200
print(x) #200
myfunc()
print(x) #300
05-11-2021 meghav@kannuruniv.ac.in 17
18. Scope and lifetime of variable
Global Keyword
• If you need to create a global variable, but are stuck in the local scope, you
can use the global keyword.
• The global keyword makes the variable global.
def myfunc():
global x
x = 300
myfunc()
print(x)
05-11-2021 meghav@kannuruniv.ac.in 18
19. Arbitrary Arguments, *args
• If you do not know how many arguments that will be passed into your
function, add a * before the parameter name in the function definition.
• This way the function will receive a tuple of arguments, and can access the
items accordingly:
def my_function(*kids):
print("The youngest child is " + kids[2])
my_function("Emil", "Tobias", "Linus")
05-11-2021 meghav@kannuruniv.ac.in 19
20. Arbitrary Keyword Arguments, **kwargs
• If you do not know how many keyword arguments that will be passed into your
function, add two asterisk: ** before the parameter name in the function
definition.
• This way the function will receive a dictionary of arguments, and can access the
items accordingly:
def my_function(**kid):
print("His last name is " + kid["lname"])
my_function(fname = "Tobias", lname = "Refsnes")
05-11-2021 meghav@kannuruniv.ac.in 20
21. Command line arguments
• We may choose to run the Python script from the command line interface
1.Open the directory(F:PythonCodeCh2) containing the file area.py
2.Open command prompt window using an option in context menu
3. Execute the command: python area.py
F:PythonCodeCh2>python area.py
Enter the following values for rectangle
Length: integer value:20
Breadthe:integer value:10
Area of rectangle is 200
05-11-2021 meghav@kannuruniv.ac.in 21
22. Command line arguments
• We may also take the input as command line arguments while executing a script
from the command prompt
F:PythonCodeCh2> python areal.py 20 10
Area of rectangle is 200
• In above command 20 and 10 save as inputs for the script areal.py
• We execute the script from command line
• It takes the name of the script as first argument and followed by other input
arguments and store them in the list sys.argv
• We access the arguments stored in arg using indeces argv[0], argv[1], argv[2] etc
05-11-2021 meghav@kannuruniv.ac.in 22