SlideShare a Scribd company logo
Unit-1
Variables,Expression, and Statements
Python variable
• Python Variable is containers which store values.
• We do not need to declare variables before using them or
declare their type.
• A variable is created the moment we first assign a value
to it.
• A Python variable is a name given to a memory location. It
is the basic unit of storage in a program.
Variable Example
var="first variable"
print(var)
• Here var is the variable that stores the string “first
variable”.
• The value stored in a variable can be changed during
program execution.
• A Python Variables is only a name given to a memory
Rules for creating variables
• A variable name must start with a letter or the underscore
character.
• A variable name cannot start with a number.
• A variable name can only contain alpha-numeric
characters and underscores (A-z, 0-9, and _ ).
• Variable names are case-sensitive (name, Name and
NAME are three different variables).
• The reserved words(keywords) cannot be used naming
the variable.
Multiple assignment
• Python allows you to assign a single value to several
variables simultaneously. For example −
• For example:
a = b = c = 1
• Here, an integer object is created with the value 1, and all
three variables are assigned to the same memory
location.
• Variable – Container to store a value
• Keywords – Reserved words in Python
• Identifiers – class/function/variable name
Values and types
• A value is one of the basic things a program works with,
like a letter or a number.
• You can print values in Python. See what happens when
you run the following code.
print(17)
print('Hello World!')
• These values belong to different types: 17 is an integer,
and “Hello World!” is a string, so called because it
contains a “string” of letters. You can identify strings
Data Types
Primarily there are the following data types in Python:
• Integers
• Floating point numbers
• Strings
• Booleans
• None
NOTE: None indicates nothing.
type() function and Typecasting
• type function is used to find the data type of a given
variable in Python.
• For example:
a = 31
type(a) #class<int>
b = “31”
type(b) #class<str>
Example Program
Typecasting
• A number can be converted into a string and vice versa (if possible)
• There are many functions to convert one data type into another.
• Str(31) # ”31” Integer to string conversion
• int(“32”) # 32 String to int conversion
• float(32) #32.0 Integer to float conversion
… and so on
• Here “31” is a string literal, and 31 is a numeric literal.
Input() function
• This function allows the user to take input from the
keyboard as a string.
Syntax:
a = input(“Enter name”)
#if a is “student”, the user entered
• Note: The output of the input function is always a string
even if the number is entered by the user.
• Suppose if a user enters 34, then this 34 will automatically
convert to “34” string literal.
Instructions
• An Instruction is an order/command given to a computer
processor by a computer program to perform some
mathematical or logical manipulations (calculations).
• Each and every line or a sentence in any programming
language is called an instruction.
Statement in python
• Any Instruction that a python interpreter can execute is
called a Statement.
• The execution of a statement changes state
• Execution of a statement may or may not produces or
displays a result value, it only does whatever the
statement says.
• For Example:
a=5;
Keywords in Python
• Keywords in Python are
reserved words that can
not be used as a variable
name, function name, or
any other identifier.
• Code to check keywords
list in python:
Operators in Python
The following are some common operators in Python:
1. Arithmetic Operators (+, -, *, /, etc.)
2. Assignment Operators (=, +=, -=, etc.)
3. Comparison Operators (==, >=, <=, >, <, !=, etc.)
4. Logical Operators (and, or, not)
5. Identity Operators
6. Membership Operators
7. Bitwise Operators
1. Arithmetic Operators
Practice Question
• Write a program that performs all the arithmatic operation
on two numbers.
2. Assignment Operators
3. Comparision Operator (Relational
Operator)
4. Logical Operators
Example ( logical or )
Example (logical and)
Example ( logical not )
5. Identity Operators
Example ( is )
Example ( is not )
6. Membership Operators
Example ( in )
Example ( not in )
7. Bitwise Operators
• In Python, bitwise operators are used to performing
bitwise calculations on integers. The integers are first
converted into binary and then operations are performed
on bit by bit, hence the name bitwise operators. Then the
result is returned in decimal format.
• Note: Python bitwise operators work only on integers.
Bitwise AND operator
• Returns 1 if both the bits are 1 else 0.
• Example:
a = 10 = 1010 (Binary)
b = 4 = 0100 (Binary)
a & b = 1010
&
0100
= 0000
= 0 (Decimal)
Bitwise or operator
• Returns 1 if either of the bit is 1 else 0
• Example:
a = 10 = 1010 (Binary)
b = 4 = 0100 (Binary)
a | b = 1010
|
0100
= 1110
= 14 (Decimal)
• Most of the bitwise operators are binary, which means
that they expect two operands to work with, typically
referred to as the left operand and the right operand.
Bitwise NOT (~) is the only unary bitwise operator since it
expects just one operand.
Bitwise not operator
• Returns one’s complement of the number.
• Example:
a = 10 = 1010 (Binary)
~a = ~1010
= -(1010 + 1)
= -(1011)
= -11 (Decimal)
Bitwise xor operator
• Returns 1 if one of the bits is 1 and the other is 0 else
returns false.
• Example:
a = 10 = 1010 (Binary)
b = 4 = 0100 (Binary)
a ^ b = 1010
^
0100
= 1110
= 14 (Decimal)
Bitwise right shift
• Shifts the bits of the number to the right and fills 0 on
voids left( fills 1 in the case of a negative number) as a
result.
• Gets similar results as of dividing the number with some
power of two.
• Example 1:
a = 10 = 0000 1010 (Binary)
a >> 1 = 0000 0101 = 5
• Example 2:
a = -10 = 1111 0110 (Binary)
a >> 1 = 1111 1011 = -5
Bitwise left shift
• Shifts the bits of the number to the left and fills 0 on voids
right as a result.
• Gets similar results as of multiplying the number with
some power of two.
• Example 1:
a = 5 = 0000 0101 (Binary)
a << 1 = 0000 1010 = 10
a << 2 = 0001 0100 = 20
• Example 2:
b = -10 = 1111 0110 (Binary)
b << 1 = 1110 1100 = -20
b << 2 = 1101 1000 = -40
Precedence of Python Operators
• Expressions:
The combination of values, variables, operators, and function calls is
termed as an expression. The Python interpreter can evaluate a valid
expression.
For Example:
5+7
here 5+7 is an expression.
NOTE: There can be multiple operators in one expression as well.
• To evaluate these types of expressions there is a rule of
precedence in Python. It guides the order in which these
operations are carried out.
• For example, multiplication has higher precedence than
subtraction.
>>> 10 - 4 * 2
2 (result)
• But we can change this order using parentheses () as it
has higher precedence than multiplication.
• For Example:
Parentheses () has higher precedence
>>> (10 - 4) * 2
12 (Result)
• The operator precedence in Python is listed in the
following table. It is in descending order (upper group has
higher precedence than the lower ones).
unit1 python.pptx
unit1 python.pptx
Associativity of Python Operators
• We can see in the above table that more than one
operator exists in the same group. These operators have
the same precedence.
• When two operators have the same precedence,
associativity helps to determine the order of operations.
• Associativity is the order in which an expression is
evaluated that has multiple operators of the same
precedence. Almost all the operators have left-to-right
associativity.
• For example, multiplication and floor division have the
same precedence. Hence, if both of them are present in
an expression, the left one is evaluated first.
Example
• Left-right associativity
print(5 * 2 // 3)
# Output: 3
• Shows left-right associativity
print(5 * (2 // 3))
# Output: 0
Statement vs Expressions
Statement
• A statement executes something
• Execution of a statement may or
may not produces or displays a
result value, it only does whatever
the statement says.
• Every statement can be an
expression.
• Example: >>> x = 3
>>> print(x)
Output: 3
Expressions
• An expression evaluates to a
value.
• Evaluation of an expression
always Produces or returns a
result value.
• Every expression can’t be a
statement
• Example: >>> a + 16
>>> 20
Commments
• Lines in the code that are ignored by the python
interpreter during the execution of the program.
• Comments enhance the readability of the code and help
the programmers to understand the code very carefully.
Types of comments
• There are three types of comments in Python –
1. Single line Comments
2. Multiline Comments
3. Docstring Comments
1. Single line Comment
• A single-line comment
begins with a hash (#)
symbol and is useful in
mentioning that the whole
line should be considered
as a comment until the
end of the line.
• Example:
Multi-Line Comments
• Python does not provide the option for multiline
comments. However, there are different ways through
which we can write multiline comments.
1. Using Multiple Hashtags (#)
2. Using String Literals
Using Multiple Hastags
Using String Literals
• Python ignores the string
literals that are not
assigned to a variable so
we can use these string
literals as a comment.
Docstring
• Python docstring is the string literals with triple quotes that
are appeared right after the function. It is used to
associate documentation that has been written with
Python modules, functions, classes, and methods. It is
added right below the functions, modules, or classes to
describe what they do. In Python, the docstring is then
made available via the __doc__ attribute.
Example
• def multiply(a, b):
• """Multiplies the value of a and b"""
• return a*b
• # Print the docstring of multiply function
• print(multiply.__doc__)
Operations on string
• Python string is a sequence of Unicode characters that is
enclosed in the quotations marks.
• we will discuss the in-built function i.e. the functions
provided by the Python to operate on strings.
• Strings can be created by enclosing characters inside a
single quote or double-quotes. Even triple quotes can be
used in Python but generally used to represent multiline
strings and docstrings.
• Some of the important functions of strings will be
discussed in further slides.
• lower(): Converts all uppercase characters in a string into
lowercase
• upper(): Converts all lowercase characters in a string into
uppercase
• title(): Convert string to title case
• capitalize(): Converts the first character of the string to a
capital (uppercase) letter
• startswith(): Returns true if the string starts with the
specified value
• count(): Returns the number of occurrences of a substring
in the string.
• endswith(): Returns true if the string ends with the
specified value
• find(): Searches the string for a specified value and
returns the position of where it was found
• index(): Searches the string for a specified value and
returns the position of where it was found
• isalnum(): Returns True if all characters in the string
are alphanumeric
• isalpha(): Returns True if all characters in the string
are in the alphabet
• islower(): Returns True if all characters in the string
are lower case
• isupper(): Returns True if all characters in the string
are upper case
Example
text = 'this is pYthon ClAss'
print("nUpdated String after uppercase:")
print(text.upper())
print("nUpdated String after lowercase:")
print(text.lower())
print("nUpdated String afer titlecase:")
print(text.title())
# original string never changes
print("nOriginal String")
print(text)
OUTPUT SCREEN-->

More Related Content

PPTX
modul-python-all.pptx
PPTX
python_computer engineering_semester_computer_language.pptx
PPTX
Basic concept of Python.pptx includes design tool, identifier, variables.
PPTX
MODULE hdsfsf gefegsfs wfefwfwfg etegeg.pptx
PPTX
Unit - 2 CAP.pptx
PPTX
Introduction to python
PPTX
Programming Basics.pptx
PPTX
1.4 Work with data types and variables, numeric data, string data.pptx
modul-python-all.pptx
python_computer engineering_semester_computer_language.pptx
Basic concept of Python.pptx includes design tool, identifier, variables.
MODULE hdsfsf gefegsfs wfefwfwfg etegeg.pptx
Unit - 2 CAP.pptx
Introduction to python
Programming Basics.pptx
1.4 Work with data types and variables, numeric data, string data.pptx

Similar to unit1 python.pptx (20)

PPTX
python presentation.pptx
PPTX
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
PPTX
Python Basics by Akanksha Bali
PPTX
parts_of_python_programming_language.pptx
PPT
Unit-I-PPT-1.ppt
PPTX
Python unit 2 is added. Has python related programming content
PPTX
1. PGA2.0-Python Programming-Intro to Python.pptx
PPTX
Introduction to Python for Data Science and Machine Learning
PPTX
Review Python
PPTX
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
PPTX
Grade XI - Computer science Data Handling in Python
PPTX
Review old Pygame made using python programming.pptx
PDF
An overview on python commands for solving the problems
PPTX
Topic 2 - Python, Syntax, Variables.pptx
PPTX
Operators in Python Arithmetic Operators
PDF
Chapter 01 Introduction to Java by Tushar B Kute
PPTX
Python Revision Tour.pptx class 12 python notes
PPTX
Python basics
PPTX
Python Basics.pptx
PPTX
Python-Certification-Training-Day-1-2.pptx
python presentation.pptx
python notes for MASTER OF COMPUTER APPLIICATION_ppt.pptx
Python Basics by Akanksha Bali
parts_of_python_programming_language.pptx
Unit-I-PPT-1.ppt
Python unit 2 is added. Has python related programming content
1. PGA2.0-Python Programming-Intro to Python.pptx
Introduction to Python for Data Science and Machine Learning
Review Python
chapter-3-engdata-handling1_1585929972520 by EasePDF.pptx
Grade XI - Computer science Data Handling in Python
Review old Pygame made using python programming.pptx
An overview on python commands for solving the problems
Topic 2 - Python, Syntax, Variables.pptx
Operators in Python Arithmetic Operators
Chapter 01 Introduction to Java by Tushar B Kute
Python Revision Tour.pptx class 12 python notes
Python basics
Python Basics.pptx
Python-Certification-Training-Day-1-2.pptx

Recently uploaded (20)

PDF
737-MAX_SRG.pdf student reference guides
PDF
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
PPTX
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
Current and future trends in Computer Vision.pptx
PDF
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
PDF
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PPTX
CYBER-CRIMES AND SECURITY A guide to understanding
PDF
Embodied AI: Ushering in the Next Era of Intelligent Systems
PPTX
web development for engineering and engineering
PPTX
CH1 Production IntroductoryConcepts.pptx
PPTX
Foundation to blockchain - A guide to Blockchain Tech
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PDF
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
PPTX
UNIT 4 Total Quality Management .pptx
PPT
Project quality management in manufacturing
PDF
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
PPTX
Artificial Intelligence
PPTX
OOP with Java - Java Introduction (Basics)
737-MAX_SRG.pdf student reference guides
Evaluating the Democratization of the Turkish Armed Forces from a Normative P...
FINAL REVIEW FOR COPD DIANOSIS FOR PULMONARY DISEASE.pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
Current and future trends in Computer Vision.pptx
The CXO Playbook 2025 – Future-Ready Strategies for C-Suite Leaders Cerebrai...
TFEC-4-2020-Design-Guide-for-Timber-Roof-Trusses.pdf
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
CYBER-CRIMES AND SECURITY A guide to understanding
Embodied AI: Ushering in the Next Era of Intelligent Systems
web development for engineering and engineering
CH1 Production IntroductoryConcepts.pptx
Foundation to blockchain - A guide to Blockchain Tech
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
BIO-INSPIRED HORMONAL MODULATION AND ADAPTIVE ORCHESTRATION IN S-AI-GPT
UNIT 4 Total Quality Management .pptx
Project quality management in manufacturing
keyrequirementskkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkkk
Artificial Intelligence
OOP with Java - Java Introduction (Basics)

unit1 python.pptx

  • 2. Python variable • Python Variable is containers which store values. • We do not need to declare variables before using them or declare their type. • A variable is created the moment we first assign a value to it. • A Python variable is a name given to a memory location. It is the basic unit of storage in a program.
  • 3. Variable Example var="first variable" print(var) • Here var is the variable that stores the string “first variable”. • The value stored in a variable can be changed during program execution. • A Python Variables is only a name given to a memory
  • 4. Rules for creating variables • A variable name must start with a letter or the underscore character. • A variable name cannot start with a number. • A variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ ). • Variable names are case-sensitive (name, Name and NAME are three different variables). • The reserved words(keywords) cannot be used naming the variable.
  • 5. Multiple assignment • Python allows you to assign a single value to several variables simultaneously. For example − • For example: a = b = c = 1 • Here, an integer object is created with the value 1, and all three variables are assigned to the same memory location.
  • 6. • Variable – Container to store a value • Keywords – Reserved words in Python • Identifiers – class/function/variable name
  • 7. Values and types • A value is one of the basic things a program works with, like a letter or a number. • You can print values in Python. See what happens when you run the following code. print(17) print('Hello World!') • These values belong to different types: 17 is an integer, and “Hello World!” is a string, so called because it contains a “string” of letters. You can identify strings
  • 8. Data Types Primarily there are the following data types in Python: • Integers • Floating point numbers • Strings • Booleans • None NOTE: None indicates nothing.
  • 9. type() function and Typecasting • type function is used to find the data type of a given variable in Python. • For example: a = 31 type(a) #class<int> b = “31” type(b) #class<str>
  • 11. Typecasting • A number can be converted into a string and vice versa (if possible) • There are many functions to convert one data type into another. • Str(31) # ”31” Integer to string conversion • int(“32”) # 32 String to int conversion
  • 12. • float(32) #32.0 Integer to float conversion … and so on • Here “31” is a string literal, and 31 is a numeric literal.
  • 13. Input() function • This function allows the user to take input from the keyboard as a string. Syntax: a = input(“Enter name”) #if a is “student”, the user entered • Note: The output of the input function is always a string even if the number is entered by the user. • Suppose if a user enters 34, then this 34 will automatically convert to “34” string literal.
  • 14. Instructions • An Instruction is an order/command given to a computer processor by a computer program to perform some mathematical or logical manipulations (calculations). • Each and every line or a sentence in any programming language is called an instruction.
  • 15. Statement in python • Any Instruction that a python interpreter can execute is called a Statement. • The execution of a statement changes state • Execution of a statement may or may not produces or displays a result value, it only does whatever the statement says. • For Example: a=5;
  • 16. Keywords in Python • Keywords in Python are reserved words that can not be used as a variable name, function name, or any other identifier. • Code to check keywords list in python:
  • 17. Operators in Python The following are some common operators in Python: 1. Arithmetic Operators (+, -, *, /, etc.) 2. Assignment Operators (=, +=, -=, etc.) 3. Comparison Operators (==, >=, <=, >, <, !=, etc.) 4. Logical Operators (and, or, not) 5. Identity Operators 6. Membership Operators 7. Bitwise Operators
  • 19. Practice Question • Write a program that performs all the arithmatic operation on two numbers.
  • 21. 3. Comparision Operator (Relational Operator)
  • 28. Example ( is not )
  • 33. • In Python, bitwise operators are used to performing bitwise calculations on integers. The integers are first converted into binary and then operations are performed on bit by bit, hence the name bitwise operators. Then the result is returned in decimal format. • Note: Python bitwise operators work only on integers.
  • 34. Bitwise AND operator • Returns 1 if both the bits are 1 else 0. • Example: a = 10 = 1010 (Binary) b = 4 = 0100 (Binary) a & b = 1010 & 0100 = 0000 = 0 (Decimal)
  • 35. Bitwise or operator • Returns 1 if either of the bit is 1 else 0 • Example: a = 10 = 1010 (Binary) b = 4 = 0100 (Binary) a | b = 1010 | 0100 = 1110 = 14 (Decimal)
  • 36. • Most of the bitwise operators are binary, which means that they expect two operands to work with, typically referred to as the left operand and the right operand. Bitwise NOT (~) is the only unary bitwise operator since it expects just one operand.
  • 37. Bitwise not operator • Returns one’s complement of the number. • Example: a = 10 = 1010 (Binary) ~a = ~1010 = -(1010 + 1) = -(1011) = -11 (Decimal)
  • 38. Bitwise xor operator • Returns 1 if one of the bits is 1 and the other is 0 else returns false. • Example: a = 10 = 1010 (Binary) b = 4 = 0100 (Binary) a ^ b = 1010 ^ 0100 = 1110 = 14 (Decimal)
  • 39. Bitwise right shift • Shifts the bits of the number to the right and fills 0 on voids left( fills 1 in the case of a negative number) as a result. • Gets similar results as of dividing the number with some power of two.
  • 40. • Example 1: a = 10 = 0000 1010 (Binary) a >> 1 = 0000 0101 = 5 • Example 2: a = -10 = 1111 0110 (Binary) a >> 1 = 1111 1011 = -5
  • 41. Bitwise left shift • Shifts the bits of the number to the left and fills 0 on voids right as a result. • Gets similar results as of multiplying the number with some power of two.
  • 42. • Example 1: a = 5 = 0000 0101 (Binary) a << 1 = 0000 1010 = 10 a << 2 = 0001 0100 = 20 • Example 2: b = -10 = 1111 0110 (Binary) b << 1 = 1110 1100 = -20 b << 2 = 1101 1000 = -40
  • 43. Precedence of Python Operators • Expressions: The combination of values, variables, operators, and function calls is termed as an expression. The Python interpreter can evaluate a valid expression. For Example: 5+7 here 5+7 is an expression. NOTE: There can be multiple operators in one expression as well.
  • 44. • To evaluate these types of expressions there is a rule of precedence in Python. It guides the order in which these operations are carried out. • For example, multiplication has higher precedence than subtraction. >>> 10 - 4 * 2 2 (result)
  • 45. • But we can change this order using parentheses () as it has higher precedence than multiplication. • For Example: Parentheses () has higher precedence >>> (10 - 4) * 2 12 (Result) • The operator precedence in Python is listed in the following table. It is in descending order (upper group has higher precedence than the lower ones).
  • 48. Associativity of Python Operators • We can see in the above table that more than one operator exists in the same group. These operators have the same precedence. • When two operators have the same precedence, associativity helps to determine the order of operations.
  • 49. • Associativity is the order in which an expression is evaluated that has multiple operators of the same precedence. Almost all the operators have left-to-right associativity. • For example, multiplication and floor division have the same precedence. Hence, if both of them are present in an expression, the left one is evaluated first.
  • 50. Example • Left-right associativity print(5 * 2 // 3) # Output: 3 • Shows left-right associativity print(5 * (2 // 3)) # Output: 0
  • 51. Statement vs Expressions Statement • A statement executes something • Execution of a statement may or may not produces or displays a result value, it only does whatever the statement says. • Every statement can be an expression. • Example: >>> x = 3 >>> print(x) Output: 3 Expressions • An expression evaluates to a value. • Evaluation of an expression always Produces or returns a result value. • Every expression can’t be a statement • Example: >>> a + 16 >>> 20
  • 52. Commments • Lines in the code that are ignored by the python interpreter during the execution of the program. • Comments enhance the readability of the code and help the programmers to understand the code very carefully.
  • 53. Types of comments • There are three types of comments in Python – 1. Single line Comments 2. Multiline Comments 3. Docstring Comments
  • 54. 1. Single line Comment • A single-line comment begins with a hash (#) symbol and is useful in mentioning that the whole line should be considered as a comment until the end of the line. • Example:
  • 55. Multi-Line Comments • Python does not provide the option for multiline comments. However, there are different ways through which we can write multiline comments. 1. Using Multiple Hashtags (#) 2. Using String Literals
  • 57. Using String Literals • Python ignores the string literals that are not assigned to a variable so we can use these string literals as a comment.
  • 58. Docstring • Python docstring is the string literals with triple quotes that are appeared right after the function. It is used to associate documentation that has been written with Python modules, functions, classes, and methods. It is added right below the functions, modules, or classes to describe what they do. In Python, the docstring is then made available via the __doc__ attribute.
  • 59. Example • def multiply(a, b): • """Multiplies the value of a and b""" • return a*b • # Print the docstring of multiply function • print(multiply.__doc__)
  • 60. Operations on string • Python string is a sequence of Unicode characters that is enclosed in the quotations marks. • we will discuss the in-built function i.e. the functions provided by the Python to operate on strings.
  • 61. • Strings can be created by enclosing characters inside a single quote or double-quotes. Even triple quotes can be used in Python but generally used to represent multiline strings and docstrings. • Some of the important functions of strings will be discussed in further slides.
  • 62. • lower(): Converts all uppercase characters in a string into lowercase • upper(): Converts all lowercase characters in a string into uppercase • title(): Convert string to title case • capitalize(): Converts the first character of the string to a capital (uppercase) letter • startswith(): Returns true if the string starts with the specified value
  • 63. • count(): Returns the number of occurrences of a substring in the string. • endswith(): Returns true if the string ends with the specified value • find(): Searches the string for a specified value and returns the position of where it was found • index(): Searches the string for a specified value and returns the position of where it was found
  • 64. • isalnum(): Returns True if all characters in the string are alphanumeric • isalpha(): Returns True if all characters in the string are in the alphabet • islower(): Returns True if all characters in the string are lower case • isupper(): Returns True if all characters in the string are upper case
  • 65. Example text = 'this is pYthon ClAss' print("nUpdated String after uppercase:") print(text.upper()) print("nUpdated String after lowercase:") print(text.lower()) print("nUpdated String afer titlecase:") print(text.title()) # original string never changes print("nOriginal String") print(text) OUTPUT SCREEN-->