Arrays & Strings can be summarized as follows:
1. Arrays are fixed-size collections of elements of the same data type that are used to store lists of related data. They can be one-dimensional, two-dimensional, or multi-dimensional.
2. Strings in C are arrays of characters terminated by a null character. They are commonly used to store text data. Common string operations include reading, writing, combining, copying, comparing, and extracting portions of strings.
3. Arrays are declared with a data type, name, and size. They can be initialized with a block of comma-separated values. Individual elements are accessed using indexes in square brackets. Two-dimensional arrays represent tables
Python Class | Python Programming | Python Tutorial | EdurekaEdureka!
( Python Training : https://www.edureka.co/python )
This Edureka Python Class tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you understand Python Classes and Objects with examples. It will also explain the concept of Abstract Classes and Inheritance in python.
Check out our Python Training Playlist: https://goo.gl/Na1p9G
This Python Programming tutorial video helps you to learn following topics:
1. Python Classes and Objects
2. Inheritance
3. Abstract Classes
This document provides an overview of internet programming and XHTML. It discusses the basic structure of a web page, including the <head> and <body> sections. Common tags for formatting text like headers, links, images and forms are described. It also covers attributes for setting font properties, color, and size. The goal is to understand the basics of developing web pages using XHTML.
WHAT IS DICTIONARY IN PYTHON?
HOW TO CREATE A DICTIONARY
INITIALIZE THE DICTIONARY
ACCESSING KEYS AND VALUES FROM A DICTIONARY
LOOPS TO DISPLAY KEYS AND VALUES IN A DICTIONARY
METHODS IN A DICTIONARY
TO WATCH VIDEO OR PDF:
https://computerassignmentsforu.blogspot.com/p/dictinpyxii.html
The document provides an overview of the Python programming language. It discusses that Python is an easy to learn, high-level, open-source programming language. It describes Python's design philosophy of code readability and how it allows programmers to express concepts in fewer lines of code compared to languages like C++ and Java. The document also discusses Python's powerful libraries, wide use across industries, and how to get started with Python programming using the IDLE integrated development environment.
A proxy server acts as an intermediary between a client and the internet. It allows enterprises to ensure security, administrative control, and caching services. There are different types of proxy servers such as caching proxies, web proxies, content filtering proxies, and anonymizing proxies. Proxy servers can operate in either a transparent or opaque mode. They provide benefits like security, performance improvements through caching, and load balancing but also have disadvantages like creating single points of failure.
Provides an introductory level understanding of the Python Programming Language and language features. Serves as a guide for beginners and a reference to Python basics and language use cases.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
Arrays & Strings can be summarized as follows:
1. Arrays are fixed-size collections of elements of the same data type that are used to store lists of related data. They can be one-dimensional, two-dimensional, or multi-dimensional.
2. Strings in C are arrays of characters terminated by a null character. They are commonly used to store text data. Common string operations include reading, writing, combining, copying, comparing, and extracting portions of strings.
3. Arrays are declared with a data type, name, and size. They can be initialized with a block of comma-separated values. Individual elements are accessed using indexes in square brackets. Two-dimensional arrays represent tables
Python Class | Python Programming | Python Tutorial | EdurekaEdureka!
( Python Training : https://www.edureka.co/python )
This Edureka Python Class tutorial (Python Tutorial Blog: https://goo.gl/wd28Zr) will help you understand Python Classes and Objects with examples. It will also explain the concept of Abstract Classes and Inheritance in python.
Check out our Python Training Playlist: https://goo.gl/Na1p9G
This Python Programming tutorial video helps you to learn following topics:
1. Python Classes and Objects
2. Inheritance
3. Abstract Classes
This document provides an overview of internet programming and XHTML. It discusses the basic structure of a web page, including the <head> and <body> sections. Common tags for formatting text like headers, links, images and forms are described. It also covers attributes for setting font properties, color, and size. The goal is to understand the basics of developing web pages using XHTML.
WHAT IS DICTIONARY IN PYTHON?
HOW TO CREATE A DICTIONARY
INITIALIZE THE DICTIONARY
ACCESSING KEYS AND VALUES FROM A DICTIONARY
LOOPS TO DISPLAY KEYS AND VALUES IN A DICTIONARY
METHODS IN A DICTIONARY
TO WATCH VIDEO OR PDF:
https://computerassignmentsforu.blogspot.com/p/dictinpyxii.html
The document provides an overview of the Python programming language. It discusses that Python is an easy to learn, high-level, open-source programming language. It describes Python's design philosophy of code readability and how it allows programmers to express concepts in fewer lines of code compared to languages like C++ and Java. The document also discusses Python's powerful libraries, wide use across industries, and how to get started with Python programming using the IDLE integrated development environment.
A proxy server acts as an intermediary between a client and the internet. It allows enterprises to ensure security, administrative control, and caching services. There are different types of proxy servers such as caching proxies, web proxies, content filtering proxies, and anonymizing proxies. Proxy servers can operate in either a transparent or opaque mode. They provide benefits like security, performance improvements through caching, and load balancing but also have disadvantages like creating single points of failure.
Provides an introductory level understanding of the Python Programming Language and language features. Serves as a guide for beginners and a reference to Python basics and language use cases.
This presentation provides the information on python including the topics Python features, applications, variables and operators in python, control statements, numbers, strings, print formatting, list and list comprehension, dictionaries, tuples, files, sets, boolean, mehtods and functions, lambda expressions and a sample project using Python.
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.
HTML defines special formatting elements to display text with special meanings, such as bold, italic, subscript, and superscript. Some common formatting elements include <b> for bold text, <i> for italic text, <sub> for subscripted text, and <sup> for superscripted text. These elements were designed to display different types of text with semantic importance or visual formatting.
What is Python Lambda Function? Python Tutorial | EdurekaEdureka!
YouTube Link: https://youtu.be/RQRCWDK9UkA
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Python Lambda' is to educate you about the Lambda functions of Python and help you understand how to use them in various scenarios. Below are the topics covered in this PPT:
What are Python Lambda functions?
Why are they used?
How to write anonymous functions?
Lambda functions within user-defined functions
Using Anonymous functions within
- filter()
- map()
- reduce()
Solving algebric expressions using Lambda
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This presentation educates you about Python - GUI Programming(Tkinter), Tkinter Programming with syntaxe example, Tkinter Widgets with Operator & Description, Standard attributes.
For more topics stay tuned with learnbay.
in this how the split() function work with string in python is discussed
TO DOWNLOAD MORE INFORMATION:
https://computerassignmentsforu.blogspot.com/p/stringinpythonsplit.html
VIDEO TUTORIAL LINK:
https://youtu.be/6BvslDmk1Z8
1. Python Presented By: Rajesh Kumar Guided By: Mr. Jaishankar Bhatt
2. Content Python Introduction Python Code Execution Python Comments & Indentation Variables Data Types Strings Collections (Arrays)
3. Python Introduction What is Python? Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum Released in 1991
4. Python Code Execution Source code extension is .py Byte code extension is .pyc (compiled python code) Python’s runtime execution model:
5. Comments •Creating a Comment: Ex: Comments starts with a # Output:
6. Comments •Multi Line Comments: Ex: or:
7. Python Indentation •Indentation refers to the spaces at the beginning of a code line. Ex1: Ex2:
8. Variables •Variables are containers for storing data values. Ex:
9. Data Types •Built-in Data Types
10. Getting the Data Type •You can get the data type of any object by using the type() method. Ex: Print the data type of the variable x: Output:
11. Setting the Data Type •In Python, the data type is set when you assign a value to a variable:
12. Strings •String literals in python are surrounded by either single quotation marks, or double quotation marks. •'hello' is the same as "hello". Ex:
13. Multiline Strings •You can assign a multiline string to a variable by using three quotes Ex: Output:
14. Slicing •You can return a range of characters by using the slice syntax. Ex:Get the characters from position 2 to position 5. Output:
15. String Methods Method Description len() Returns the length of a string. lower() Returns the string in lower case. upper() Returns the string in upper case. count() Returns the number of times a specified value appears in the string.
16. Collections (Arrays) •There are four collection data types in the Python programming language. Types: 1. List 2. Tuple 3. Set 4. Dictionary
17. Python Lists •A list is a collection which is ordered and changeable. In Python lists are written with square brackets. Ex: Create a List: Output:
18. Python Tuples •A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Ex: Create a Tuple: Output:
19. Python Sets •A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Ex: Create a Set:
20. Python Dictionaries •A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets. Ex: Create a Dictionary:
21. Conclusion Python is a great option, whether you are a beginning programmer looking to learn the basics, an experienced programmer designing a large application, or anywhere in between. The basics of Python are easily grasped, and yet its capabilities are vast.
22. Reference https://www.udemy.com/course/learn- programming-with-python https://www.w3schools.com/python/default.asp
Strings in Python can be created using single quotes, double quotes, or triple quotes. Strings are immutable and indexing allows accessing individual characters. Strings can be sliced to extract substrings. The + operator is used for concatenation and * operator repeats strings. The split method returns a list of substrings split by a delimiter and join method concatenates strings with a delimiter.
This document discusses exception handling in C++. It defines an exception as an event that occurs during program execution that disrupts normal flow, like divide by zero errors. Exception handling allows the program to maintain normal flow even after errors by catching and handling exceptions. It describes the key parts of exception handling as finding problems, throwing exceptions, catching exceptions, and handling exceptions. The document provides examples of using try, catch, and throw blocks to handle exceptions in C++ code.
The document compares interpreters and compilers. It states that interpreters translate code line-by-line while compilers scan the entire program at once. Interpreters have faster analysis time but slower overall execution, while compilers have slower analysis but faster execution. Interpreters do not generate object code so are more memory efficient. Languages like JavaScript, Python and Ruby use interpreters, while C, C++ and Java use compilers.
Here are solutions to the exercises:
1. Write a program that reverses a string:
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String input = scanner.nextLine();
String reversed = "";
for (int i = input.length() - 1; i >= 0; i--) {
reversed += input.charAt(i);
}
System.out.println("Reversed string: " + reversed);
}
}
```
2. Write a program to
This document discusses programming languages, compilers vs interpreters, and introduces Python. It explains that a programming language communicates instructions to a machine and can be used to create programs. An interpreter reads and executes code directly, while a compiler converts source code into machine code. Python is an interpreted, object-oriented language that is easy to learn yet powerful. It can be used for web, enterprise, and other applications. The document also provides basic information on Python syntax and data types.
Programming Fundamentals Functions in C and typesimtiazalijoono
Programming Fundamentals
Functions in C
Lecture Outline
• Functions
• Function declaration
• Function call
• Function definition
– Passing arguments to function
1) Passing constants
2) Passing variables
– Pass by value
– Returning values from functions
• Preprocessor directives
• Local and external variables
1. The document discusses creating threads using the Runnable interface in Java.
2. The Runnable interface contains only the run() method, which is implemented by classes that want instances to run as threads.
3. To create a thread using Runnable, a Thread object is instantiated and passed the Runnable target, or the Thread object can be instantiated within the Runnable class's constructor.
Templates allow functions and classes to operate on generic types in C++. There are two types of templates: class templates and function templates. Function templates are functions that can operate on generic types, allowing code to be reused for multiple types without rewriting. Template parameters allow types to be passed to templates, similar to how regular parameters pass values. When a class, function or static member is generated from a template, it is called template instantiation.
Arrays in Python can hold multiple values and each element has a numeric index. Arrays can be one-dimensional (1D), two-dimensional (2D), or multi-dimensional. Common operations on arrays include accessing elements, adding/removing elements, concatenating arrays, slicing arrays, looping through elements, and sorting arrays. The NumPy library provides powerful capabilities to work with n-dimensional arrays and matrices.
This document discusses recursive functions, which are functions that call themselves repetitively until a certain condition is satisfied. It provides an introduction to recursive functions, noting that they contain statements to determine if the function should call itself again, a function call with arguments, a conditional statement like if/else, and a return statement. It then provides two examples of recursive functions as class work: writing a program to find the product of two numbers recursively and writing a program to calculate a^b recursively.
The document provides information about various Python data structures concepts related to lists. It discusses list basics like creating, accessing and updating lists. It also covers list methods like append(), pop(), sort() etc. and how to pass, return and search lists in functions. Key topics include list operations, looping through lists, copying lists, multidimensional lists and comparing performance of lists and tuples.
The document discusses various topics related to lists in Python including:
- Lists can store multiple items of similar or different types in a single variable.
- List items can be accessed and modified using indexes.
- List slicing allows accessing elements within a specified index range.
- Built-in functions like len(), max(), min() etc. can be used to perform operations on lists.
- List methods allow adding, removing, and modifying elements in lists.
- Lists can be passed as arguments to functions and returned from functions.
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.
HTML defines special formatting elements to display text with special meanings, such as bold, italic, subscript, and superscript. Some common formatting elements include <b> for bold text, <i> for italic text, <sub> for subscripted text, and <sup> for superscripted text. These elements were designed to display different types of text with semantic importance or visual formatting.
What is Python Lambda Function? Python Tutorial | EdurekaEdureka!
YouTube Link: https://youtu.be/RQRCWDK9UkA
** Python Certification Training: https://www.edureka.co/python **
This Edureka PPT on 'Python Lambda' is to educate you about the Lambda functions of Python and help you understand how to use them in various scenarios. Below are the topics covered in this PPT:
What are Python Lambda functions?
Why are they used?
How to write anonymous functions?
Lambda functions within user-defined functions
Using Anonymous functions within
- filter()
- map()
- reduce()
Solving algebric expressions using Lambda
Follow us to never miss an update in the future.
YouTube: https://www.youtube.com/user/edurekaIN
Instagram: https://www.instagram.com/edureka_learning/
Facebook: https://www.facebook.com/edurekaIN/
Twitter: https://twitter.com/edurekain
LinkedIn: https://www.linkedin.com/company/edureka
Castbox: https://castbox.fm/networks/505?country=in
This presentation educates you about Python - GUI Programming(Tkinter), Tkinter Programming with syntaxe example, Tkinter Widgets with Operator & Description, Standard attributes.
For more topics stay tuned with learnbay.
in this how the split() function work with string in python is discussed
TO DOWNLOAD MORE INFORMATION:
https://computerassignmentsforu.blogspot.com/p/stringinpythonsplit.html
VIDEO TUTORIAL LINK:
https://youtu.be/6BvslDmk1Z8
1. Python Presented By: Rajesh Kumar Guided By: Mr. Jaishankar Bhatt
2. Content Python Introduction Python Code Execution Python Comments & Indentation Variables Data Types Strings Collections (Arrays)
3. Python Introduction What is Python? Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum Released in 1991
4. Python Code Execution Source code extension is .py Byte code extension is .pyc (compiled python code) Python’s runtime execution model:
5. Comments •Creating a Comment: Ex: Comments starts with a # Output:
6. Comments •Multi Line Comments: Ex: or:
7. Python Indentation •Indentation refers to the spaces at the beginning of a code line. Ex1: Ex2:
8. Variables •Variables are containers for storing data values. Ex:
9. Data Types •Built-in Data Types
10. Getting the Data Type •You can get the data type of any object by using the type() method. Ex: Print the data type of the variable x: Output:
11. Setting the Data Type •In Python, the data type is set when you assign a value to a variable:
12. Strings •String literals in python are surrounded by either single quotation marks, or double quotation marks. •'hello' is the same as "hello". Ex:
13. Multiline Strings •You can assign a multiline string to a variable by using three quotes Ex: Output:
14. Slicing •You can return a range of characters by using the slice syntax. Ex:Get the characters from position 2 to position 5. Output:
15. String Methods Method Description len() Returns the length of a string. lower() Returns the string in lower case. upper() Returns the string in upper case. count() Returns the number of times a specified value appears in the string.
16. Collections (Arrays) •There are four collection data types in the Python programming language. Types: 1. List 2. Tuple 3. Set 4. Dictionary
17. Python Lists •A list is a collection which is ordered and changeable. In Python lists are written with square brackets. Ex: Create a List: Output:
18. Python Tuples •A tuple is a collection which is ordered and unchangeable. In Python tuples are written with round brackets. Ex: Create a Tuple: Output:
19. Python Sets •A set is a collection which is unordered and unindexed. In Python sets are written with curly brackets. Ex: Create a Set:
20. Python Dictionaries •A dictionary is a collection which is unordered, changeable and indexed. In Python dictionaries are written with curly brackets. Ex: Create a Dictionary:
21. Conclusion Python is a great option, whether you are a beginning programmer looking to learn the basics, an experienced programmer designing a large application, or anywhere in between. The basics of Python are easily grasped, and yet its capabilities are vast.
22. Reference https://www.udemy.com/course/learn- programming-with-python https://www.w3schools.com/python/default.asp
Strings in Python can be created using single quotes, double quotes, or triple quotes. Strings are immutable and indexing allows accessing individual characters. Strings can be sliced to extract substrings. The + operator is used for concatenation and * operator repeats strings. The split method returns a list of substrings split by a delimiter and join method concatenates strings with a delimiter.
This document discusses exception handling in C++. It defines an exception as an event that occurs during program execution that disrupts normal flow, like divide by zero errors. Exception handling allows the program to maintain normal flow even after errors by catching and handling exceptions. It describes the key parts of exception handling as finding problems, throwing exceptions, catching exceptions, and handling exceptions. The document provides examples of using try, catch, and throw blocks to handle exceptions in C++ code.
The document compares interpreters and compilers. It states that interpreters translate code line-by-line while compilers scan the entire program at once. Interpreters have faster analysis time but slower overall execution, while compilers have slower analysis but faster execution. Interpreters do not generate object code so are more memory efficient. Languages like JavaScript, Python and Ruby use interpreters, while C, C++ and Java use compilers.
Here are solutions to the exercises:
1. Write a program that reverses a string:
```java
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
System.out.print("Enter a string: ");
String input = scanner.nextLine();
String reversed = "";
for (int i = input.length() - 1; i >= 0; i--) {
reversed += input.charAt(i);
}
System.out.println("Reversed string: " + reversed);
}
}
```
2. Write a program to
This document discusses programming languages, compilers vs interpreters, and introduces Python. It explains that a programming language communicates instructions to a machine and can be used to create programs. An interpreter reads and executes code directly, while a compiler converts source code into machine code. Python is an interpreted, object-oriented language that is easy to learn yet powerful. It can be used for web, enterprise, and other applications. The document also provides basic information on Python syntax and data types.
Programming Fundamentals Functions in C and typesimtiazalijoono
Programming Fundamentals
Functions in C
Lecture Outline
• Functions
• Function declaration
• Function call
• Function definition
– Passing arguments to function
1) Passing constants
2) Passing variables
– Pass by value
– Returning values from functions
• Preprocessor directives
• Local and external variables
1. The document discusses creating threads using the Runnable interface in Java.
2. The Runnable interface contains only the run() method, which is implemented by classes that want instances to run as threads.
3. To create a thread using Runnable, a Thread object is instantiated and passed the Runnable target, or the Thread object can be instantiated within the Runnable class's constructor.
Templates allow functions and classes to operate on generic types in C++. There are two types of templates: class templates and function templates. Function templates are functions that can operate on generic types, allowing code to be reused for multiple types without rewriting. Template parameters allow types to be passed to templates, similar to how regular parameters pass values. When a class, function or static member is generated from a template, it is called template instantiation.
Arrays in Python can hold multiple values and each element has a numeric index. Arrays can be one-dimensional (1D), two-dimensional (2D), or multi-dimensional. Common operations on arrays include accessing elements, adding/removing elements, concatenating arrays, slicing arrays, looping through elements, and sorting arrays. The NumPy library provides powerful capabilities to work with n-dimensional arrays and matrices.
This document discusses recursive functions, which are functions that call themselves repetitively until a certain condition is satisfied. It provides an introduction to recursive functions, noting that they contain statements to determine if the function should call itself again, a function call with arguments, a conditional statement like if/else, and a return statement. It then provides two examples of recursive functions as class work: writing a program to find the product of two numbers recursively and writing a program to calculate a^b recursively.
The document provides information about various Python data structures concepts related to lists. It discusses list basics like creating, accessing and updating lists. It also covers list methods like append(), pop(), sort() etc. and how to pass, return and search lists in functions. Key topics include list operations, looping through lists, copying lists, multidimensional lists and comparing performance of lists and tuples.
The document discusses various topics related to lists in Python including:
- Lists can store multiple items of similar or different types in a single variable.
- List items can be accessed and modified using indexes.
- List slicing allows accessing elements within a specified index range.
- Built-in functions like len(), max(), min() etc. can be used to perform operations on lists.
- List methods allow adding, removing, and modifying elements in lists.
- Lists can be passed as arguments to functions and returned from functions.
This document discusses Python lists and their uses. Lists are a mutable data type that allows storing multiple values in a single variable. Values in a list can be accessed by index and lists can be sliced, concatenated, and modified using built-in methods. Lists are commonly used with for loops to iterate over elements. Strings can be split into lists of substrings using the split() method.
Tuple assignment allows multiple variables to be assigned values from an iterable like a list or tuple in a single statement. This is more concise than separate assignments and avoids using a temporary variable. For example, to swap the values of variables a and b, tuple assignment can be used: a, b = b, a. The left side must contain the same number of variables as there are elements on the right, and each value is assigned to the corresponding variable from left to right. Tuple assignment is useful for unpacking elements like splitting a string into parts.
This document discusses Python lists, including their definition as mutable, ordered sequences that can store multiple data types. It provides examples of list syntax, accessing and modifying list elements using indexes and methods like append(), insert(), pop(), and reverse(). The key characteristics of lists are outlined, such as being created with square brackets, indexed from 0, and supporting common operations like sorting, concatenation, and finding the minimum/maximum value. Various list methods and their usage are defined throughout with illustrative code samples.
The document discusses lists in Python. It begins by defining lists as mutable sequences that can contain elements of any data type. It describes how to create, access, manipulate, slice, traverse and delete elements from lists. It also explains various list methods such as append(), pop(), sort(), reverse() etc. and provides examples of their use. The document concludes by giving some programs on lists including finding the sum and maximum of a list, checking if a list is empty, cloning lists, checking for common members between lists and generating lists of square numbers.
Slicing in Python is a feature that enables accessing parts of sequences like strings, tuples, and lists. You can also use them to modify or delete the items of mutable sequences such as lists. Slices can also be applied on third-party objects like NumPy arrays, as well as Pandas series and data frames.
Slicing enables writing clean, concise, and readable code.
This article shows how to access, modify, and delete items with indices and slices, as well as how to use the built-in class slice().
The document discusses Python lists and their key features. It covers how lists are ordered sequences that can contain elements of different types. Lists are mutable and can be accessed using indexes. Common list operations include slicing, concatenation, repetition, sorting, and using various list methods like append(), extend(), index(), reverse() etc. Tuples are immutable sequences similar to lists. Dictionaries are another data type that store elements as key-value pairs. The document also briefly introduces regular expressions for text parsing and extraction.
Lists are mutable data structures that can contain elements of different data types. Some key list operations include:
1. Creating lists using square brackets and separating elements with commas. Nested lists are also possible.
2. Common list methods like append(), pop(), insert() allow adding, removing and modifying list elements.
3. Slicing lists using start and end indexes allows extracting sublist elements. The step parameter advances through elements.
4. Built-in functions like len(), index(), count() provide useful information about lists.
The document discusses lists, tuples, and dictionaries in Python. It provides examples and explanations of these core data types. Lists are ordered and mutable sequences enclosed in brackets. Tuples are ordered and immutable sequences enclosed in parentheses. Dictionaries store data as key-value pairs within curly braces. Common operations on each type like indexing, slicing, length, keys and values are described. Methods for modifying and traversing lists like append, pop, insert and sort are also outlined.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Happy bro.
With pdf.
I wrote anything.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Happy bro.
With pdf.
I wrote anything.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Happy bro.
With pdf.
I wrote anything.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Happy bro.
With pdf.
I wrote anything.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Happy bro.
With pdf.
I wrote anything.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Happy bro.
With pdf.
I wrote anything.
Python elements lists you can study
This is help you to study the python programing.This is useful for your learning.
Happy bro.
.
This document provides an overview of lists and tuples in Python. It discusses how to create, access, modify, and iterate over lists and tuples. Some key points covered include:
- Lists are mutable sequences that can contain elements of different types. Common list methods allow appending, inserting, removing, and sorting elements.
- Tuples are immutable lists that cannot be modified after creation. They provide count and index methods similar to lists.
- Lists and tuples can be nested to represent multi-dimensional data structures. Iteration over nested lists/tuples requires multiple for loops.
- Examples demonstrate common list/tuple operations like slicing, concatenation, membership testing, and traversing 2D lists to represent matrices for
This document provides information about data structures in Python. It discusses lists, tuples, sets, and dictionaries. For lists and tuples, it covers defining, indexing, slicing, unpacking, methods, built-in functions, and list comprehensions. Lists can contain heterogeneous elements and support methods like append(), pop(), sort(), and reverse(). Tuples are similar to lists but are immutable ordered sequences. They also support indexing, slicing, and unpacking. This document serves as a guide to working with common Python data structures.
Python supports several data types including numbers, strings, and lists. Numbers can be integer, float, or complex types. Strings are collections of characters that can be indexed, sliced, and manipulated using various string methods and operators. Lists are mutable sequences that can contain elements of different data types and support operations like indexing, slicing, sorting, and joining. Common list methods include append(), insert(), remove(), pop(), clear(), and sort(). Tuples are similar to lists but are immutable.
Python supports several numeric and non-numeric data types including integers, floats, complex numbers, strings, lists, and tuples. Numbers can be integers, floats, or complex, and support common operations. Strings are immutable sequences of characters that can be indexed, sliced, formatted, and concatenated. Lists are mutable sequences that can contain mixed data types, and support common operations like indexing, slicing, sorting, and joining. Tuples are similar to lists but are immutable.
The Ring programming language version 1.10 book - Part 30 of 212Mahmoud Samir Fayed
This document discusses lists in Ring programming language. It covers creating, accessing, modifying lists as well as common list operations like sorting, searching, reversing etc. Lists can contain other lists, allowing for nested data structures. Key points include:
- Lists are created using square brackets or range operators. Items can be added or removed using functions like Add(), Del().
- The len() function returns the number of items in a list. Individual items can be accessed using their index in square brackets.
- Common operations include sorting with sort(), reversing with reverse(), searching with find().
- Lists are passed by reference, so functions can modify the original list. They also support string indices to access items.
The document discusses lists in Python. Some key points:
- A list is a mutable ordered sequence of elements of any data type. Lists can be created using square brackets or the list() constructor.
- List elements can be accessed using indexes and sliced. Methods like append(), insert(), pop() etc. are used to modify lists.
- Lists support operations like membership testing, repetition, concatenation etc. Functions like len(), max(), min() etc. operate on lists.
- Lists can be passed to and returned from functions. List comprehension provides a concise way to create lists.
- Searching and sorting algorithms like linear search, binary search, bubble sort, selection sort can be
This document discusses lists and tuples in Python. It explains that lists are mutable containers that can hold heterogeneous data types and grow or shrink in size dynamically. Tuples are immutable containers that can also hold heterogeneous data types but have a fixed size after creation. The document covers how to define, access, slice, loop through and perform common operations on elements in lists and tuples. It also discusses built-in functions like len(), max(), min() that can operate on lists and tuples.
The Ring programming language version 1.5.3 book - Part 22 of 184Mahmoud Samir Fayed
This document provides summaries of key features of lists in Ring programming language. Lists allow storing multiple values in a single variable. Key points include:
- Lists can be created using square brackets or : operator and items can be added or removed.
- Functions like len(), find(), sort(), reverse() etc. allow getting length, searching, sorting and reversing lists.
- Lists support nested structures and can be passed to and returned from functions.
- String indices can be used to access items in lists containing pairs of string and values.
- Lists provide a way to pass variable number of parameters to functions in a flexible order.
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.
The document discusses installing Python 3 on Ubuntu and Windows systems. It provides step-by-step instructions for installing Python 3.8 using apt on Ubuntu and downloading/running the installer on Windows. Basic Python data visualization techniques like line plots, bar charts, histograms, box plots, and scatter plots are then introduced using the Matplotlib library. Code examples are given for creating each type of plot.
This document provides instructions on installing Python 3 on Ubuntu and Windows operating systems. It discusses installing Python 3.8 on Ubuntu using the apt install command and verifying the installation with the python --version command. It also outlines downloading the Python installer, running the executable, adding Python to environment variables, and verifying the installation on Windows. The document further explains installing iPython using pip and provides examples of using boolean values, conditionals, loops, functions, and strings in Python programs.
This slide includes :
Types of Machine Learning
Supervised Learning
Brain
Neuron
Design a Learning System
Perspectives
Issues in Machine Learning
Learning Task
Learning as Search
Hypothesis
Version Spaces
Candidate elimination algorithm
linear Discriminant
Perception
Linear Separability
Linear Regression
Unsupervised Learning
Reinforcement Learning
Evolutionary Learning
GSM-Mobility Management-Call Control
GRPS-Network elements
Radio Resource Management
Mobility Management and Session Management
Small Screen Web Browsing
UTRAN-Core and Radio Network Mobility Management
UMTS Security
This slide includes
Advanced multiplexing
Code Division Multiplexing
Dense Wavelength Division Multiplexing
OFDM
Connectionless
LAN
L3 SWTICH
SLIP
PPP
CORE AND DISTRIBUTION NETWORKS.
বাংলাদেশের অর্থনৈতিক সমীক্ষা ২০২৪ [Bangladesh Economic Review 2024 Bangla.pdf] কম্পিউটার , ট্যাব ও স্মার্ট ফোন ভার্সন সহ সম্পূর্ণ বাংলা ই-বুক বা pdf বই " সুচিপত্র ...বুকমার্ক মেনু 🔖 ও হাইপার লিংক মেনু 📝👆 যুক্ত ..
আমাদের সবার জন্য খুব খুব গুরুত্বপূর্ণ একটি বই ..বিসিএস, ব্যাংক, ইউনিভার্সিটি ভর্তি ও যে কোন প্রতিযোগিতা মূলক পরীক্ষার জন্য এর খুব ইম্পরট্যান্ট একটি বিষয় ...তাছাড়া বাংলাদেশের সাম্প্রতিক যে কোন ডাটা বা তথ্য এই বইতে পাবেন ...
তাই একজন নাগরিক হিসাবে এই তথ্য গুলো আপনার জানা প্রয়োজন ...।
বিসিএস ও ব্যাংক এর লিখিত পরীক্ষা ...+এছাড়া মাধ্যমিক ও উচ্চমাধ্যমিকের স্টুডেন্টদের জন্য অনেক কাজে আসবে ...
Main Java[All of the Base Concepts}.docxadhitya5119
This is part 1 of my Java Learning Journey. This Contains Custom methods, classes, constructors, packages, multithreading , try- catch block, finally block and more.
Walmart Business+ and Spark Good for Nonprofits.pdfTechSoup
"Learn about all the ways Walmart supports nonprofit organizations.
You will hear from Liz Willett, the Head of Nonprofits, and hear about what Walmart is doing to help nonprofits, including Walmart Business and Spark Good. Walmart Business+ is a new offer for nonprofits that offers discounts and also streamlines nonprofits order and expense tracking, saving time and money.
The webinar may also give some examples on how nonprofits can best leverage Walmart Business+.
The event will cover the following::
Walmart Business + (https://business.walmart.com/plus) is a new shopping experience for nonprofits, schools, and local business customers that connects an exclusive online shopping experience to stores. Benefits include free delivery and shipping, a 'Spend Analytics” feature, special discounts, deals and tax-exempt shopping.
Special TechSoup offer for a free 180 days membership, and up to $150 in discounts on eligible orders.
Spark Good (walmart.com/sparkgood) is a charitable platform that enables nonprofits to receive donations directly from customers and associates.
Answers about how you can do more with Walmart!"
LAND USE LAND COVER AND NDVI OF MIRZAPUR DISTRICT, UPRAHUL
This Dissertation explores the particular circumstances of Mirzapur, a region located in the
core of India. Mirzapur, with its varied terrains and abundant biodiversity, offers an optimal
environment for investigating the changes in vegetation cover dynamics. Our study utilizes
advanced technologies such as GIS (Geographic Information Systems) and Remote sensing to
analyze the transformations that have taken place over the course of a decade.
The complex relationship between human activities and the environment has been the focus
of extensive research and worry. As the global community grapples with swift urbanization,
population expansion, and economic progress, the effects on natural ecosystems are becoming
more evident. A crucial element of this impact is the alteration of vegetation cover, which plays a
significant role in maintaining the ecological equilibrium of our planet.Land serves as the foundation for all human activities and provides the necessary materials for
these activities. As the most crucial natural resource, its utilization by humans results in different
'Land uses,' which are determined by both human activities and the physical characteristics of the
land.
The utilization of land is impacted by human needs and environmental factors. In countries
like India, rapid population growth and the emphasis on extensive resource exploitation can lead
to significant land degradation, adversely affecting the region's land cover.
Therefore, human intervention has significantly influenced land use patterns over many
centuries, evolving its structure over time and space. In the present era, these changes have
accelerated due to factors such as agriculture and urbanization. Information regarding land use and
cover is essential for various planning and management tasks related to the Earth's surface,
providing crucial environmental data for scientific, resource management, policy purposes, and
diverse human activities.
Accurate understanding of land use and cover is imperative for the development planning
of any area. Consequently, a wide range of professionals, including earth system scientists, land
and water managers, and urban planners, are interested in obtaining data on land use and cover
changes, conversion trends, and other related patterns. The spatial dimensions of land use and
cover support policymakers and scientists in making well-informed decisions, as alterations in
these patterns indicate shifts in economic and social conditions. Monitoring such changes with the
help of Advanced technologies like Remote Sensing and Geographic Information Systems is
crucial for coordinated efforts across different administrative levels. Advanced technologies like
Remote Sensing and Geographic Information Systems
9
Changes in vegetation cover refer to variations in the distribution, composition, and overall
structure of plant communities across different temporal and spatial scales. These changes can
occur natural.
Beyond Degrees - Empowering the Workforce in the Context of Skills-First.pptxEduSkills OECD
Iván Bornacelly, Policy Analyst at the OECD Centre for Skills, OECD, presents at the webinar 'Tackling job market gaps with a skills-first approach' on 12 June 2024
ISO/IEC 27001, ISO/IEC 42001, and GDPR: Best Practices for Implementation and...PECB
Denis is a dynamic and results-driven Chief Information Officer (CIO) with a distinguished career spanning information systems analysis and technical project management. With a proven track record of spearheading the design and delivery of cutting-edge Information Management solutions, he has consistently elevated business operations, streamlined reporting functions, and maximized process efficiency.
Certified as an ISO/IEC 27001: Information Security Management Systems (ISMS) Lead Implementer, Data Protection Officer, and Cyber Risks Analyst, Denis brings a heightened focus on data security, privacy, and cyber resilience to every endeavor.
His expertise extends across a diverse spectrum of reporting, database, and web development applications, underpinned by an exceptional grasp of data storage and virtualization technologies. His proficiency in application testing, database administration, and data cleansing ensures seamless execution of complex projects.
What sets Denis apart is his comprehensive understanding of Business and Systems Analysis technologies, honed through involvement in all phases of the Software Development Lifecycle (SDLC). From meticulous requirements gathering to precise analysis, innovative design, rigorous development, thorough testing, and successful implementation, he has consistently delivered exceptional results.
Throughout his career, he has taken on multifaceted roles, from leading technical project management teams to owning solutions that drive operational excellence. His conscientious and proactive approach is unwavering, whether he is working independently or collaboratively within a team. His ability to connect with colleagues on a personal level underscores his commitment to fostering a harmonious and productive workplace environment.
Date: May 29, 2024
Tags: Information Security, ISO/IEC 27001, ISO/IEC 42001, Artificial Intelligence, GDPR
-------------------------------------------------------------------------------
Find out more about ISO training and certification services
Training: ISO/IEC 27001 Information Security Management System - EN | PECB
ISO/IEC 42001 Artificial Intelligence Management System - EN | PECB
General Data Protection Regulation (GDPR) - Training Courses - EN | PECB
Webinars: https://pecb.com/webinars
Article: https://pecb.com/article
-------------------------------------------------------------------------------
For more information about PECB:
Website: https://pecb.com/
LinkedIn: https://www.linkedin.com/company/pecb/
Facebook: https://www.facebook.com/PECBInternational/
Slideshare: http://www.slideshare.net/PECBCERTIFICATION
it describes the bony anatomy including the femoral head , acetabulum, labrum . also discusses the capsule , ligaments . muscle that act on the hip joint and the range of motion are outlined. factors affecting hip joint stability and weight transmission through the joint are summarized.
This document provides an overview of wound healing, its functions, stages, mechanisms, factors affecting it, and complications.
A wound is a break in the integrity of the skin or tissues, which may be associated with disruption of the structure and function.
Healing is the body’s response to injury in an attempt to restore normal structure and functions.
Healing can occur in two ways: Regeneration and Repair
There are 4 phases of wound healing: hemostasis, inflammation, proliferation, and remodeling. This document also describes the mechanism of wound healing. Factors that affect healing include infection, uncontrolled diabetes, poor nutrition, age, anemia, the presence of foreign bodies, etc.
Complications of wound healing like infection, hyperpigmentation of scar, contractures, and keloid formation.
2. Install Python 3 On Ubuntu
Prerequisites
Step 1.A system running Ubuntu
Step 2.A user account with sudo privileges
Step 3.Access to a terminal command-line (Ctrl–Alt–T)
Step 4.Make sure your environment is configured to use
Python 3.8
2
3. Install Python 3
Now you can start the installation of Python 3.8.
$sudo apt install python3.8
Allow the process to complete and verify the Python
version was installed successfully
$python ––version
3
4. Installing and using Python on Windows is very simple.
Step 1: Download the Python Installer binaries
Step 2: Run the Executable Installer
Step 3: Add Python to environmental variables
Step 4: Verify the Python Installation
4
5. Python Installation
Open the Python website in your web browser.
https://www.python.org/downloads/windows/
Once the installer is downloaded, run the Python installer.
Add the following path
C:Program FilesPython37-32: for 64-bit installation
Once the installation is over, you will see a Python Setup
Successful window.
You are ready to start developing Python applications in
your Windows 10 system.
5
6. iPython Installation
If you already have Python installed, you can use pip to
install iPython using the following command:
$pip install iPython
To use it, type the following command in your computer’s
terminal:
$ipython
6
7. Compound Data Type
List
List is an ordered sequence of items. Values in the list are called
elements.
List of values separated by commas within square brackets[ ].
Items in the lists can be of different data types.
Tuples
A tuple is same as list.
The set of elements is enclosed in parentheses.
A tuple is an immutable list.
i.e. once a tuple has been created, you can't add elements to a
tuple or remove elements from the tuple.
Tuple can be converted into list and list can be converted in to tuple.
8. Compound Data Type
Dictionary
Dictionary is an unordered collection of elements.
An element in dictionary has a key: value pair.
All elements in dictionary are placed inside the curly braces{ }
Elements in dictionaries are accessed via keys and not by their
position.
The values of a dictionary can be any data type.
Keys must be immutable data type.
10. List
Operations on list
1. Indexing
2. Slicing
3. Concatenation
4. Repetitions
5. Updating
6. Membership
7. Comparison
11. List
.
Operation Example Description
create a list
>>> a=[2,3,4,5,6,7,8,9,10]
>>> print(a)
[2, 3, 4, 5, 6, 7, 8, 9, 10]
we can create a list at compile
time
Indexing
>>> print(a[0])
2
>>> print(a[8])
10
>>> print(a[-1])
10
Accessing the item in the
position 0
Accessing the item in the
position 8
Accessing a last element using
negative indexing.
Slicing
>>> print(a[0:3])
[2, 3, 4]
>>> print(a[0:])
[2, 3, 4, 5, 6, 7, 8, 9, 10]
Printing a part of the list.
Concatenation
>>>b=[20,30]
>>> print(a+b)
[2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30]
Adding and printing the items of
two lists.
Repetition
>>> print(b*3)
[20, 30, 20, 30, 20, 30]
Create a multiple copies of the
same list.
Updating
>>> print(a[2])
4
>>> a[2]=100
>>> print(a)
[2, 3, 100, 5, 6, 7, 8, 9, 10]
Updating the list using index
value.
12. List
List slices
List slicing is an operation that extracts a subset of elements from an
list.
Operation Example Description
Membership
>>> a=[2,3,4,5,6,7,8,9,10]
>>> 5 in a
True
>>> 100 in a
False
>>> 2 not in a
False
Returns True if element is
present in list. Otherwise returns
false.
Comparison
>>> a=[2,3,4,5,6,7,8,9,10]
>>>b=[2,3,4]
>>> a==b
False
>>> a!=b
True
Returns True if all elements in
both elements are same.
Otherwise returns false
13. List
Syntax
listname[start:stop]
listname[start:stop:steps]
Default start value is 0
Default stop value is n-1
[:] this will print the entire list
[2:2] this will create a empty slice slices example
Slices Example Description
a[0:3]
>>> a=[9,8,7,6,5,4]
>>> a[0:3]
[9, 8, 7]
Printing a part of a list from 0 to
2.
a[:4] >>> a[:4]
[9, 8, 7, 6]
Default start value is 0. so prints
from 0 to 3
a[1:] >>> a[1:]
[8, 7, 6, 5, 4]
Default stop value will be n-1. so
prints from 1 to 5
14. List
List methods
Methods used in lists are used to manipulate the data quickly.
These methods work only on lists.
They do not work on the other sequence types that are not mutable,
that is, the values cannot be changed.
Syntax
list name.method name( element/index/list)
Slices Example Description
list.append(element)
>>> a=[1,2,3,4,5]
>>> a.append(6)
>>> print(a)
[1, 2, 3, 4, 5, 6]
Add an element to the end of the
list
list.insert(index,element
)
>>> a.insert(0,0)
>>> print(a)
[0, 1, 2, 3, 4, 5, 6]
Insert an item at the defined
index
min(list) >>> min(a)
2
Return the minimum element in a
list
15. List
. Syntax Example Description
list.extend(b)
>>> b=[7,8,9]
>>> a.extend(b)
>>> print(a)
[0, 1, 2, 3, 4, 5, 6, 7, 8,9]
Add all elements of a list to the
another list
list,index(element)
>>> a.index(8)
8
Returns the index of the element
list.sort()
>>> a.sort()
>>> print(a)
[0, 1, 2, 3, 4, 5, 6, 7, 8,9]
Sort items in a list
list.reverse()
>>> a.reverse()
>>> print(a)
[9,8, 7, 6, 5, 4, 3, 2, 1, 0]
Reverse the order.
list.remove(element)
>>> a.remove(0)
>>> print(a)
[9,8,7, 6, 5, 4, 3, 2,1]
Removes an item from the list
list.copy()
>>> b=a.copy()
>>> print(b)
[9,8,7, 6, 5, 4, 3, 2,1]
Copy from a to b
len(list)
>>>len(a)
9
Length of the list
17. List
List loops
1. for loop
2. while loop
3. infinite loop
for Loop
The for loop in python is used to iterate over a sequence (list, tuple,
string) or other iterable objects.
Iterating over a sequence is called traversal.
Loop continues until we reach the last item in the sequence.
The body of for loop is separated from the rest of the code using
indentation.
Syntax:
for variable in sequence:
18. List
Example
Accessing element
a=[10,20,30,40,50]
for i in a:
print(i)
Output
10
20
30
40
50
Accessing index output
a=[10,20,30,40,50]
for i in range(0,len(a),1):
print(i)
output
0
1
2
3
4
Accessing element using range
a=[10,20,30,40,50]
for i in range(0,len(a),1):
print(a[i])
----------------------------------------------------------
print(id(a[i])) # for memory address
output
10
20
30
40
50
19. List
While loop
The while loop is used to iterate over a block of code as long as the
test condition is true.
When the condition is tested and the result is false, the loop body
will be skipped and the first statement after the while loop will be
executed.
Syntax:
while (condition):
body of the statement
Example: Sum of the elements in
list
a=[1,2,3,4,5]
i=0
sum=0
while i<len(a):
sum=sum+a[i]
i=i+1
print(sum)
Output
15
20. List
infinite Loop
A loop becomes infinite loop if the condition becomes false.
It keeps on running. Such loops are called infinite loop.
Example:
a=1
while (a==1):
n=int(input("enter the number"))
print("you entered:" , n)
Output
Enter the number 10
you entered:10
Enter the number 12
you entered:12
Enter the number 16
you entered:16
21. List
Mutability
Lists are mutable.(It can be changed)
Mutability is the ability for certain types of data to be changed without
entirely recreating it.
An item can be changed in a list by accessing it directly as part of the
assignment statement.
Using the indexing operator on the left side of an assignment, one of
the list items can be updated.
Example:
>>> a=[1,2,3,4,5]
>>> a[0]=100
>>> print(a)
[100, 2, 3, 4, 5]
changing single element
>>> a=[1,2,3,4,5]
>>> a[0:3]=[100,100,100]
>>> print(a)
[100, 100, 100, 4, 5]
changing multiple element
22. List
Aliasing(copying)
Creating a copy of a list is called aliasing.
When you create a copy both list will be having same memory location.
Changes in one list will affect another list.
Aliasing refers to having different names for same list values.
Example:
a= [1, 2, 3 ,4 ,5]
b=a
print (b)
a is b
a[0]=100
print(a)
print(b)
[1, 2, 3, 4, 5]
[100,2,3,4,5]
[100,2,3,4,5]
23. List
Cloning
Creating a copy of a same list of elements with different memory
locations is called cloning.
Changes in one list will not affect locations of another list.
Cloning is a process of making a copy of the list without modifying the
original list.
1. Slicing
2. list()method
3. copy() method
Example:
cloning using Slicing
>>>a=[1,2,3,4,5]
>>>b=a[:]
>>>print(b)
[1,2,3,4,5]
>>>a is b
False
24. List
. clonning using list() method
>>>a=[1,2,3,4,5]
>>>b=list(a)
>>>print(b)
[1,2,3,4,5]
>>>a is b
false
>>>a[0]=100
>>>print(a)
>>>a=[100,2,3,4,5]
>>>print(b)
>>>b=[1,2,3,4,5]
clonning using copy() method
a=[1,2,3,4,5]
>>>b=a.copy()
>>> print(b)
[1, 2, 3, 4, 5]
>>> a is b
False
25. List
List as parameters
Arguments are passed by reference.
If any changes are done in the parameter, then the changes also
reflects back in the calling function.
When a list to a function is passed, the function gets a reference to the
list.
Passing a list as an argument actually passes a reference to the list, not
a copy of the list.
Lists are mutable, changes made to the elements.
Example
def remove(a):
a.remove(1)
a=[1,2,3,4,5]
remove(a)
print(a)
Output
[2,3,4,5]
26. List
. Example 2:
def inside(a):
for i in range(0,len(a),1):
a[i]=a[i]+10
print(“inner”,a)
a=[1,2,3,4,5]
inside(a)
print(“outer”,a)
output
inner [11, 12, 13, 14, 15]
outer [11, 12, 13, 14, 15]
Example3:
def insert(a):
a.insert(0,30)
a=[1,2,3,4,5]
insert(a)
print(a)
output
[30, 1, 2, 3, 4, 5]
27. List
Practice
1.list=[‘p’,’r’,’I’,’n’,’t’]
print list[-3:]
Ans:
Error, no parenthesis in print statement.
2.Listout built-in functions.
Ans:
max(3,4),min(3,4),len(“raj”),range(2,8,1),round(7.8),float(5),int(5.0)
3.List is mutable-Justify
Ans:
List is an ordered sequence of items. Values in the list are called elements/items.
List is mutable. i.e. Values can be changed.
a=[1,2,3,4,5,6,7,8,9,10]
a[2]=100
print(a) -> [1,2,100,4,5,6,7,8,9,10]
28. Advanced list processing
List Comprehension
List comprehensions provide a brief way to apply operations on a list.
It creates a new list in which each element is the result of applying a
given operation in a list.
It consists of brackets containing an expression followed by a “for”
clause, then a list.
The list comprehension always returns a result list.
Syntax
list=[ expression for item in list if conditional ]
29. Advanced list processing
.
List Comprehension output
>>>L=[x**2 for x in range(0,5)]
>>>print(L)
[0, 1, 4, 9, 16]
>>>[x for x in range(1,10) if x%2==0] [2, 4, 6, 8]
>>>[x for x in 'Python Programming' if x in
['a','e','i','o','u']]
['o', 'o', 'a', 'i']
>>>mixed=[1,2,"a",3,4.2]
>>> [x**2 for x in mixed if type(x)==int]
[1, 4, 9]
>>>[x+3 for x in [1,2,3]] [4, 5, 6]
>>> [x*x for x in range(5)] [0, 1, 4, 9, 16]
>>> num=[-1,2,-3,4,-5,6,-7]
>>> [x for x in num if x>=0]
[2, 4, 6]
>>> str=["this","is","an","example"]
>>> element=[word[0] for word in str]
>>> print(element)
['t', 'i', 'a', 'e']
30. Nested list
List inside another list is called nested list.
Example
>>> a=[56,34,5,[34,57]]
>>> a[0]
56
>>> a[3]
[34, 57]
>>> a[3][0]
34
>>> a[3][1]
57
31. Tuple
A tuple is same as list, except in parentheses instead of square
brackets.
A tuple is an immutable list. i.e. can not be changed.
Tuple can be converted into list and list can be converted in to tuple.
Benefit:
Tuples are faster than lists.
Tuple can be protected the data.
Tuples can be used as keys in dictionaries, while lists can't.
Operations on Tuples:
1. Indexing
2. Slicing
3. Concatenation
4. Repetitions
5. Membership
6. Comparison
32. Tuple
. Operations Example Description
Creating a tuple
>>>a=(20,40,60,”raj”,”man”) Creating the tuple with different
data types.
Indexing
>>>print(a[0])
20
Accessing the item in the position
0
Slicing
>>>print(a[1:3])
(40,60)
Displaying elements from 1st to
2nd.
Concatenation
>>> b=(2,4)
>>>print(a+b)
>>>(20,40,60,”raj”,”man”,2,4)
Adding tuple elements.
Repetition
>>>print(b*2)
>>>(2,4,2,4)
Repeating the tuple
Membership
>>> a=(2,3,4,5,6,7,8,9,10)
>>> 5 in a
True
>>> 2 not in a
False
If element is present in tuple
returns TRUE else FALSE
Comparison
>>> a=(2,3,4,5,6,7,8,9,10)
>>>b=(2,3,4)
>>> a==b
False
If all elements in both tuple same
display TRUE else FALSE
33. Tuple
Tuple methods
Tuple is immutable. i.e. changes cannot be done on the elements of a
tuple once it is assigned.
Methods Example Description
tuple.index(element)
>>> a=(1,2,3,4,5)
>>> a.index(5)
4
Display the index number of
element.
tuple.count(element)
>>>a=(1,2,3,4,5)
>>> a.count(3)
1
Number of count of the given
element.
len(tuple)
>>> len(a)
5
The length of the tuple
min(tuple)
>>> min(a)
1
The minimum element in a tuple
max(tuple)
>>>max(a)
5
The maximum element in a tuple
del(tuple) >>>del(a) Delete the tuple.
34. Tuple
Convert tuple into list
Convert list into tuple
Methods
Example
Description
list(tuple)
>>>a=(1,2,3,4,5)
>>>a=list(a)
>>>print(a)
[1, 2, 3, 4, 5]
Convert the given tuple into
list.
Methods
Example
Description
tuple(list)
>>> a=[1,2,3,4,5]
>>> a=tuple(a)
>>> print(a)
(1, 2, 3, 4, 5)
Convert the given list into
tuple.
35. Tuple
Tuple Assignment
Tuple assignment allows, variables on the left of an assignment operator and
values on the right of the assignment operator.
Multiple assignment works by creating a tuple of expressions from the right
hand side, and a tuple of targets from the left, and then matching each
expression to a target.
It is useful to swap the values of two variables.
Example:
Swapping using temporary variable Swapping using tuple assignment
a=20
b=50
temp=a
a=b
b=temp
print("value after swapping is",a,b)
a=20
b=50
(a,b)=(b,a)
print("value after swapping is",a,b)
36. Tuple
Multiple assignments
Multiple values can be assigned to multiple variables using tuple
assignment.
Example
>>>(a,b,c)=(1,2,3)
>>>print(a)
1
>>>print(b)
2
>>>print(c)
3
37. Tuple
Tuple as return value
A Tuple is a comma separated sequence of items.
It is created with or without ( ).
A function can return one value.
if you want to return more than one value from a function then use tuple
as return value.
Example:
Program to find quotient and reminder output
def div(a,b):
r=a%b
q=a//b
return(r,q)
a=eval(input("enter a value:"))
b=eval(input("enter b value:"))
r,q=div(a,b)
print("reminder:",r)
print("quotient:",q)
enter a value:5
enter b value:4
reminder: 1
quotient: 1
38. Tuple
Tuple as argument
The parameter name that begins with * gathers argument into a tuple.
Example
def printall(*args):
print(args)
printall(2,3,'a')
Output:
(2, 3, 'a')
39. Dictionaries
Dictionary is an unordered collection of elements.
An element in dictionary has a key:value pair.
All elements in dictionary are placed inside the curly braces i.e. { }
Elements in Dictionaries are accessed via keys.
The values of a dictionary can be any data type.
Keys must be immutable data type.
Operations on dictionary
1. Accessing an element
2. Update
3. Add element
4. Membership
40. Dictionaries
. Operations Example Description
Creating a
dictionary
>>> a={1:"one",2:"two"}
>>> print(a)
{1: 'one', 2: 'two'}
Creating the dictionary with
different data types.
Accessing an
element
>>> a[1]
'one'
>>> a[0]
KeyError: 0
Accessing the elements by
using keys.
Update
>>> a[1]="ONE"
>>> print(a)
{1: 'ONE', 2: 'two'}
Assigning a new value to key.
Add element
>>> a[3]="three"
>>> print(a)
{1: 'ONE', 2: 'two', 3: 'three'}
Add new element in to the
dictionary with key.
Membership
a={1: 'ONE', 2: 'two', 3: 'three'}
>>> 1 in a
True
>>> 3 not in a
False
If the key is present in
dictionary returns TRUE else
FALSE
41. Dictionaries
Methods in dictionary
Method Example Description
Dictionary.copy()
a={1: 'ONE', 2: 'two', 3: 'three'}
>>> b=a.copy()
>>> print(b)
{1: 'ONE', 2: 'two', 3: 'three'}
copy dictionary ’a’ to
dictionary ‘b’
Dictionary.items()
>>> a.items()
dict_items([(1, 'ONE'), (2,
'two'), (3, 'three')])
It displays a list of
dictionary’s (key, value) tuple
pairs.
Dictionary.key() >>> a.keys()
dict_keys([1, 2, 3])
Displays list of keys in a
dictionary.
Dictionary.values()
>>> a.values()
dict_values(['ONE', 'two',
'three'])
Displays list of values in a
dictionary.
Dictionary.pop(key
)
>>> a.pop(3)
'three'
>>> print(a)
{1: 'ONE', 2: 'two'}
Remove the element with
key.
43. Comparison of List, Tuples and Dictionary
. List Tuple Dictionary
A list is mutable A tuple is immutable A dictionary is mutable
Lists are dynamic Tuples are static Values can be of any
data type and can
repeat.
Keys must be of
immutable type
Homogenous Heterogeneous Homogenous
Slicing can be done Slicing can be done Slicing can't be done