The document provides an introduction to Python programming, including details about Python's history, versions, data types, strings, and code execution. It discusses how to install Python and write basic programs. Key reasons for using Python are its object-oriented nature, readability, large standard library, cross-platform capabilities, and ease of use. The document also covers string methods and slicing, numeric data types, installing Python, and running code in interactive and script modes.
Python is a general purpose programming language that can be used for both programming and scripting. It was created in the 1990s by Guido van Rossum. Python is an interpreted language that is free, powerful, and portable. It can be used for tasks like web development, data analysis, and system scripting. The document provides an overview of Python including its history, uses, data types like strings and lists, and basic programming concepts like variables, conditionals, and loops. It recommends Python as a principal teaching language due to its free and easy installation, flexibility, use in academia and industry, and ability to offer a more rapid and enjoyable learning experience for students.
This document provides an overview and introduction to Python programming. It discusses Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also covers commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics. The document is intended as a whistle-stop tour to cover the most common aspects of Python.
This document provides an introduction to Python programming language. It discusses what Python is, its features, applications, and how it compares to compiled languages in terms of compiling versus interpreting. It also covers installing Python, different Python environments like the Python shell, IDLE, Jupyter Notebook, and Anaconda. Basic Python concepts like variables, data types, operators, functions, modules, and math module commands are explained. The reader is instructed to install NumPy and SciPy using conda for the next lab and test the installations.
This document provides a high-level summary of an introduction to Python programming course. The summary includes an overview of Python basics like variables, data types, operators, conditionals, loops, functions and file handling. It also discusses commonly used Python libraries and concepts in data analytics like NumPy, Pandas, Matplotlib and statistics.
web programming UNIT VIII python by Bhavsingh MalothBhavsingh Maloth
Ìý
This document provides a tutorial on Python programming. It introduces core Python concepts over several sections. The first section discusses what will be covered, including an introduction to the Python language and becoming comfortable writing basic programs. Subsequent sections cover specific Python topics like data types, operators, conditional and loop execution, functions, modules and packages for code reusability. The document emphasizes consistent indentation and readability in Python code.
This tutorial provides an introduction to the Python programming language. It will cover Python's core features like syntax, data types, operators, conditional and loop execution, functions, modules and packages to enable writing basic programs. The tutorial is intended for learners to learn Python together through questions, discussions and pointing out mistakes.
This document provides an introduction to Python programming. It discusses that Python is an interpretive language and describes advantages like automatic memory management and disadvantages like slower speed compared to compiled languages. It also covers Python versions, the Anaconda IDE, variables and data types, operators, strings, lists, tuples, dictionaries, conditional statements, loops and functions like range(). Examples are provided throughout to demonstrate the core concepts of Python syntax and programming.
Interpreter v/s Compiler summarizes the key differences between interpreters and compilers. Interpreters translate programs one statement at a time with no object code generated, making them more memory efficient. Compilers scan entire programs and translate them into machine code at once, generating object code and requiring more memory but providing faster overall execution time. Popular languages like JavaScript, Python, and Ruby use interpreters while C, C++, and Java use compilers.
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.
The document provides an overview of the basics of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented scripting language. It also covers Python's history and describes it as being easy to learn and read, easy to maintain, portable, and extensible. The document then details Python's core data types including numbers, strings, lists, tuples, and dictionaries. It provides examples of how to define and manipulate variables of each data type in Python.
The document provides instructions for downloading and installing Python and PyCharm on Mac and Windows systems. It outlines the steps to download each program from their respective websites, then guides the user through installing Python and PyCharm on their device by navigating folders and clicking through installation windows. It also briefly introduces some basic programming concepts that will be covered in an upcoming Python tutorial, such as variables, data types, conditional statements, and loops.
This document provides an overview of the Python programming language. It begins by explaining what Python is, noting that it is a general purpose programming language that is often used for scripting. The key differences between program and scripting languages are then outlined. The history and creation of Python by Guido van Rossum are summarized, along with Python's scope in fields like science, system administration, and web development. Various uses of Python are listed, followed by who commonly uses Python today such as Google and YouTube. Reasons for Python's popularity include being free, powerful, and portable. The document concludes by covering installing Python, running and executing Python code, and some basic Python concepts like strings, variables, data types, and loops/
Python is a cross-platform programming language that can run on Windows, macOS, Linux, and other platforms. It is free and open-source. While most modern operating systems come with Python pre-installed, it is generally recommended to install the latest version separately. The Thonny IDE is a simple Python IDE that bundles the latest Python version, so it can run Python programs without requiring a separate Python installation. Thonny has features like an easy-to-use debugger and code completion that make it suitable for beginners learning Python.
Python is a general purpose programming language that can be used for web development, system administration, science and more. It is interpreted rather than compiled, and was created in the 1990s by Guido van Rossum to be highly readable. Python is widely used by companies like Google, YouTube, Intel and more due to its power, flexibility and readability. It supports key programming concepts like variables, conditionals, loops, lists, tuples and more.
This document provides an overview of the Python programming language. It begins by explaining what Python is - a general purpose, interpreted programming language that can be used as both a programming and scripting language. It then discusses the differences between programs and scripting languages. The history and creator of Python, Guido van Rossum, are outlined. The document explores the scope of Python and what tasks it can be used for. Popular companies and industries that use Python today are listed. Reasons why people use Python, such as it being free, powerful, and portable, are provided. Instructions for installing Python and running Python code are included. The document covers Python code execution and introduces basic Python concepts like variables, strings, data types, lists
This document provides an introduction and overview of the Python programming language. It discusses Python's key features such as being an interpreted, object-oriented, high-level programming language with dynamic typing and a large standard library. It also covers Python's use as both a scripting and general purpose language. The document then discusses Python's data types, operators, control flow statements, functions, and lambda expressions. It provides examples of using Python interactively and in script mode.
Computers require programming languages to communicate instructions. Python is an easy to read, powerful, and freely available programming language. It was created in the 1990s and takes its name from Monty Python. Python supports key programming concepts like variables, data types, control structures, and functions that allow it to solve a variety of problems through sequential execution of instructions.
This document provides information about Jupyter Notebook, including:
- Jupyter Notebook is an open-source web application for creating and sharing documents containing live code, equations, visualizations, and narrative text.
- It works locally on localhost port 8888 and the easiest way to install it is through Anaconda which includes Jupyter Notebook and popular Python libraries.
- Notebooks use kernels to run code in different programming languages, with IPython being the default Python kernel.
4_Introduction to Python Programming.pptxGnanesh12
Ìý
This document provides an introduction to Python programming. It discusses the fundamentals of computing and problem solving, including algorithms and pseudocodes. It then describes the history and development of the Python programming language. Key features of Python like being easy to learn, cross-platform, and having a large standard library are outlined. Different modes of running Python like interactive and script modes are explained. Finally, it covers basic Python concepts like data types, values, variables, and statements.
Python-Beginer-PartOnePython is one of the top programming languages in the w...ahmedosman389
Ìý
Python is one of the top programming languages in the world, widely used in fields such as AI, machine learning, data science, and web development.
The simple and English-like syntax of Python makes it a go-to language for beginners who want to get into coding quickly.
Because Python is used in multiple fields, there is a high demand for Python developers, with competitive base salaries.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
Ìý
This document discusses Python programming concepts including data types, variables, operators, and functions. It provides examples of Python syntax for writing and executing code as well as built-in data types like strings, integers, and lists. Key concepts covered include variables, data type casting, comments, arithmetic and comparison operators, and functions.
This document lists various short words and letters with no clear meaning or context. It includes bullet points with 1-2 word items but does not convey any coherent ideas, concepts, or information that could be summarized in a concise way.
Interpreter v/s Compiler summarizes the key differences between interpreters and compilers. Interpreters translate programs one statement at a time with no object code generated, making them more memory efficient. Compilers scan entire programs and translate them into machine code at once, generating object code and requiring more memory but providing faster overall execution time. Popular languages like JavaScript, Python, and Ruby use interpreters while C, C++, and Java use compilers.
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.
The document provides an overview of the basics of the Python programming language. It discusses that Python is an interpreted, interactive, object-oriented scripting language. It also covers Python's history and describes it as being easy to learn and read, easy to maintain, portable, and extensible. The document then details Python's core data types including numbers, strings, lists, tuples, and dictionaries. It provides examples of how to define and manipulate variables of each data type in Python.
The document provides instructions for downloading and installing Python and PyCharm on Mac and Windows systems. It outlines the steps to download each program from their respective websites, then guides the user through installing Python and PyCharm on their device by navigating folders and clicking through installation windows. It also briefly introduces some basic programming concepts that will be covered in an upcoming Python tutorial, such as variables, data types, conditional statements, and loops.
This document provides an overview of the Python programming language. It begins by explaining what Python is, noting that it is a general purpose programming language that is often used for scripting. The key differences between program and scripting languages are then outlined. The history and creation of Python by Guido van Rossum are summarized, along with Python's scope in fields like science, system administration, and web development. Various uses of Python are listed, followed by who commonly uses Python today such as Google and YouTube. Reasons for Python's popularity include being free, powerful, and portable. The document concludes by covering installing Python, running and executing Python code, and some basic Python concepts like strings, variables, data types, and loops/
Python is a cross-platform programming language that can run on Windows, macOS, Linux, and other platforms. It is free and open-source. While most modern operating systems come with Python pre-installed, it is generally recommended to install the latest version separately. The Thonny IDE is a simple Python IDE that bundles the latest Python version, so it can run Python programs without requiring a separate Python installation. Thonny has features like an easy-to-use debugger and code completion that make it suitable for beginners learning Python.
Python is a general purpose programming language that can be used for web development, system administration, science and more. It is interpreted rather than compiled, and was created in the 1990s by Guido van Rossum to be highly readable. Python is widely used by companies like Google, YouTube, Intel and more due to its power, flexibility and readability. It supports key programming concepts like variables, conditionals, loops, lists, tuples and more.
This document provides an overview of the Python programming language. It begins by explaining what Python is - a general purpose, interpreted programming language that can be used as both a programming and scripting language. It then discusses the differences between programs and scripting languages. The history and creator of Python, Guido van Rossum, are outlined. The document explores the scope of Python and what tasks it can be used for. Popular companies and industries that use Python today are listed. Reasons why people use Python, such as it being free, powerful, and portable, are provided. Instructions for installing Python and running Python code are included. The document covers Python code execution and introduces basic Python concepts like variables, strings, data types, lists
This document provides an introduction and overview of the Python programming language. It discusses Python's key features such as being an interpreted, object-oriented, high-level programming language with dynamic typing and a large standard library. It also covers Python's use as both a scripting and general purpose language. The document then discusses Python's data types, operators, control flow statements, functions, and lambda expressions. It provides examples of using Python interactively and in script mode.
Computers require programming languages to communicate instructions. Python is an easy to read, powerful, and freely available programming language. It was created in the 1990s and takes its name from Monty Python. Python supports key programming concepts like variables, data types, control structures, and functions that allow it to solve a variety of problems through sequential execution of instructions.
This document provides information about Jupyter Notebook, including:
- Jupyter Notebook is an open-source web application for creating and sharing documents containing live code, equations, visualizations, and narrative text.
- It works locally on localhost port 8888 and the easiest way to install it is through Anaconda which includes Jupyter Notebook and popular Python libraries.
- Notebooks use kernels to run code in different programming languages, with IPython being the default Python kernel.
4_Introduction to Python Programming.pptxGnanesh12
Ìý
This document provides an introduction to Python programming. It discusses the fundamentals of computing and problem solving, including algorithms and pseudocodes. It then describes the history and development of the Python programming language. Key features of Python like being easy to learn, cross-platform, and having a large standard library are outlined. Different modes of running Python like interactive and script modes are explained. Finally, it covers basic Python concepts like data types, values, variables, and statements.
Python-Beginer-PartOnePython is one of the top programming languages in the w...ahmedosman389
Ìý
Python is one of the top programming languages in the world, widely used in fields such as AI, machine learning, data science, and web development.
The simple and English-like syntax of Python makes it a go-to language for beginners who want to get into coding quickly.
Because Python is used in multiple fields, there is a high demand for Python developers, with competitive base salaries.
Basic concept of Python.pptx includes design tool, identifier, variables.supriyasarkar38
Ìý
This document discusses Python programming concepts including data types, variables, operators, and functions. It provides examples of Python syntax for writing and executing code as well as built-in data types like strings, integers, and lists. Key concepts covered include variables, data type casting, comments, arithmetic and comparison operators, and functions.
This document lists various short words and letters with no clear meaning or context. It includes bullet points with 1-2 word items but does not convey any coherent ideas, concepts, or information that could be summarized in a concise way.
This document does not contain any meaningful information to summarize. It consists of random letters, words and punctuation with no coherent sentences, paragraphs or overall meaning.
This document lists a series of letters, words, and sentences without context or apparent meaning. It includes various single letters, unintelligible words, and short phrases that do not form a coherent paragraph, story, or other structured piece of writing. The document appears to be random typings without a clear purpose or message.
This document does not contain any meaningful information to summarize. It consists of random letters and symbols with no context or identifiable topics, people, places, events, or other elements that could be coherently summarized.
1. Data refers to raw facts and statistics that are stored or transmitted, while information is data that has been organized and structured to be useful.
2. Big data is a large collection of data that cannot be processed by traditional data management tools due to its huge size and complexity.
3. Big data has three key characteristics - volume, referring to the large amount of data; velocity, referring to the speed at which new data is generated and collected; and variety, referring to the different types and sources of data.
Computer Application in Business (commerce)Sudar Sudar
Ìý
The main objectives
1. To introduce the concept of computer and its various parts. 2. To explain the concept of data base management system and Management information system.
3. To provide insight about networking and basics of internet
Recall various terms of computer and its part
Understand the meaning of software, operating system, programming language and its features
Comparing Data Vs Information and its management system Understanding about various concepts of management information system
Explain about networking and elements based on internet
1. Recall the various concepts relating to computer and its various parts
2 Understand the meaning of software’s, operating system etc
3 Understanding the meaning and utility of database management system
4 Evaluate the various aspects of management information system
5 Generating more ideas regarding the use of internet for business purpose
How to Configure Flexible Working Schedule in Odoo 18 EmployeeCeline George
Ìý
In this slide, we’ll discuss on how to configure flexible working schedule in Odoo 18 Employee module. In Odoo 18, the Employee module offers powerful tools to configure and manage flexible working schedules tailored to your organization's needs.
How to Configure Restaurants in Odoo 17 Point of SaleCeline George
Ìý
Odoo, a versatile and integrated business management software, excels with its robust Point of Sale (POS) module. This guide delves into the intricacies of configuring restaurants in Odoo 17 POS, unlocking numerous possibilities for streamlined operations and enhanced customer experiences.
Computer Network Unit IV - Lecture Notes - Network LayerMurugan146644
Ìý
Title:
Lecture Notes - Unit IV - The Network Layer
Description:
Welcome to the comprehensive guide on Computer Network concepts, tailored for final year B.Sc. Computer Science students affiliated with Alagappa University. This document covers fundamental principles and advanced topics in Computer Network. PDF content is prepared from the text book Computer Network by Andrew S. Tenanbaum
Key Topics Covered:
Main Topic : The Network Layer
Sub-Topic : Network Layer Design Issues (Store and forward packet switching , service provided to the transport layer, implementation of connection less service, implementation of connection oriented service, Comparision of virtual circuit and datagram subnet), Routing algorithms (Shortest path routing, Flooding , Distance Vector routing algorithm, Link state routing algorithm , hierarchical routing algorithm, broadcast routing, multicast routing algorithm)
Other Link :
1.Introduction to computer network - /slideshow/lecture-notes-introduction-to-computer-network/274183454
2. Physical Layer - /slideshow/lecture-notes-unit-ii-the-physical-layer/274747125
3. Data Link Layer Part 1 : /slideshow/lecture-notes-unit-iii-the-datalink-layer/275288798
Target Audience:
Final year B.Sc. Computer Science students at Alagappa University seeking a solid foundation in Computer Network principles for academic.
About the Author:
Dr. S. Murugan is Associate Professor at Alagappa Government Arts College, Karaikudi. With 23 years of teaching experience in the field of Computer Science, Dr. S. Murugan has a passion for simplifying complex concepts in Computer Network
Disclaimer:
This document is intended for educational purposes only. The content presented here reflects the author’s understanding in the field of Computer Network
How to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣsCeline George
Ìý
Integrate WhatsApp into Odoo using the WhatsApp Business API or third-party modules to enhance communication. This integration enables automated messaging and customer interaction management within Odoo 17.
Blind Spots in AI and Formulation Science Knowledge Pyramid (Updated Perspect...Ajaz Hussain
Ìý
This presentation delves into the systemic blind spots within pharmaceutical science and regulatory systems, emphasizing the significance of "inactive ingredients" and their influence on therapeutic equivalence. These blind spots, indicative of normalized systemic failures, go beyond mere chance occurrences and are ingrained deeply enough to compromise decision-making processes and erode trust.
Historical instances like the 1938 FD&C Act and the Generic Drug Scandals underscore how crisis-triggered reforms often fail to address the fundamental issues, perpetuating inefficiencies and hazards.
The narrative advocates a shift from reactive crisis management to proactive, adaptable systems prioritizing continuous enhancement. Key hurdles involve challenging outdated assumptions regarding bioavailability, inadequately funded research ventures, and the impact of vague language in regulatory frameworks.
The rise of large language models (LLMs) presents promising solutions, albeit with accompanying risks necessitating thorough validation and seamless integration.
Tackling these blind spots demands a holistic approach, embracing adaptive learning and a steadfast commitment to self-improvement. By nurturing curiosity, refining regulatory terminology, and judiciously harnessing new technologies, the pharmaceutical sector can progress towards better public health service delivery and ensure the safety, efficacy, and real-world impact of drug products.
The Constitution, Government and Law making bodies .saanidhyapatel09
Ìý
This PowerPoint presentation provides an insightful overview of the Constitution, covering its key principles, features, and significance. It explains the fundamental rights, duties, structure of government, and the importance of constitutional law in governance. Ideal for students, educators, and anyone interested in understanding the foundation of a nation’s legal framework.
Mate, a short story by Kate Grenvile.pptxLiny Jenifer
Ìý
A powerpoint presentation on the short story Mate by Kate Greenville. This presentation provides information on Kate Greenville, a character list, plot summary and critical analysis of the short story.
Prelims of Kaun TALHA : a Travel, Architecture, Lifestyle, Heritage and Activism quiz, organized by Conquiztadors, the Quiz society of Sri Venkateswara College under their annual quizzing fest El Dorado 2025.
2. • Introduction to Python and installation:
• Python is a widely used general-purpose, high level
programming language. It was initially designed by
Guido van Rossum in 1991 and developed by Python
Software Foundation. It was mainly developed for
emphasis on code readability, and its syntax allows
programmers to express concepts in fewer lines of
code. Python is a programming language that lets
you work quickly and integrate systems more
efficiently. There are two major Python versions-
Python 2 and Python 3.
• • On 16 October 2000, Python 2.0 was released with
many new features.
• • On 3rd December 2008, Python 3.0 was released
with more testing and includes new features.
3. • Beginning with Python programming:
• 1) Finding an Interpreter:
• Before we start Python programming, we need to
have an interpreter to interpret and run our
programs. There are certain online interpreters like
https://ide.geeksforgeeks.org/,
http://ideone.com/ or http://codepad.org/ that
can be used to start Python without installing an
interpreter.
• Windows: There are many interpreters available
freely to run Python scripts like IDLE (Integrated
Development Environment) which is installed
when you install the python software from
http://python.org/downloads/
5. • Why to use Python:
• The following are the primary factors to
use python in day-to-day life:
• 1. Python is object-oriented
• Structure supports such concepts as
polymorphism, operation overloading and
multiple inheritance.
• 2. Indentation
• Indentation is one of the greatest feature
in python
6. • 3. It’s free (open source)
• Downloading python and installing python is free and
easy
• 4. It’s Powerful
• Dynamic typing
• Built-in types and tools
• Library utilities
• Third party utilities (e.g. Numeric, NumPy, sciPy)
• Automatic memory management
• 5. It’s Portable
• Python runs virtually every major platform used today
• As long as you have a compatable python interpreter
installed, python programs will run in exactly the same
manner, irrespective of platform.
7. • 6. It’s easy to use and learn
• No intermediate compile
• Python Programs are compiled automatically to an intermediate form
called byte code, which the interpreter then reads.
• This gives python the development speed of an interpreter without
the performance loss inherent in purely interpreted languages.
• Structure and syntax are pretty intuitive and easy to grasp.
• 7. Interpreted Language
• Python is processed at runtime by python Interpreter
• 8. Interactive Programming Language
• Users can interact with the python interpreter directly for writing the
programs
• 9. Straight forward syntax
• The formation of python syntax is simple and straight forward which
also makes it popular.
8. • Installation:
• There are many interpreters available freely to
run Python scripts like IDLE (Integrated
Development Environment) which is installed
when you install the python software from
http://python.org/downloads/
• Steps to be followed and remembered:
• Step 1: Select Version of Python to Install. Step 2:
Download Python Executable Installer. Step 3:
Run Executable Installer.
• Step 4: Verify Python Was Installed On Windows.
9. • Step 5: Verify Pip Was Installed. Step 6:
Add Python Path to Environment Variables
(Optional)
10. • Working with Python Python Code Execution:
• Python’s traditional runtime execution
model:Source code you type is translated to byte
code, which is then run by the Python Virtual
Machine (PVM). Your code is automatically
compiled, but then it is interpreted.
11. • There are two modes for using the Python
interpreter:
• • Interactive Mode
• • Script Mode
12. • Running Python in interactive mode: Without passing
python script file to the interpreter, directly execute
code to Python prompt.
• Once you‟re inside the python interpreter, then you
can start.
• >>> print("hello world")
• hello world
• #Relevant output is displayed on subsequent lines
without the >>> symbol
• >>> x=[0,1,2]
• #Quantities stored in memory are not displayed by
default.
• >>> x
• #If a quantity is stored in memory, typing its name will
display it. [0, 1, 2]
• >>> 2+3 5
13. The chevron at the beginning of the 1st line, i.e., the symbol >>> is a prompt the
python interpreter uses to indicate that it is ready. If the programmer types 2+6,
the interpreter replies 8.
14. • Running Python in script mode:
• Alternatively, programmers can store Python script
source code in a file with the .py extension, and use the
interpreter to execute the contents of the file. To
execute the script by the interpreter, you have to tell
the interpreter the name of the file. For example, if you
have a script name MyFile.py and you're working on
Unix, to run the script you have to type:
• python MyFile.py
• Working with the interactive mode is better when
Python programmers deal with small pieces of code as
you can type and execute them immediately, but when
the code is more than 2-4 lines, using the script for
coding can help to modify and use the code in future.
• Example:
16. • Numeric Data types:
• The data stored in memory can be of many types.
For example, a student roll number is stored as a
numeric value and his or her address is stored as
alphanumeric characters. Python has various
standard data types that are used to define the
operations possible on them and the storage
method for each of them.
• Int:
• Int, or integer, is a whole number, positive or
negative, without decimals, of unlimited length.
• >>> print(24656354687654+2)
• 24656354687656
• >>> print(20)
• 20
17. • # To verify the type of any object in
Python, use the type() function:
• >>> type(10)
• <class 'int'>
• >>> a=11
• >>> print(type(a))
• <class 'int'>
18. • Float:
• Float, or "floating point number" is a number,
positive or negative, containing one or more
decimals.
• Float can also be scientific numbers with an "e" to
indicate the power of 10.
• >>> y=2.8
• >>> y
• 2.8
• >>> y=2.8
• >>> print(type(y))
• <class 'float'>
• >>> type(.4)
• <class 'float'>
20. • Boolean:
• Objects of Boolean type may have one of
two values, True or False:
• >>> type(True)
• <class 'bool'>
• >>> type(False)
• <class 'bool'>
21. • String:
• 1. Strings in Python are identified as a contiguous set
of characters represented in the quotation marks.
Python allows for either pairs of single or double
quotes.
• • 'hello' is the same as "hello".
• • Strings can be output to screen using the print
function.
• For example: print("hello").
• >>> print(“VSR college") VSR college
• >>> type(“VSR college")
• <class 'str'>
• >>> print(‘VSR college')
• VSR college
• >>> " "
• ' '
22. • A string is a group/a sequence of characters. Since
Python has no provision for arrays, we simply use
strings. This is how we declare a string. We can use
a pair of single or double quotes. Every string
object is of the type „str‟.
• >>> type("name")
• <class 'str'>
• fruit = 'banana'
• >>> letter = fruit[1]
• The second statement selects character number 1
from fruit and assigns it to letter. The expression in
brackets is called an index. The index indicates
which character in the sequence we want
23. • String slices:
• A segment of a string is called a slice.
Selecting a slice is similar to selecting a
character: Subsets of strings can be taken
using the slice operator ([ ] and [:]) with
indexes starting at 0 in the beginning of the
string and working their way from -1 at the
end. Slice out substrings, sub lists, sub Tuples
using index. Syntax:[Start: stop: steps]
• Slicing will start from index and will go up to
stop in step of steps.
• Default value of start is 0,
24. • Stop is last index of list
• And for step default is 1
• For example 1−
• str = 'Hello World!'
• print str
• # Prints complete string
• print str[0]
• # Prints first character of the string
• print str[2:5]
• # Prints characters starting from 3rd to 5th
• print str[2:]
• # Prints string starting from 3rd character
• print str * 2
• # Prints string two times
• print str + "TEST"
• # Prints concatenated string
27. • Immutability:
• It is tempting to use the [] operator on the left side of an
assignment, with the intention of changing a character in
a string.
• For example:
• >>> greeting=‘VSR college!'
• >>> greeting[0]='n'
• TypeError: 'str' object does not support item assignment
The reason for the error is that strings are immutable,
which means we can‟t change an existing string.
• The best we can do is creating a new string that is a
variation on the original:
• >>> greeting = 'Hello, world!'
• >>>new_greeting = 'J' + greeting[1:]
• >>>new_greeting
• 'Jello, world!'
• Note: The plus (+) sign is the string concatenation
operator and the asterisk (*) is the repetition operator
30. • Note: All the string methods will be returning
either true or false as the result
• 1. isalnum():
• Isalnum() method returns true if string has at
least 1 character and all characters are
alphanumeric and false otherwise.
• Syntax:
• String.isalnum()
• Example:
• >>> string="123alpha"
• >>>string.isalnum()
• True
31. • 2. isalpha():
• isalpha() method returns true if string has
at least 1 character and all characters are
alphabetic and false otherwise.
• Syntax:
• String.isalpha()
• Example:
• >>> string="nikhil"
• >>>string.isalpha()
• True
32. • 3. isdigit():
• isdigit() returns true if string contains only
digits and false otherwise.
• Syntax:
• String.isdigit()
• Example:
• >>> string="123456789"
• >>>string.isdigit()
• True
33. • 3. isdigit():
• isdigit() returns true if string contains only
digits and false otherwise.
• Syntax:
• String.isdigit()
• Example:
• >>> string="123456789"
• >>>string.isdigit()
• True