Python Print Function, Introduction, String Formatting, Format Method

preview_player
Показать описание


#Python Introduction

# Python is case-sensitive language
# Python supports OOP's concept
# Python used in Web development, Machine Learning,
# Data Analytics, Artificial Intelligence etc..
# Python used by the companies like Google, Facebook,
# Instagram, Netflix etc...
# Python is an interpreted language

# print function

# print("Hello World!")
# print('Hello World')
# print(10)
# print(20.33)
# print(type(10))

# x = 10
# y = 'hello'
# z = x + y
# print(z)

# x = """ Python
# Supports
# OOP's
# """
# print(x)

# x = "Hello"
# print(len(x))

#Slicing
#Array index starts from 0, 1, 2.... from start

#Indexing
# x = "Hello"
# print(x[4])

#Negative Indexing
#Negative Indexing starts from -1, -2, .... from end
# x = "Hello"
# print(x[-5])

#Slicing
#In slicing, we provide the range of indexes
# x = "Hello"
# print(x[0:4])
# print(x[2:])
# print(x[:4])
# print(x[:])

# x = "Hello"
# print(x[-5:-2])
# print(x[:-1])
# print(x[-5:])

# Strip Methods
#Remove whitespaces from the beginning or end

# x = " Hello "

# x = " Hello"

# x = "Hello "

# x = "hello"

# x = "HELLO"

# x = " India is great"

# x = " India is great"

# x = "Helllllo"

# x = "Hello"

# x = "Hello"

# x = "Ind"
# y = "ia"
# z = x + y
# print(z)

# x = 'what\'s up'
# print(x)

# x = 'what\n up'
# print(x)

# x = 'what\t up'
# print(x)

# x = 10
# y = "KM"
# z = x + y
# print(z)

#String Formating
# curly brackets {}
# format() method

# x = 10
# y = "{} KM"

# x = 10
# z = 20
# y = "{1} KM"

# Python List
# store multpile items in a single variable
# Array can not store different data types
# List can store different data types
# Lists are mutable means changeable
# Duplicate values are allowed
# Lists are ordered
# Insertion order is preserved
# Lists are represented by square brackets [] and
# values separated by comma.

# Create a List

mylist = [10, "delhi", 20.33, True, 10, -50]
print(mylist)
print(type(mylist))
Рекомендации по теме