PYTHON PART - 1

PYTHON DATA TYPES ,OPERATORS AND STRINGS 







Python Overview

What is Python

  • Python is a dynamically typed, General Purpose Programming Language that supports an object-oriented programming approach as well as a functional programming approach.
  • Python is also an interpreted and high-level programming language.
  • It was created by Guido Van Rossum in 1989.

 

Features of Python

  • Python is simple and easy to understand.
  • It is Interpreted and platform-independent which makes debugging very easy.
  • Python is an open-source programming language.
  • Python provides very big library support. Some of the popular libraries include NumPy, Tensorflow, Selenium, OpenCV, etc.
  • It is possible to integrate other programming languages within python.



 

What is Python used for

  • Python is used in Data Visualization to create plots and graphical representations.
  • Python helps in Data Analytics to analyze and understand raw data for insights and trends.
  • It is used in AI and Machine Learning to simulate human behavior and to learn from past data without hard coding.
  • It is used to create web applications.
  • It can be used to handle databases.
  • It is used in business and accounting to perform complex mathematical operations along with quantitative and qualitative analysis.

Installation & Getting Started

Steps to Install Python:

  1. Visit the official python website: https://www.python.org/
  2. Download the executable file based on your Operating System and version specifications.
  3. Run the executable file and complete the installation process.

Version:

After installation check the version of python by typing following command: ‘python --version’.

 

Starting Python:

Open Python IDE or any other text editor of your preferred choice. Let’s understand python code execution with the simplest print statement. Type the following in the IDE: 

print("Hello World !!!")

Now save the file with a .py extension and Run it. You will get the following output:

Hello World !!!

Installing Packages:

To install packages in Python, we use the pip command. 
e.g. pip install "Package Name"

Following command installs pandas package in Python.

pip install pandas

What is Syntax?

In simplest words, Syntax is the arrangement of words and phrases to create well-formed sentences in a language. In the case of a computer language, the syntax is the structural arrangement of comments, variables, numbers, operators, statements, loops, functions, classes, objects, etc. which helps us understand the meaning or semantics of a computer language.

 

For E.g. a ‘comment’ is used to explain the functioning of a block of code. It starts with a ‘#’.

More on comments in the comments chapter.

 

For E.g. a block of code is identified by an ‘indentation’. Have a look at the following code, here print(i) is said to be indented with respect to the link above it. In simple words, indentation is the addition of spaces before the line "print(i)"


for i in range(5):
    print(i)

Python Comments

A comment is a part of the coding file that the programmer does not want to execute, rather the programmer uses it to either explain a block of code or to avoid the execution of a specific part of code while testing.

 

Single-Line Comments:

To write a comment just add a ‘#’ at the start of the line.

Example 1:

#This is a 'Single-Line Comment'
print("This is a print statement.")

Output:

This is a print statement. 

 

Example 2:

print("Hello World !!!") #Printing Hello World

Output:

Hello World !!!

 

Example 3:

print("Python Program")
#print("Python Program")

Output:

Python Program

 

 

Multi-Line Comments:

To write multi-line comments you can use ‘#’ at each line or you can use the multiline string.

Example 1: The use of ‘#’.

Explain
#It will execute a block of code if a specified condition is true. #If the codition is false than it will execute another block of code. p = 7 if (p > 5): print("p is greater than 5.") else: print("p is not greater than 5.")

Output:

p is greater than 5.

 

Example 2: The use of multiline string.

Explain
"""This is an if-else statement. It will execute a block of code if a specified condition is true. If the condition is false then it will execute another block of code.""" p = 7 if (p > 5): print("p is greater than 5.") else: print("p is not greater than 5.")

Output:

p is greater than 5.

Python Variables

Variables are containers that store information that can be manipulated and referenced later by the programmer within the code.

In python, the programmer does not need to declare the variable type explicitly, we just need to assign the value to the variable.

Example:

name = "Abhishek"   #type str
age = 20            #type int
passed = True       #type bool

 

It is always advisable to keep variable names descriptive and to follow a set of conventions while creating variables:

  • Variable name can only contain alpha-numeric characters and underscores (A-z, 0-9, and _ )
  • Variable name must start with a letter or the underscore character.
  • Variables are case sensitive.
  • Variable name cannot start with a number.

Example:

Explain
Color = "yellow" #valid variable name cOlor = "red" #valid variable name _color = "blue" #valid variable name 5color = "green" #invalid variable name $color = "orange" #invalid variable name

 

Sometimes, a multi-word variable name can be difficult to read by the reader. To make it more readable, the programmer can do the following:

Example:

NameOfCity = "Mumbai"       #Pascal case
nameOfCity = "Berlin"       #Camel case
name_of_city = "Moscow"     #snake case

 

Scope of variable:

The scope of the variable is the area within which the variable has been created. Based on this a variable can either have a local scope or a global scope.

Local Variable:

A local variable is created within a function and can be only used inside that function. Such a variable has a local scope.

Example:

Explain
icecream = "Vanilla" #global variable def foods(): vegetable = "Potato" #local variable fruit = "Lichi" #local variable print(vegetable + " is a local variable value.") print(icecream + " is a global variable value.") print(fruit + " is a local variable value.") foods()

Output:

Potato is a local variable value.
Vanilla is a global variable value.
Lichi is a local variable value.

 

Global Variable:

A global variable is created in the main body of the code and can be used anywhere within the code. Such a variable has a global scope.

Example:

Explain
icecream = "Vanilla" #global variable def foods(): vegetable = "Potato" #local variable fruit = "Lichi" #local variable print(vegetable + " is a local variable value.") foods() print(icecream + " is a global variable value.") print(fruit + " is a local variable value.")

Output:

Potato is a local variable value.
Vanilla is a global variable value.


Data Types

Data type specifies the type of value a variable requires to do various operations without causing an error. By default, python provides the following built-in data types:

Numeric data: int, float, complex

int: 3, -8, 0

float: 7.349, -9.0, 0.0000001

complex: 6 + 2i

more on numeric data types in the number chapter.

 

Text data: str

str: “Hello World!!!”, “Python Programming”

 

Boolean data:

Boolean data consists of values True or False.

 

Sequenced data: list, tuple, range

list: A list is an ordered collection of data with elements separated by a comma and enclosed within square brackets. Lists are mutable and can be modified after creation.

Example:

list1 = [8, 2.3, [-4, 5], ["apple", "banana"]]
print(list1)

Output:

[8, 2.3, [-4, 5], ['apple', 'banana']]

 

tuple: A tuple is an ordered collection of data with elements separated by a comma and enclosed within parentheses. Tuples are immutable and can not be modified after creation. 

Example:

tuple1 = (("parrot", "sparrow"), ("Lion", "Tiger"))
print(tuple1)

Output:

(('parrot', 'sparrow'), ('Lion', 'Tiger'))

 

range: returns a sequence of numbers as specified by the user. If not specified by the user then it starts from 0 by default and increments by 1.

Example:

sequence1 = range(4,14,2)
for i in sequence1:
    print(i)

Output:

Explain
4 6 8 10 12

 

Mapped data: dict

dict: a dictionary is an unordered collection of data containing a key:value pair. The key:value pairs are enclosed within curly brackets.

Example:

dict1 = {"name":"Sakshi", "age":20, "canVote":True}
print(dict1)

Output:

{'name': 'Sakshi', 'age': 20, 'canVote': True}

 

Binary data: bytes, bytearray, memoryview

bytes: bytes() function is used to convert objects into byte objects, or create empty bytes object of the specified size.

Example:

Explain
#Converting string to bytes str1 = "This is a string" arr1 = bytes(str1, 'utf-8') print(arr1) arr2 = bytes(str1, 'utf-16') print(arr2) #Creating bytes of given size bytestr = bytes(4) print(bytestr)

Output:

b'This is a string'
b'\xff\xfeT\x00h\x00i\x00s\x00 \x00i\x00s\x00 \x00a\x00 \x00s\x00t\x00r\x00i\x00n\x00g\x00'
b'\x00\x00\x00\x00'

 

bytearray: bytearray() function is used to convert objects into bytearray objects, or create empty bytearray object of the specified size.

Example:

Explain
#Converting string to bytes str1 = "This is a string" arr1 = bytearray(str1, 'utf-8') print(arr1) arr2 = bytearray(str1, 'utf-16') print(arr2) #Creating bytes of given size bytestr = bytearray(4) print(bytestr)

Output:

bytearray(b'This is a string')
bytearray(b'\xff\xfeT\x00h\x00i\x00s\x00 \x00i\x00s\x00 \x00a\x00 \x00s\x00t\x00r\x00i\x00n\x00g\x00')
bytearray(b'\x00\x00\x00\x00')

 

memoryview: memoryview() function returns a memory view object from a specified object.

Example:

str1 = bytes("home", "utf-8")
memoryviewstr = memoryview(str1)
print(list(memoryviewstr[0:]))

Output:

[104, 111, 109, 101]

 

Set data:

Set is an unordered collection of elements in which no element is repeated. The elements of sets are separated by a comma and contained within curly braces.

Example:

set1 = {4, -5, 8, 3, 2.9}
print(set1)

Output:

{2.9, 3, 4, 8, -5}

 

None:

None is used to define a null value. When we assign a None value to a variable, we are essentially resetting it to its original empty state which is not the same as zero, an empty string or a False value.

Example:

state = None
print(type(state))

Output:

<class 'NoneType'>



Python Numbers

In Python, numbers are of the following data types:

  • int
  • float
  • complex

 

int

int is a positive or a negative integer of any length. int should not be a decimal or a fraction.

Example:

Explain
int1 = -2345698 int2 = 0 int3 = 100548 print(type(int1)) print(type(int2)) print(type(int3))

Output:

<class 'int'>
<class 'int'>
<class 'int'>

 

Float

A float is a positive or a negative decimal number. It can be an exponential number or a fraction.

Example:

Explain
flt1 = -8.35245 #decimal number flt2 = 0.000001 #decimal number flt3 = 2.6E44 #exponential number flt4 = -6.022e23 #exponential number print(type(flt1)) print(type(flt2)) print(type(flt3)) print(type(flt4))

Output:

Explain
<class 'float'> <class 'float'> <class 'float'> <class 'float'>

 

complex

Complex numbers are a combination of real and imaginary number. They are of the form a + bj, where a is the real part and bj is the imaginary part.

Example:

Explain
cmplx1 = 2 + 4j cmplx2 = -(3 + 7j) cmplx3 = -4.1j cmplx4 = 6j print(type(cmplx1)) print(type(cmplx2)) print(type(cmplx3)) print(type(cmplx4))

Output:

Explain
<class 'complex'> <class 'complex'> <class 'complex'> <class 'complex'>

 



Data Conversion

  • The process of converting numeric data from one type to another is called as type conversion.
  • To convert from integer to float, we use float() function.

 

To convert from integer to complex, we use the complex() function.

Example:

Explain
num1 = -25 num2 = float(num1) num3 = complex(num1) print(num2) print(num3)

Output:

-25.0
(-25+0j)

 

  • To convert from float to integer, we use int() function. int() function rounds of the given number to the nearest integer value.

 

To convert from float to complex, we use the complex() function.

Example:

Explain
num1 = 8.4 num2 = int(num1) num3 = complex(num1) print(num2) print(num3)

Output:

8
(8.4+0j)

 

Note: complex numbers cannot be converted to integer or float.




Type Casting

Similar to type conversion, type casting is done when we want to specify a type on a variable. 

Example:

Explain
str1 = "7" str2 = "3.142" str3 = "13" num1 = 29 num2 = 6.67 print(int(str1)) print(float(str2)) print(float(str3)) print(str(num1)) print(str(num2))

Output:

Explain
7 3.142 13.0 29 6.67


Python Operators

Python has different types of operators for different operations. They are as follows:

 












Python Booleans

Boolean consists of only two values; True and False.

 

Why are Boolean’s needed?

Consider the following if-else statement:

Explain
x = 13 if(x>13): print("X is a prime number.") else: print("X is not a prime number.")

Is it True that X is greater than 13 or is it False?

 

  • Thus Booleans are used to know whether the given expression is True or False.
  • bool() function evaluates values and returns True or False.

 

Here are some examples where the Boolean returns True/False values for different datatypes.

None:

print("None: ",bool(None))

Output:

None:  False

 

Numbers:

Explain
print("Zero:",bool(0)) print("Integer:",bool(23)) print("Float:",bool(3.142)) print("Complex:",bool(5+2j))

Output:

Explain
Zero: False Integer: True Float: True Complex: True

 

Strings:

Explain
#Strings print("Any string:",bool("Nilesh")) print("A string containing number:",bool("8.5")) print("Empty string:" ,"")

Output:

Any string: True
A string containing number: True
Empty string: False

 

Lists:

print("Empty List:",bool([]))
print("List:",bool([1,2,5,2,1,3]))

Output:

Empty List: False
List: True

 

Tuples:

#Tuples
print("Empty Tuple:",bool(()))
print("Tuple:",bool(("Horse", "Rhino", "Tiger")))

Output:

Empty Tuple: False
Tuple: True

 

Sets and Dictionaries:

print("Empty Dictionary:",bool({}))
print("Empty Set:",bool({"Mike", 22, "Science"}))
print("Dictionary:",bool({"name":"Lakshmi", "age":24 ,"job":"unemployed"}))

Output:

Empty Dictionary: False
Empty Set: True
Dictionary: True



Python Strings

What are strings?

In python, anything that you enclose between single or double quotation marks is considered a string. A string is essentially a sequence or array of textual data.

Strings are used when working with Unicode characters. 

Example:

name = "Samuel"
print("Hello, " + name)

Output:

Hello, Samuel

 

Note: It does not matter whether you enclose your strings in single or double quotes, the output remains the same. 

 

Sometimes, the user might need to put quotation marks in between the strings. Example, consider the sentence: He said, “I want to eat an apple”.

How will you print this statement in python?

 

Wrong way 

print("He said, "I want to eat an apple".")

Output:

print("He said, "I want to eat an apple".")
                     ^
SyntaxError: invalid syntax

 

Right way 

print('He said, "I want to eat an apple".')
#OR
print("He said, \"I want to eat an apple\".")

Output:

He said, "I want to eat an apple".
He said, "I want to eat an apple".

 

What if you want to write multiline strings?

Sometimes the programmer might want to include a note, or a set of instructions, or just might want to explain a piece of code. Although this might be done using multiline comments, the programmer may want to display this in the execution of programmer. This is done using multiline strings.

Example:

Explain
receipe = """ 1. Heat the pan and add oil 2. Crack the egg 3. Add salt in egg and mix well 4. Pour the mixture in pan 5. Fry on medium heat """ print(receipe) note = ''' This is a multiline string It is used to display multiline message in the program ''' print(note)

Output:

Explain
1. Heat the pan and add oil 2. Crack the egg 3. Add salt in egg and mix well 4. Pour the mixture in pan 5. Fry on medium heat This is a multiline string It is used to display multiline message in the program

 

Operation on Strings

Length of a String:

We can find the length of a string using len() function.

Example:

fruit = "Mango"
len1 = len(fruit)
print("Mango is a", len1, "letter word.")

Output:

Mango is a 5 letter word.

 

String as an Array:

A string is essentially a sequence of characters also called an array. Thus we can access the elements of this array. 

Example:

pie = "ApplePie"
print(pie[:5])
print(pie[6])	#returns character at specified index

Output:

Apple
i

 

Note: This method of specifying the start and end index to specify a part of a string is called slicing. 

Example:

Explain
pie = "ApplePie" print(pie[:5]) #Slicing from Start print(pie[5:]) #Slicing till End print(pie[2:6]) #Slicing in between print(pie[-8:]) #Slicing using negative index

Output:

Explain
Apple Pie pleP ApplePie

 

Loop through a String:

Strings are arrays and arrays are iterable. Thus we can loop through strings.

Example:

alphabets = "ABCDE"
for i in alphabets:
    print(i)

Output:

Explain
A B C D E

 

 

 

String Methods

Python provides a set of built-in methods that we can use to alter and modify the strings.

 

upper() : The upper() method converts a string to upper case.

Example:

str1 = "AbcDEfghIJ"
print(str1.upper())

Output:

ABCDEFGHIJ

 

lower() : The lower() method converts a string to upper case.

Example:

str1 = "AbcDEfghIJ"
print(str1.lower())

Output:

abcdefghij

 

strip() : The strip() method removes any white spaces before and after the string.

Example:

str2 = " Silver Spoon "
print(str2.strip)

Output:

Silver Spoon

 

rstrip() : the rstrip() removes any trailing characters.

Example:

str3 = "Hello !!!"
print(str3.rstrip("!"))

Output:

Hello

 

replace() : the replace() method replaces a string with another string.

Example:

str2 = "Silver Spoon"
print(str2.replace("Sp", "M"))

Output:

Silver Moon

 

split() : The split() method splits the give string at the specified instance and returns the separated strings as list items.

Example:

str2 = "Silver Spoon"
print(str2.split(" "))      #Splits the string at the whitespace " ".

Output:

['Silver', 'Spoon']

There are various other string methods that we can use to modify our strings.

 

capitalize() : The capitalize() method turns only the first character of the string to uppercase and the rest other characters of the string are turned to lowercase. The string has no effect if the first character is already uppercase.

Example:

Explain
str1 = "hello" capStr1 = str1.capitalize() print(capStr1) str2 = "hello WorlD" capStr2 = str2.capitalize() print(capStr2)

Output:

Hello
Hello world

 

center() : The center() method aligns the string to the center as per the parameters given by the user.

Example:

str1 = "Welcome to the Console!!!"
print(str1.center(50))

Output:

            Welcome to the Console!!!

 

We can also provide padding character. It will fill the rest of the fill characters provided by the user.

Example:

str1 = "Welcome to the Console!!!"
print(str1.center(50, "."))

Output:

............Welcome to the Console!!!.............

 

count() : The count() method returns the number of times the given value has occurred within the given string.

Example:

str2 = "Abracadabra"
countStr = str2.count("a")
print(countStr)

Output:

4

 

endswith() : The endswith() method checks if the string ends with a given value. If yes then return True, else return False. 

Example 1:

str1 = "Welcome to the Console !!!"
print(str1.endswith("!!!"))

Output:

True

Example 2:

str1 = "Welcome to the Console !!!"
print(str1.endswith("Console"))

Output:

False

 

We can even also check for a value in-between the string by providing start and end index positions.

Example:

str1 = "Welcome to the Console !!!"
print(str1.endswith("to", 4, 10))

Output:

True

 

find() : The find() method searches for the first occurrence of the given value and returns the index where it is present. If given value is absent from the string then return -1.

Example:

str1 = "He's name is Dan. He is an honest man."
print(str1.find("is"))

Output:

10

 

As we can see, this method is somewhat similar to the index() method. The major difference being that index() raises an exception if value is absent whereas find() does not.

Example:

str1 = "He's name is Dan. He is an honest man."
print(str1.find("Daniel"))

Output:

-1

 

index() : The index() method searches for the first occurrence of the given value and returns the index where it is present. If given value is absent from the string then raise an exception.

Example:

str1 = "He's name is Dan. Dan is an honest man."
print(str1.index("Dan"))

Output:

13

 

As we can see, this method is somewhat similar to the find() method. The major difference being that index() raises an exception if value is absent whereas find() does not.

Example:

str1 = "He's name is Dan. Dan is an honest man."
print(str1.index("Daniel"))

Output:

ValueError: substring not found

 

isalnum() : The isalnum() method returns True only if the entire string only consists of A-Z, a-z, 0-9. If any other characters or punctuations are present, then it returns False.

Example 1:

str1 = "WelcomeToTheConsole"
print(str1.isalnum())

Output:

True

 

Example 2:

Explain
str1 = "Welcome To The Console" print(str1.isalnum()) str2 = "Hurray!!!" print(str2.isalnum())

Output:

False
False

 

isalpha() : The isalnum() method returns True only if the entire string only consists of A-Z, a-z. If any other characters or punctuations or numbers(0-9) are present, then it returns False.

Example 1:

str1 = "Welcome"
print(str1.isalpha())

Output:

True

 

Example 2:

Explain
tr1 = "I'm 18 years old" print(str1.isalpha()) str2 = "Hurray!!!" print(str2.isalnum())

Output:

False
False

 

islower() : The islower() method returns True if all the characters in the string are lower case, else it returns False. 

Example 1:

str1 = "hello world"
print(str1.islower())

Output:

True

 

Example 2:

Explain
str1 = "welcome Mike" print(str1.islower()) str2 = "Hurray!!!" print(str2.islower())

Output:

False
False

 

isprintable() : The isprintable() method returns True if all the values within the given string are printable, if not, then return False.

Example 1:

str1 = "We wish you a Merry Christmas"
print(str1.isprintable())

Output:

True

 

Example 2:

str2 = "Hello, \t\t.Mike"
print(str2.isprintable())

Output:

False

 

isspace() : The isspace() method returns True only and only if the string contains white spaces, else returns False.

Example 1:

Explain
str1 = " " #using Spacebar print(str1.isspace()) str2 = " " #using Tab print(str2.isspace())

Output:

True
True

 

Example 2:

str1 = "Hello World" 
print(str1.isspace())

Output:

False

 

istitle() : The istitile() returns True only if the first letter of each word of the string is capitalized, else it returns False.

Example 1:

str1 = "World Health Organization" 
print(str1.istitle())

Output:

True

 

Example 2:

str2 = "To kill a Mocking bird"
print(str2.istitle())

Output:

False

 

isupper() : The isupper() method returns True if all the characters in the string are upper case, else it returns False. 

Example 1:

str1 = "WORLD HEALTH ORGANIZATION" 
print(str1.isupper())

Output:

True

 

Example 2:

str2 = "To kill a Mocking bird"
print(str2.isupper())

Output:

False

 

replace() : The replace() method can be used to replace a part of the original string with another string. 

Example:

str1 = "Python is a Compiled Language." 
print(str1.replace("Compiled", "Interpreted"))

Output:

Python is a Interpreted Language.

 

startswith() : The endswith() method checks if the string starts with a given value. If yes then return True, else return False. 

Example 1:

str1 = "Python is a Interpreted Language" 
print(str1.startswith("Python"))

Output:

True

 

Example 2:

str1 = "Python is a Interpreted Language" 
print(str1.startswith("a"))

Output:

False

 

We can even also check for a value in-between the string by providing start and end index positions.

Example:

str1 = "Python is a Interpreted Language" 
print(str1.startswith("Inter", 12, 20))

Output:

True

 

swapcase() : The swapcase() method changes the character casing of the string. Upper case are converted to lower case and lower case to upper case.

Example:

str1 = "Python is a Interpreted Language" 
print(str1.swapcase())

Output:

pYTHON IS A iNTERPRETED lANGUAGE

 

title() : The title() method capitalizes each letter of the word within the string.

Example:

str1 = "He's name is Dan. Dan is an honest man."
print(str1.title())

Output:

He'S Name Is Dan. Dan Is An Honest Man.



Format Strings

What if we want to join two separated strings?

We can perform concatenation to join two or more separate strings.

Example:

Explain
str4 = "Captain" str5 = "America" str6 = str4 + " " + str5 print(str6)

Output:

Captain America

 

In the above example, we saw how one can concatenate two strings. But how can we concatenate a string and an integer? 

name = "Guzman"
age = 18
print("My name is" + name + "and my age is" + age)

Output:

TypeError: can only concatenate str (not "int") to str

As we can see, we cannot concatenate a string to another data type.

 

So what’s the solution?

We make the use of format() method. The format() methods places the arguments within the string wherever the placeholders are specified.

Example:

Explain
name = "Guzman" age = 18 statement = "My name is {} and my age is {}." print(statement.format(name, age))

Output:

My name is Guzman and my age is 18.

 

We can also make the use of indexes to place the arguments in specified order.

Example:

Explain
quantity = 2 fruit = "Apples" cost = 120.0 statement = "I want to buy {2} dozen {0} for {1}$" print(statement.format(fruit,cost,quantity))

Output:

I want to buy 2 dozen Apples for $120.0

 

Escape Characters

Escape Characters are very important in python. It allows us to insert illegal characters into a string like a back slash, new line or a tab.

Single/Double Quote: used to insert single/double quotes in the string.

Example:

Explain
str1 = "He was \"Flabergasted\"." str2 = 'He was \'Flabergasted\'.' print(str1) print(str2)

Output:

He was "Flabergasted".
He was 'Flabergasted'.

 

New Line: inserts a new line wherever specified.

Example:

str1 = "I love doing Yoga. \nIt cleanses my mind and my body."
print(str1)

Output:

I love doing Yoga.
It cleanses my mind and my body.

 

Tab: inserts a tab wherever specified.

Example:

str2 = "Hello \t\tWorld \t!!!"
print(str2)

Output:

Hello           World   !!!

 

Backspace: erases the character before it wherever it is specified.

Example:

str2 = "Hello  \bWorld !!!"
print(str2)

Output:

Hello World !!!

 

Backslash: used to insert a backslash into a string.

Example:

str3 = "What will you eat? Apple\\Banana"
print(str3)

Output:

What will you eat? Apple\Banana





Comments

Popular posts from this blog

VLSI(Very Large Scale Integration)

C++ Programming complete Theory and Lecture