Skip to content

Instantly share code, notes, and snippets.

View ChaitanyaBaweja's full-sized avatar

Chaitanya Baweja ChaitanyaBaweja

View GitHub Profile
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)
# 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)
name = input("Enter name: ")
age = input("Enter age: ")
print("data_type of name: ", type(name))
print("data_type of age: ", type(age))
def float_range(start, stop, stepsize):
val = start
while val<stop:
yield val
val += stepsize
%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)
temp = 10
cold = False
if temp<15:
print('It is cold')
cold = True
print('Another statement')
print(cold)
print('Done')
temp = 10; cold = False;
if temp<15: print('It is cold'); cold = True; print('Another statement')
print(cold); print('Done');
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)
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
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)