This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
float_1 = float(input("Enter value: ")) | |
print('Type of float_1:',type(float_1)) | |
result = float_1*2 | |
print("Twice the given numbers is : ", result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# print sum of two numbers taken from the user | |
num_1 = int(input("Enter first num: ")) | |
num_2 = int(input("Enter second num: ")) | |
print('Type of num_1:',type(num_1)) | |
print('Type of num_2:',type(num_2)) | |
result = num_1 + num_2 | |
print("The sum of given numbers is : ", result) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name = input("Enter name: ") | |
age = input("Enter age: ") | |
print("data_type of name: ", type(name)) | |
print("data_type of age: ", type(age)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def float_range(start, stop, stepsize): | |
val = start | |
while val<stop: | |
yield val | |
val += stepsize | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%matplotlib inline | |
import random | |
import pandas as pd | |
dat = [random.gauss(10, 2) for i in range(150) ] | |
df = pd.DataFrame( { 'C': dat} ) | |
axis = df.C.hist() | |
axis.set_title('Histogram', size=10) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
temp = 10 | |
cold = False | |
if temp<15: | |
print('It is cold') | |
cold = True | |
print('Another statement') | |
print(cold) | |
print('Done') |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
temp = 10; cold = False; | |
if temp<15: print('It is cold'); cold = True; print('Another statement') | |
print(cold); print('Done'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = float('inf') | |
print('Addition : ',a + 10) | |
print('Subtraction : ',a - 10) | |
print('Multiplication : ',a * 10) | |
print('Division : ',a / 10) | |
print('\nMultiplication by Zero: ',a * 0) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
import math | |
# all three ways of defining infinite values | |
inf_1 = float('inf') | |
inf_2 = math.inf | |
inf_3 = np.inf | |
# a large number | |
a = 100000000 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
# Initializing a variable with positive infinity | |
positive_inf = np.inf | |
print('Positive Infinity: ', positive_inf) | |
# Initializing a variable with negative infinity | |
negative_inf = -np.inf | |
print('Negative Infinity: ', negative_inf) |