chapter 1: Data Structure

1.1 numbers

my_int = 20    # int
my_float = 45.5  # float
my_complex = 20j   # complex
#Print the values of the above declared varibales
print(my_int)
print(my_float)
print(my_complex)
#Print the Data Types of the above declared variables
print(type(my_int))
print(type(my_float))
print(type(my_complex))

1.2 Int

normal_int   = 10
large_int    = 46333666787711
negative_int = -25452233

print(type(normal_int))
print(type(large_int))
print(type(negativee_int))

1.3 Float

#Normal Float varibles
my_float_1 = 1.10
my_float_2 = 1.0
my_float_3 = -35.59

print(type(my_float_1))
print(type(my_float_2))
print(type(my_float_3))

#Float can also be scientific numbers with an "e" to indicate the power of 10.

my_float_4 = 35e3
my_float_5 = 12E4
my_float_6 = -87.7e100

print(type(my_float_4))
print(type(my_float_5))
print(type(my_float_6))

Python Programming Examples on Mathematical Functions

Python Program to Check if a Date is Valid and Print the Incremented Date if it is
Python Program to Compute Simple Interest Given all the Required Values
Python Program to Check Whether a Given Year is a Leap Year
Python Program to Read Height in Centimeters and then Convert the Height to Feet and Inches
Python Program to Take the Temperature in Celcius and Covert it to Farenheit
Python Program to Compute Prime Factors of an Integer
Python Program to Generate all the Divisors of an Integer
Python Program to Print Table of a Given Number
Python Program to Print Sum of Negative Numbers, Positive Even Numbers and Positive Odd numbers in a List
Python Program to Print Largest Even and Largest Odd Number in a List
Python Program to Form an Integer that has the Number of Digits at Ten's Place and the Least Significant Digit of the Entered Integer at One's Place
Python Program to Find Those Numbers which are Divisible by 7 and Multiple of 5 in a Given Range of Numbers
Python Program to Check if a Number is an Armstrong Number
Python Program to Print the Pascal's triangle for n number of rows given by the user
Python Program to Check if a Number is a Perfect Number
Python Program to Check if a Number is a Strong Number
Python Program to Find the LCM of Two Numbers
Python Program to Find the GCD of Two Numbers
Python Program to Compute a Polynomial Equation given that the Coefficients of the Polynomial are stored in a List
Python Program to Check If Two Numbers are Amicable Numbers
Python Program to Find the Area of a Triangle Given All Three Sides
Python Program to Find the Gravitational Force Acting Between Two Objects
Python Program to Check if a Number is a Prime Number
Python Program to Print all the Prime Numbers within a Given Range
Python Program to Print Numbers in a Range (1,upper) Without Using any Loops
Python Program to Find the Sum of Sine Series
Python Program to Find the Sum of Cosine Series
Python Program to Find the Sum of First N Natural Numbers
Python Program to Find the Sum of the Series: 1 + 1/2 + 1/3 + ….. + 1/N
Python Program to Find the Sum of the Series: 1 + x^2/2 + x^3/3 + … x^n/n
Python Program to Compute the Value of Euler's Number e. Use the Formula: e = 1 + 1/1! + 1/2! + …… 1/n!
Python Program to Determine all Pythagorean Triplets in the Range
Python Program to Search the Number of Times a Particular Number Occurs in a List