Function Caching In Python | Python Tutorials For Absolute Beginners In Hindi #75

preview_player
Показать описание


Best Hindi Videos For Learning Programming:

Follow Me On Social Media
Рекомендации по теме
Комментарии
Автор

from functools import lru_cache
import time

cacheMemory = int(input("How many values you want to cache? "))


def timeWork(n):
time.sleep(n)
return n


timeWork(2)
timeWork(3)
timeWork(4)
timeWork(5)
timeWork(6)
print("again
timeWork(2)
print("finish")

MalhotraHarshika
Автор

import time
from functools import lru_cache
p = int(input("Set the maxsize for the @lru_cache: "))
@lru_cache(maxsize=p)
def time_delay(n1):
for i in range(5):
print(i)
time.sleep(n1)


time_delay(3)
print("Done")
time_delay(3)
print("Memory is cached...")

anubhavraj
Автор

Yes sir mujhe for loop ke sath else ke bare mai pata tha actually mai aapka ye course 2023 mai dekh raha hu, and aapki 100 days of python jo 2022 mai nikli thi uske 60+ videos dekh liye the but it is much better than that malum tha

AnkushSaral
Автор

import time
from functools import lru_cache

print('How many function cache you want?')

no:\\')))
def work(n):
time.sleep(n)
return n

print('\nPlease wite.')
work(2)
if int(input('enter no:\\'))+2 == 4:
work(2)
print('how are you?')
work(2)
print('OK don all functions.' )

danishrafiq
Автор

I accept the challenge sir 🙂

from functools import lru_cache
from time import sleep

try:
user = int(input("Enter how many functions you want in your cache: "))

@lru_cache(maxsize=user)
def remaining_time(n):
sleep(n)
return f"After time {n}"

print(remaining_time(3))
print(remaining_time(2))
print(remaining_time(5))
print(remaining_time(3))
print(remaining_time(2))

except Exception as e:
print(e)

AnkushSaral
Автор

import time
from functools import lru_cache

@lru_cache(maxsize=10)
def calling(sec):
time.sleep(sec)
return sec

if __name__ == '__main__':
call = input("Enter 'call' to call your friend: ")
calling(3)
calling(2)
calling(1)
print("Your call is connecting.")
calling(2)

mukundchamariya
Автор

I except the challenge
import time
from functools import lru_cache
i = int(input("enter a number: "))
@lru_cache(maxsize=i)
def some_work(n):
time.sleep(n)
return n
if __name__ == "__main__":
print("now running some work")
some_work(3)
some_work(6)
some_work(9)
print("done... calling again")
some_work(9)
input("Enter anything: ")
some_work(3)
print("called again")

jaat_Choudhary
Автор

from functools import lru_cache
n = int(input("Enter how many values you want to cache:"))
@lru_cache(maxsize=n)
def add(string1, string2):
# time.sleep(2)
print(f"{string1} {string2} is your string")
string1 = str(input("Enter a string:"))
string2 = str(input("Enter a string:"))
add(string1, string2)
print("Now second fuction calling")
a = add('ankush', 'chaursiya')
print(a)

ankush
Автор

from functools import lru_cache
@lru_cache(maxsize=3)
def save_time(n):
for item in range(n):
print(item)
return n


if __name__ == '__main__':
print("This is staring")
print(save_time(10000))
print("Again runing..")
print(save_time(10000))
print("properly done")

mridulghoshshanto
Автор

from functools import lru_cache
import time
i=input(';')
l = lru_cache(maxsize=1)
def ing(l):
pass
def tim(n):
print('start')
time.sleep(n)
return n
if __name__=='__main__':
t=tim(7)
print(t)
print('end')
input()
tim(7)

crazy
Автор

from functools import lru_cache
import time

@lru_cache(maxsize=3)
def race(n):
time.sleep(n)
return n

if __name__ == '__main__':
print("Race is about to start....Be Ready!")
race(2)
print("on your marks")
race(3/2)
print("Get set")
race(2)
print("GO!!")

blackbeard
Автор

import time

# from functools import lru_cache
# for i in range(int(input("how many values :"))):
# @lru_cache
# def Value_for_lru(n):
# print("somya sharma")
# time.sleep(n)

# print("harshit singh")
# Value_for_lru(3)
# print("Time sleep")
# Value_for_lru(3)

harshitsingh
Автор

inp=int(input("Enter the number of values you want to cache."))
import time
from functools import lru_cache


@lru_cache(maxsize=inp)
def func(n):
time.sleep(n)
return(n)

if __name__ =='__main__':
func(3)

print("yo")
func(3)

print("yo")
func(2)

print("yo")
func(5)

print("yo")
func(5)
print("end")

catcorner
Автор

import time
from functools import lru_cache
t=int(input('How many values do you want to cache?\n'))
@lru_cache(t)
def facto(n):
k=1
for i in reversed(range(n)):
if i==0:
break
k*=i
time.sleep(3)
return k

a=facto(4)
print(a)
a=facto(5)
print(a)
a=facto(6)
print(a)
a=facto(4)
print(a)
a=facto(5)
a=print(a)

RohanSharma-qrfy
Автор

import time
from functools import lru_cache
n=int(input("give any number how mach time you need to use maxsize"))
@lru_cache(maxsize=n)
def work():
time.sleep(3)
return
print("call anythink..")
work()

DarkoGaming
Автор

from functools import lru_cache
import time

Input1 = int(input("Please enter the value for LRU Cache : "))
Input2 = int(input("Please enter the time you want delay for : "))

@lru_cache(maxsize=Input1)
def Some_Work(n):
time.sleep(n)
return n

print("Executing")
Some_Work(Input2)
print("Running again")
Some_Work(Input2)
print("Running again")
Some_Work(Input2)
print("Running again")
Some_Work(Input2)
print("Stopped")

ashokgarg
Автор

# learn usages of lru_cache
import time
from functools import lru_cache
catchmemory = int(input('select max_size:--'))

def wait(n):
time.sleep(n)
return n
if __name__ == '__main__':
wait(1)
print('first')
wait(2)
print('second')
wait(3)
print('third')
wait(3)
print('fourth')

harishdaga
Автор

I accept the challenge

from functools import lru_cache
import time
n=int(input('How many values do you want to cache? '))
@lru_cache(maxsize=n)
def f(num):
t=time.strftime("%H:%M:%S")
time.sleep(num)
print(t)



f(3)
f(5)
f(3)
print('hello')
f(6)

priyanujbora
Автор

import time
from functools import lru_cache

p = int(input("Set the maxsize for the @lru_cache : "))

@lru_cache(maxsize=p)
def timeDelay(n1):
for i in range(1, 6):
print(i)
time.sleep(n1)

timeDelay(6)
print("Done")
timeDelay(3)
print("Memory Caching is Accomplished")

#codewithharry

siddheshpanajkar
Автор

from functools import lru_cache
import time


@lru_cache(maxsize=3)
def School(tm):
time.sleep(tm)
return tm
School(5)
print("This finction is now running..!!")
School(3)
print("It is steel running")
School(5)
print("Now it is done..!!")

tejalmohod