0% found this document useful (0 votes)
29 views20 pages

Introduction to Python Programming Basics

The document provides an introduction to Python, detailing its history, features, advantages, and installation process. It covers Python's syntax, variable creation, data types, and operators, emphasizing its ease of use, readability, and versatility for various programming tasks. Additionally, it explains the types of comments in Python and the concept of operator precedence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
29 views20 pages

Introduction to Python Programming Basics

The document provides an introduction to Python, detailing its history, features, advantages, and installation process. It covers Python's syntax, variable creation, data types, and operators, emphasizing its ease of use, readability, and versatility for various programming tasks. Additionally, it explains the types of comments in Python and the concept of operator precedence.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Unit 1

Introduction to Python

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.
o In 1994, Python 1.0 was released with new features like lambda, map, filter, and reduce.
o Python 2.0 added new features such as list comprehensions, garbage collection systems.
o On December 3, 2008, Python 3.0 (also called "Py3K") was released. It was designed to rectify
the fundamental flaw of the language.
o ABC programming language is said to be the predecessor of Python language, which was
capable of Exception Handling and interfacing with the Amoeba Operating System.
The following programming languages influence Python:
o ABC language.
o Modula-3

Python features and Advantages

1. Easy to Code
Python is a very high-level programming language, yet it is effortless to learn. Anyone can learn
to code in Python in just a few hours or a few days. Mastering Python and all its advanced
concepts, packages and modules might take some more time. However, learning the basic Python
syntax is very easy, as compared to other popular languages like C, C++, and Java.
2. Easy to Read
Python code looks like simple English words. There is no use of semicolons or brackets, and
the indentations define the code block. You can tell what the code is supposed to do simply by
looking at it.
3. Free and Open-Source
Python is developed under an OSI-approved open source license. Hence, it is completely free
to use, even for commercial purposes. It doesn't cost anything to download Python or to
include it in your application. It can also be freely modified and re-distributed. Python can be
downloaded from the official Python website.
4. Robust Standard Library
Python has an extensive standard library available for anyone to use. This means that
programmers don’t have to write their code for every single thing unlike other programming
languages. There are libraries for image manipulation, databases, unit-testing, expressions
and a lot of other functionalities. In addition to the standard library, there is also a growing
collection of thousands of components, which are all available in the Python Package Index.
5. Interpreted
When a programming language is interpreted, it means that the source code is executed line by
line, and not all at once. Programming languages such as C++ or Java are not interpreted, and
hence need to be compiled first to run them. There is no need to compile Python because it is
processed at runtime by the interpreter.
6. Portable
Python is portable in the sense that the same code can be used on different machines. Suppose
you write a Python code on a Mac. If you want to run it on Windows or Linux later, you don’t
have to make any changes to it. As such, there is no need to write a program multiple times
for several platforms.
7. Object-Oriented and Procedure-Oriented
A programming language is object-oriented if it focuses design around data and objects,
rather than functions and logic. On the contrary, a programming language is procedure-
oriented if it focuses more on functions (code that can be reused). One of the critical
Python features is that it supports both object-oriented and procedure-oriented
programming.
8. Extensible
A programming language is said to be extensible if it can be extended to other
languages. Python code can also be written in other languages like C++, making it a
highly extensible language.
9. Expressive
Python needs to use only a few lines of code to perform complex tasks. For example, to
display Hello World, you simply need to type one line - print(“Hello World”). Other
languages like Java or C would take up multiple lines to execute this.
10. Support for GUI
One of the key aspects of any programming language is support for GUI or Graphical
User Interface. A user can easily interact with the software using a GUI. Python offers
various toolkits, such as Tkinter, wxPython and JPython, which allows for GUI's easy
and fast development.
11. Dynamically Typed
Many programming languages need to declare the type of the variable before runtime.
With Python, the type of the variable can be decided during runtime. ľhis makes Pythona
dynamically typed language.
For example, if you have to assign an integer value 20 to a variable “x”,
you don’t need towrite int x =20, You just have to write x = 20.
12. High-level Language
Python is a high-level programming language because programmers don’t need to
remember the system architecture, nor do they have to manage the memory. This
makes it super programmer- friendly and is one of the key features of Python.
13. Simplify Complex Software Development
Python can be used to develop both desktop and web apps and complex scientific and
numerical applications. Python's data analysis features help you create custom big data
solutions without so much time and effort. You can also use the Python data visualization
libraries and APIs to present data in a more appealing way. Several advanced software
developers use Python to accomplish high- end AI and natural language processing tasks.

Installation of Python IDLE and Environment Setup

1. Download the latest version of Python.


2. Run the installer file and follow the steps to install Python
During the install process, check Add Python to environment variables. This will add Python to
environment variables, and you can run Python from any part of the computer.
1. Run Python in Immediate mode
Once Python is installed, typing python in the command line will invoke the interpreter in
immediate mode
2. Run Python in the Integrated Development Environment (IDE)
We can use any text editing software to write a Python script file.
We just need to save it with the .py extension. But using an IDE can make our life a lot easier.
IDE is a piece of software that provides useful features like code hinting, syntax highlighting and
checking, file explorers, etc. to the programmer for application development.
By the way, when you install Python, an IDE named IDLE is also installed. You can use it to run
Python on your computer.

Python variables and operators

Variables: Variables are containers for storing data values.


Creating Variables: Python has no command for declaring a variable.
A variable is created the moment you first assign a value to it.
Example
x=5
y = "John"
print(x)
print(y)
Output:
5
John

Casting: If you want to specify the data type of a variable, this can be done with casting.

Example
x = str(3) # x will be '3'
y = int(3) # y will be 3
z = float(3) # z will be 3.0

Get the Type: You can get the data type of a variable with the type() function.

Example
x=5
y = "John"
print(type(x))
print(type(y))
Output:
<class 'int'>
<class 'str'>

Single or Double Quotes?

String variables can be declared either by using single or double quotes:


Example
x = "John"
# is the same as
x = 'John'
print(x)
print(x)
Output:
John
John

Case-Sensitive: Variable names are case-sensitive.

Example:
This will create two variables:
a=4
A = "Sally"
#A will not overwrite a
print(a)
print(A)
Output:
4
Sally

Variable Names: A variable can have a short name (like x and y) or a more descriptive name
(age, carname, total_volume). Rules for Python 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 (age, Age and AGE are three different variables)
A variable name cannot be any of the Python keywords.
Example
Legal variable names are:
myvar = "John"
my_var = "John"
_my_var = "John"
myVar = "John"
MYVAR = "John"
myvar2 = "John"
Example
Illegal variable names are:
2myvar = "John"
my-var = "John"
my var = "John"
Multi Words Variable Names
Variable names with more than one word can be difficult to read.
There are several techniques you can use to make them more readable:
Camel Case: Each word, except the first, starts with a capital letter:
myVariableName = "John"
Pascal Case: Each word starts with a capital letter:
MyVariableName = "John"
Snake Case: Each word is separated by an underscore character:
my_variable_name = "John"

Many Values to Multiple Variables


Python allows you to assign values to multiple variables in one line:
Example
x, y, z = "Orange", "Banana", "Cherry"
print(x)
print(y)
print(z)
Output:
Orange
Banana
Cherry

One Value to Multiple Variables


And you can assign the same value to multiple variables in one line:
Example
x = y = z = "Orange"
print(x)
print(y)
print(z)
Output:
Orange
Orange
Orange
Comments in Python
Comments in Python are the lines in the code that are ignored by the interpreter during the
execution of the program.
Comments enhance the readability of the code and help the programmers to understand the code
very carefully. It also helps in collaborating with other developers as adding comments makes it
easier to explain the code.

Types of Comments in Python


There are two types of comments in Python:
Single line Comments
Multiline Comments

1. Single-Line Comments
Python single-line comment starts with the hashtag symbol (#) with no white spaces and lasts
till the end of the line.
If the comment exceeds one line then put a hashtag on the next line and continue the Python
Comment.
Python’s single-line comments are proved useful for supplying short explanations for variables,
function declarations, and expressions. See the following code snippet demonstrating single line
comment:

# Print “Your Name !” to console


print("Your Name")
Output
Your Name

2. Multi-Line Comments
Python does not provide the option for multiline comments. However, there are different ways
through which we can write multiline comments.
a) Multiline comments using multiple hashtags (#)
We can multiple hashtags (#) to write multiline comments in Python. Each and every line will be
considered as a single-line comment.

# Python program to demonstrate


# comment1
# comment2
print("Multiline comments")
Output
Multiline comments

b) Multiline comments using string literals


Python ignores the string literals that are not assigned to a variable so we can use these string
literals as Python Comments.

‘’’Python program to demonstrate


multiline comments’’’
print("Multiline comments")
Output
Multiline comments

Python Data Types


Variables can hold values, and every value has a data-type.
• Python is a dynamically typed language; hence we do not need to define the type of the variable
while declaring it.
• The interpreter implicitly binds the value with its type. a=5
• The variable ‘a’ holds integer value five and we did not define its type. Python interpreter will
automatically interpret variables ‘a’ as an integer type.
• Python enables us to check the type of the variable used in the program. Python provides us the
type() function, which returns the type of the variable passed.
Ex.
print(type(a))
Output:
<class 'int'>

Standard data types


• Python provides various standard data types that define the storage method on each of them. The
data types defined in Python are given below.
• Numbers
• Sequence Type
• Boolean
• Set
• Dictionary

Numbers
• Python supports three types of numeric data.
• Int - Integer value can be any length such as integers 10, 2 , 29, -20, -150 etc. Python has no
restriction on the length of an integer. Its value belongs to int
• Float - Float is used to store floating-point numbers like 1.9, 9.902, 15.2, etc. It is accurate upto
15 decimal points.
• complex- A complex number contains an ordered pair, i.e., x + iy where x and y denote the real
and imaginary parts, respectively. The complex numbers like 2.14j, 2.0 + 2.3j, etc.

Python Operators

The operator can be defined as a symbol which is responsible for a particular operation between
two operands. Operators are the pillars of a program on which the logic is built in a specific
programming language. Python provides a variety of operators, which are described as follows.

Arithmetic operators Identity operators

Assignment operators Membership operators

Comparison operators Bitwise operators

Logical operators
Arithmetic Operators

Arithmetic operators are used with numeric values to perform common mathematical operations:

Operator Name Example


+ Addition x+y
- Subtraction x–y
* Multiplication x*y
/ Division x/y
% Modulus x%y
** Exponentiation x ** y
// Floor division x // y

Python Assignment Operators

Assignment operators are used to assign values to variables:

Operator Example Same As


= x=5 x=5
+= x += 3 x=x+3
-= x -= 3 x=x–3
*= x *= 3 x=x*3
/= x /= 3 x=x/3
%= x %= 3 x=x%3
//= x //= 3 x = x // 3
**= x **= 3 x = x ** 3
(bitwise and) &= x &= 3 x=x&3
(bitwise OR) |= x |= 3 x=x|3
(bitwise XOR) ^= x ^= 3 x=x^3
(Bitwise Right Shift) x >>= 3 x = x >> 3
>>=
(bitwise left shift) x <<= 3 x = x << 3
<<=
:= print(x := 3) x=3
print(x)

Python Comparison Operators

Comparison operators are used to compare two values:

Operator Name Example


== Equal x == y
!= Not equal x != y
> Greater than x>y
< Less than x<y
>= Greater than or x >= y
equal to
<= Less than or equal x <= y
to
Python Logical Operators

Logical operators are used to combine conditional statements:

Operator Description Example


and Returns True if both statements are true x < 5 and x < 10
or Returns True if one of the x < 5 or x < 4
statements is true
not Reverse the result, returns False if the result is not(x < 5 and x < 10)
true

Python Identity Operators

Identity operators are used to compare the objects, not if they are equal, but if they are actually the
same object, with the same memory location:

Operator Description Example


is Returns True if both variables are the same object x is y
is not Returns True if both variables are not the same object x is not y

Python Membership Operators

Membership operators are used to test if a sequence is presented in an object:

Operator Description Example


in Returns True if a sequence with the specified value is x in y
present in the object
not in Returns True if a sequence with the specified value is x not in y
not present in the object

Python Bitwise Operators

Bitwise operators are used to compare (binary) numbers:

Operator Name Description Example


& AND Sets each bit to 1 if both bits are 1 x&y
| OR Sets each bit to 1 if one of two bits is 1 x|y
^ XOR Sets each bit to 1 if only one of two bits is 1 x^y
~ NOT Inverts all the bits ~x
<< Zero fill Shift left by pushing zeros in from the right and x << 2
left shift let the leftmost bits fall off
>> Signed Shift right by pushing copies of the leftmost bit x >> 2
right shift in from the left, and let the rightmost bits fall
off

Operator Precedence
Operator precedence describes the order in which operations are performed.
Example
Parentheses has the highest precedence, meaning that expressions inside parentheses must be
evaluated first:
print((6 + 3) - (6 + 3))
Example
Multiplication * has higher precedence than addition +, and therefore multiplications are
evaluated before additions:
print(100 + 5 * 3)
The precedence order is described in the table below, starting with the highest precedence at the
top:

() Parentheses
** Exponentiation
+x -x ~x Unary plus, unary minus, and
bitwise NOT
* / // % Multiplication, division, floor
division, and modulus
+- Addition and subtraction
<< >> Bitwise left and right shifts
& Bitwise AND
^ Bitwise XOR
| Bitwise OR
== != > >= < <= is is not in not in Comparisons, identity, and
membership operators
Not Logical NOT
And AND
Or OR

If two operators have the same precedence, the expression is evaluated from left to right.

Python Keywords
• Python Keywords are special reserved words that convey a special meaning to the
compiler/interpreter. Each keyword has a special meaning and a specific operation. These
keywords can't be used as a variable. Following is the List of Python Keywords.
Python Numbers Type Conversion and Mathematics
According to the mathematics we have four types of number systems which are representing the
numbers in computer architecture.
• Binary Number System
• Octal Number System
• Decimal Number System
• Hexadecimal Number System

In Python we can represent these numbers by appropriately placing a prefix before that number.
The following table lists these prefixes.
Number System Prefix
• Binary '0b’ or '0B'
• Octal '0o' or '0O'
• Hexadecimal '0x' or '0X'
Example
• A=4847 # decimal
• B=0bl00l # Binary
• C=0o475 # Octal
• D=0xA03D # Hexadecimal

Conversion:
print(bin(14)) # int to bin
print(int(0B100110)) #bin to int

print(oct(1234)) # int to oct


print(int(0o532)) # oct to int

print(hex(l234)) #int to hex


print(int(0xA32)) #hex to int

Python type Casting


We come across different kinds of arithmetic operations in which multiple data types are
involved and then results are obtained accordingly.
Here we will discuss both,
i. Implicit type conversion
ii. Explicit type conversion

Implicit Type Conversion:


During the implicit type conversion, the user is not supposed to mention any specific data type
during the conversion.
The following program illustrates how it can be done in Python.
Example:
#program to demonstrate implicit type conversion
#initializing the value of a
a = 10
print(a)
print("The type of a is ", type(a))
#initializing the value of b
b = 4.5
print(b)
print("The type of b is ", type(b))
#initializing the value of c
c = 4.0
print(c)
print("The type of c is ", type(c))
#initializing the value of d
d = 5.0
print(d)
print("The type of d is ", type(d))
#performing arithmetic operations
res = a * b
print("The product of a and b is ", res)
add = c + d
print("The addition of c and d is ", add)

Explanation: Let's have a glance at the explanation of this program.


1. To check how the values get converted on performing the operations we have initialized the
values of a,b, c and d.
2. After this, we have checked the data type of each one of them.
3. Finally, we have performed addition on the variables a and b and multiplication on the variables
c and d.
4. On executing the above program, we can observe that in the case of the product the final result
is a float value(a was an integer and b was float).

Explicit type conversion


The int(), float() and str() are mostly used for the explicit type conversion.
Consider the program given below,
#program to demonstrate explicit type conversion
#initializing the value of a
a=10.6
print("The type of 'a' before typecasting is ",type(a))
print(int(a))
print("The type of 'a' after typecasting is",type(a))
#initializing the value of b
b=8.3
print("The type of 'b' before typecasting is ",type(b))
print(int(b))
print("The type of 'b' after typecasting is",type(b))
#initializing the value of c
c=7
print("The type of 'c' before typecasting is ",type(c))
print(float(c))
print("The type of 'c' after typecasting is",type(c))
Output:
The type of 'a' before typecasting is <class 'float'>
10
The type of 'a' after typecasting is <class 'float'>
The type of 'b' before typecasting is <class 'float'>
8
The type of 'b' after typecasting is <class 'float'>
The type of 'c' before typecasting is <class 'int'>
7.0
The type of 'c' after typecasting is <class 'int'>

Conditional statement
Conditional Statements in Python:
Decision-making is as important in any programming language as it is in life. Decision-making in
a programming language is automated using conditional statements, in which Python evaluates the
code to see if it meets the specified conditions.
The conditions are evaluated and processed as true or false. If this is found to be true, the program
is run as needed. If the condition is found to be false, the statement following the If condition is
executed.
Python has six conditional statements that are used in decision-making:-
1. If statement
2. If else statement
3. Nested if statement
4. If…Elif ladder
5. Short Hand if statement
6. Short Hand if-else statement

If Statement:
The If statement is the most fundamental decision-making statement, in which the code is
executed based on whether it meets the specified condition. It has a code body that only executes
if the condition in the if statement is true. The statement can be a single line or a block of code.
The if statement in Python has the subsequent syntax:
if expression
Statement
#If the condition is true, the statement will be executed.
Examples for better understanding:
Example – 1
num = 5
if num > 0:
print(num, "is a positive number.")
print("This statement is true.")
Output:
5 is a positive number.
This statement is true.
Example – 2
a = 25
b = 170
if b > a:
print("b is greater than a")
Output:
b is greater than a

If Else Statement:-
This statement is used when both the true and false parts of a given condition are specified to be
executed. When the condition is true, the statement inside the if block is executed; if the condition
is false, the statement outside the if block is executed.
The if…Else statement in Python has the following syntax:
if condition :
#Will executes this block if the condition is true
else :
#Will executes this block if the condition is false
Example for better understanding:
num = 5
if num >= 0:
print("Positive or Zero")
else:
print("Negative number")
output:
Positive or Zero

if…elif..else Statement
In this case, the If condition is evaluated first. If it is false, the Elif statement will be executed; if it
also comes false, the Else statement will be executed.
The if…elif..else statement in Python has the subsequent
syntax:
if condition :
Body of if
elif condition :
Body of elif
else:
Body of else

Example for better understanding:


We will check if the number is positive, negative, or zero.
num = 7
if num > 0:
print("Positive number")
elif num == 0:
print("Zero")
else:
print("Negative number")
Output:
Positive number

Nested IF Statement:
A Nested IF statement is one in which an If statement is nestled inside another If statement. This is
used when a variable must be processed more than once. If, If-else, and If…elif…else statements
can be used in the program. In Nested If statements, the indentation (whitespace at the beginning)
to determine the scope of each statement should take precedence.
The Nested if statement in Python has the following
syntax:
if (condition1):
#Executes if condition 1 is true
if (condition 2):
#Executes if condition 2 is true
#Condition 2 ends here
#Condition 1 ends here

Example-1
num = 8
if num >= 0:
if num == 0:
print("zero")
else:
print("Positive number")
else:
print("Negative number")
Output:
Positive number

Short Hand if statement:


Short Hand if statement is used when only one statement needs to be executed inside the if block.
This statement can be mentioned in the same line which holds the If statement.
The Short Hand if statement in Python has the following
syntax:
if condition: statement
Example for better understanding:
i=15
# One line if statement
if i>11 : print (“i is greater than 11″)
The output of the program : “i is greater than 11.”
Short Hand if-else statement:
It is used to mention If-else statements in one line in which there is only one statement to execute
in both if and else blocks. In simple words, if you have only one statement to execute, one for if,
and one for else, you can put it all on the same line.
Examples for better understanding:
#single line if-else statement
a=3
b=5
print("A") if a > b else print("B")
output:
B
#single line if-else statement, with 3 conditions
a=3
b=5
print("A is greater") if a > b else print("=") if a == b else print("B is greater")
output:
B is greater

Looping statement: -
Python programming language provides the following types of loops to handle looping
requirements. Python provides three ways for executing the loops. While all the ways provide
similar basic functionality, they differ in their syntax and condition checking time.
While Loop:
In python, while loop is used to execute a block of statements repeatedly until a given condition is
satisfied. And when the condition becomes false, the line immediately after the loop in the
program is executed.

Syntax :
while expression:
statement(s)
All the statements indented by the same number of character spaces after a programming construct
are considered to be part of a single block of code. Python uses indentation as its method of
grouping statements.

Example:
# Python program to illustrate
# while loop
count = 0
while (count < 3):
count = count + 1
print("Psitche")
Output:
Psitche
Psitche
Psitche

for in Loop:
For loops are used for sequential traversal. For example: traversing a list or
string or array etc. In Python, there is no C style for loop, i.e., for (i=0; i<n; i++). There is “for in”
loop which is similar to for each loop in other languages. Let us learn how to use for in loop for
sequential traversals.
Syntax:
for iterator_var in sequence:
statements(s)
It can be used to iterate over a range and iterators.
# Python program to illustrate
# Iterating over range 0 to n-1
n=4
for i in range(0, n):
print(i)
Output:
0
1
2
3

Nested Loops:-
Python programming language allows to use one loop inside another loop. Following section
shows few examples to illustrate the concept.
Syntax:
for iterator_var in sequence:
for iterator_var in sequence:
statements(s)
statements(s)
The syntax for a nested while loop statement in the Python programming language is as follows:
while expression:
while expression:
statement(s)
statement(s)
A final note on loop nesting is that we can put any type of loop inside of any other type of loop.
For example, a for loop can be inside a while loop or vice versa.
# Python program to illustrate
# nested for loops in Python
for i in range(1, 5):
for j in range(i):
print(i, end=' ')
print()
Output:
1
22
333
4444

Break, Continue and Pass Statement:


Python supports the following control statements:
Break statement
Continue statement
Pass statement
Break Statement in Python
The break statement in Python is used to terminate the loop or statement in which it is present.
After that, the control will pass to the statements that are present after the break statement, if
available. If the break statement is present in the nested loop, then it terminates only those
loops which contain the break statement.
Syntax of Break Statement
The break statement in Python has the following syntax:
for / while loop:
# statement(s)
if condition:
break
# statement(s)
# loop end
Example:
s = 'psitchekanpur'
for letter in s:
print(letter)
# break the loop as soon it sees 't' or 'u'
if letter == 't' or letter == 'u':
break
print("Out of for loop")
Output:
p
s
i
t
Out of for loop

# Using while loop


i=0
while True:
print(s[i])
# break the loop as soon it sees 'e' or 's'
if s[i] == 'e' or s[i] == 's':
break
i += 1
print("Out of while loop")
Output:
g
e
Out of for loop
g
e
Out of while loop

Continue Statement in Python


Continue statement is opposite to that of the break statement, instead of terminating the loop, it
forces to execute the next iteration of the loop. As the name suggests the continue statement forces
the loop to continue or execute the next iteration. When the continue statement is executed in the
loop, the code inside the loop following the continue statement will be skipped and the next
iteration of the loop will begin.
Syntax of Continue Statement
The continue statement in Python has the following syntax:
for / while loop:
# statement(s)
if condition:
continue
# statement(s)

Example:
for i in range(1, 11):
if i == 6:
continue
else:
print(i, end = " ")
Output:
1 2 3 4 5 7 8 9 10

Pass Statement in Python


The pass statement in Python is used when a statement is required syntactically but you do not
want any command or code to execute. It is like a null operation, as nothing will happen if it is
executed. Pass statements can also be used for writing empty loops. Pass is also used for empty
control statements, functions, and classes.
Syntax of Pass Statement
The pass statement in Python has the following syntax:
function/ condition / loop:
pass

Example:
# pass statement
s = "Name"
for i in s:
if i == 'e':
print('Pass executed')
pass
print(i)
Output:
N
a
m
Pass executed
e
Example2:
for letter in 'Python':
if letter == 'h':
pass
print ('This is pass block')
print ('Current Letter :', letter)
print ("Good bye!")
Output:
Current Letter : P
Current Letter : y
Current Letter : t
This is pass block
Current Letter : h
Current Letter : o
Current Letter : n
Good bye!

You might also like