Jovian
⭐️
Sign In
In [1]:
import time
t1 = time.time()
a=1
b=5
c=8
sum = a+b+c
t2 = time.time()
print(t2-t1)

0.0
In [ ]:
t3 = time.time()

for i in range(10000):
    print(i)
t4 = time.time()
print(t4-t3)
In [ ]:
class flower():
    print("--------Flower Details---------\n")
    def __init__(self,name,color,size):
       
        self.name = name
        self.color = color
        self.size = size
    
f1 = flower("Rose","Red",1.5)
print(" Name :{}\n Color : {}\n Size : {}\n".format(f1.name,f1.color,f1.size))
f2 = flower("Lotus","Pink",2.5)
print(" Name :{}\n Color : {}\n Size : {}\n".format(f2.name,f2.color,f2.size))

In [4]:
from flask import Flask # Flask is a class 
In [5]:
app = Flask(__name__)


@app.route('/get')
def hello_world():
    return 'Hello, World!!!!!!!!!!!!!!!!!!!!!!!!!! '

if __name__ == '__main__':
    app.run()
* Serving Flask app "__main__" (lazy loading) * Environment: production WARNING: This is a development server. Do not use it in a production deployment. Use a production WSGI server instead. * Debug mode: off
* Running on http://127.0.0.1:5000/ (Press CTRL+C to quit)
In [6]:
import time

def timeit(f):
    def wrapper(*args, **kwargs):
        start = time.time()
        f(*args, **kwargs)
        end = time.time()
        print("Time taken : ", end - start)
    return wrapper

@timeit
def addition(a,b):
    s = a * b * a * b * a * b
    print(s)


addition(89,66)
202675767624 Time taken : 0.0009963512420654297
In [7]:
import os
os.getcwd()
Out[7]:
'C:\\Users\\Inker_FSEai_Sys1\\Documents\\Python Contents'
In [8]:
lis = ['anchu','arun','midhun','chinchu','manu']
age = [45,54,23,12,32]

for i in range(len(lis)):
    print("Hello my name is  {}, and I'm {}yrs old".format(lis[i],age[i]))
Hello my name is anchu, and I'm 45yrs old Hello my name is arun, and I'm 54yrs old Hello my name is midhun, and I'm 23yrs old Hello my name is chinchu, and I'm 12yrs old Hello my name is manu, and I'm 32yrs old
In [9]:

class Student: # Base class/super class for all students
   count = 0 # student count

   def __init__(self, name, rollno):
      self.name = name
      self.rollno = rollno
      Student.count += 1
   
   def show_count(self):
       print("Total Students: {}".format(Student.count))

   def show_student(self):
       print("Name : ", self.name,  ", Roll_no: ", self.rollno)
           
           
           

std1 = Student("Zara", 12) # object named std1 
std2 = Student("Manu", 50) # object named std2
std1.show_student()
std2.show_student()
print("Total number of Students: {}".format(Student.count))
Name : Zara , Roll_no: 12 Name : Manu , Roll_no: 50 Total number of Students: 2
In [10]:
x = "AAII"
def myfunc():
    global x
    x = "AI"
    print(x)
myfunc()
    
print("FullStack Engineering " + x)

AI FullStack Engineering AI
In [11]:
diz = {'name' : ['Arun','Anchu','Manu','John','Mark'], 'age' : [12,43,54,62,32]}
for i in range(5):
    print('My name is {} and Im {} years old'.format(diz['name'][i],diz['age'][i]))
My name is Arun and Im 12 years old My name is Anchu and Im 43 years old My name is Manu and Im 54 years old My name is John and Im 62 years old My name is Mark and Im 32 years old
In [12]:
list = [1,2,3,4]
it = iter(list) # this builds an iterator object
#print (next(it)) #prints next available element in iterator
"""Iterator object can be traversed using regular for statement
!usr/bin/python3"""

""""for x in it:
   print (x, end=" ")

#or using next() function
"""
import sys
while True:
   try:
      print (next(it))
   except StopIteration:
      sys.exit() #you have to import sys module for this

1 2 3 4
An exception has occurred, use %tb to see the full traceback. SystemExit
c:\users\inker_fseai_sys1\appdata\local\programs\python\python36\lib\site-packages\IPython\core\interactiveshell.py:3327: UserWarning: To exit: use 'exit', 'quit', or Ctrl-D. warn("To exit: use 'exit', 'quit', or Ctrl-D.", stacklevel=1)
In [ ]:
import sys
def fibonacci(n): #generator function
   a, b, counter = 0, 1, 0
   while True:
      if (counter > n): 
         return
      yield a
      a, b = b, a + b
      counter += 1
In [ ]:
f = fibonacci(6)


while True:
   try:
      print (next(f),end=" ")
   except StopIteration:
      sys.exit()
        

In [ ]:
 
In [ ]:
import time

def deco(f):
    def wrap(*args,**kwargs):
        t1 = time.time()
        f(*args,**kwargs)
        t2 = time.time()
        print("Time taken is :{}".format(t2-t1))
    return wrap
    

@deco
def new(a,b,c):
    print("Out : ", (((a**b)**c))**a)
    return new

new(5,4,3)

In [ ]:
lis = [3,5,6,7]
dis = tuple(lis)
type(dis)
In [ ]:

class Person():
  def __init__(myobject, name, age):
    myobject.name = name
    myobject.age = age
 
  def myfunc(myobject):
    print("Hello, my name is " + myobject.name)

    
p1 = Person("Tom", 25)
p1.myfunc()
In [10]:
high = []
low = []
def miniMaxSum(arr):
    
    for i in range(len(arr)):
        for j in range(len(arr)):
            if arr[i]<arr[j]:
                if arr[i] in low:
                    continue
                else:
                    low.append(arr[i])
            else:
                if arr[i] in high:
                    continue
                else:
                    high.append(arr[i])
            j+=1
        i+=1
    print(high)
    print(low)
    s1 = 0
    s2 = 0
    
    
    
    for j in range(len(low)):
        s2 += low[j]
    print(s2,end = ' ')
    
    for i in range(len(high)):
        s1 += high[i]
    print(s1)
    
    
    
arr = [1,2,3,4,5]
miniMaxSum(arr)        
[1, 2, 3, 4, 5] [1, 2, 3, 4] 10 15
In [29]:

def miniMaxSum(arr):
    arr.sort()
    mini = 0
    maxi = 0
    
    j = 0
    for j in range(len(arr)-1):
        mini += arr[j]
    print(mini,end = ' ')
    
    itm = 1
    for itm in range(1,len(arr)):
        maxi += arr[itm]
    print(maxi)
    
arr = [5,2,3,1,4]
miniMaxSum(arr)     
10 14
In [22]:
arr = [5,2,3,1,4]
arr.sort()
arr
Out[22]:
[1, 2, 3, 4, 5]
In [40]:
def birthdayCakeCandles(ar):
    blow = []
    ar.sort()
    print(ar)
    count = 0
    i = ar_count-1
    for j in range(ar_count):
        if ar[i]==ar[j]:
            count+= 1
    return count

ar = [3,1,2,3]
ar_count = len(ar)
birthdayCakeCandles(ar)
[1, 2, 3, 3]
Out[40]:
2
In [ ]:
 
In [ ]: