Step 1: Loading Image: Steps To Perform Up Sampling
Step 1: Loading Image: Steps To Perform Up Sampling
img=imread('coins.png')
img(1:2:end)=0
figure,imshow(img)
Variable Intalization
y = int(3)
print(y)# y will be 3"
3
z = float(3)
print(z)# z will be 3.0"
3.0
x = y = z = "Orange"
print(x)
print(y)
print(z)
Orange
Orange
Orange
Strings
a = "Hello, World!"
print(a)
print(a[0])
print(a[1])
Hello, World!
H
e
Condition Statement
if 5 > 2:
print("Five is greater than two!")
Five is greater than two!
a = 33
b = 33
if b > a:
print("b is greater than a"),
elif a == b:
print("a and b are equal")
a and b are equal
Operators
x = "Python is "
y = "awesome"
z= x+y
print(z)
Python is awesome
print(10*5)
50
x = 15
y=4
print('x / y =',x/y)
x / y = 3.75
Logical Operations
x = True
y = False
print('x and y is',x and y)
print('x or y is',x or y)
print('not x is',not x)
x and y is False
x or y is True
not x is False
While loop
i=1
while i < 6:
print(i)
i += 1
1
2
3
4
5
For Loop
fruits = ["apple", "banana", "cherry"]
for x in fruits:
print(x)
apple
banana
cherry
Range function
The range() function returns a sequence of numbers, starting from 0 by default, and increments by 1
(by default), and ends at a specified number.
for x in range(6):
print(x)
0
1
2
3
4
5
Functions
def my_function():
print("Hello from a function")
my_function()
Hello from a function
Global variable
variables that are created outside of a function (as in all of the examples above) are known as global
variables
x = "abc"
def myfunc():
print("Python is " + x)
myfunc()
Python is abc
Lists
Lists are used to store multiple items in a single variable
Arrays
cars = ["Ford", "Volvo", "BMW"]
x=cars[0]
cars[0] = "Toyota"# modify the ist value item
print(cars)
['Toyota', 'Volvo', 'BMW']
import pandas as pd
df=pd.read_csv('play_tennis.csv')
type(df)
df.tail()
df.shape
df.loc[0]
Access 1st three rows
df.loc[0:2]
One way to access unique elements is the 'iloc' method, where you can access the 1st row and first column as
follows
df.iloc[0,0:2]
df.iloc[0:2,0:2]