https://youtu.be/Zr9fpVThQjE. Check out this video this video.I gave a clear explanation about most complex algorithm in computer science
YouTube
| Implementation of Knapsack Problem in Python| | AK |
In this video we are going to learn about how to perform the knapsack algorithm in python
Mr.Theif shows how he used this algorithm to get more profit
watch this video fully to understand this knapsack problem in python
Source code is available at AK python…
Mr.Theif shows how he used this algorithm to get more profit
watch this video fully to understand this knapsack problem in python
Source code is available at AK python…
⚠️Code for this Video: def knapsack(Capacity, weights, profits, n):
if(n==0 or Capacity==0):
return 0
if(weights[n-1]>Capacity):
return knapsack(Capacity, weights, profits, n-1)
else:
return max(profits[n-1]+knapsack(Capacity-weights[n-1], weights, profits, n-1), knapsack(Capacity,weights, profits, n-1))
print('Enter the profits:')
profits=list(map(int,input().split(' ')))
print('Enter the weights:')
weights=list(map(int,input().split(' ')))
Capacity=int(input('Enter the maximum capacity:'))
n=len(weights)
print(knapsack(Capacity, weights, profits, n))
if(n==0 or Capacity==0):
return 0
if(weights[n-1]>Capacity):
return knapsack(Capacity, weights, profits, n-1)
else:
return max(profits[n-1]+knapsack(Capacity-weights[n-1], weights, profits, n-1), knapsack(Capacity,weights, profits, n-1))
print('Enter the profits:')
profits=list(map(int,input().split(' ')))
print('Enter the weights:')
weights=list(map(int,input().split(' ')))
Capacity=int(input('Enter the maximum capacity:'))
n=len(weights)
print(knapsack(Capacity, weights, profits, n))
Check out the latest video
https://youtu.be/ZXX30OLjaD8
https://youtu.be/ZXX30OLjaD8
YouTube
| Password cracking explained..! | | AK |
Hello everyone, In this video I will show you how your passwords easily cracked by the hackers
In this video I explained what are the ways that your passwords get compromised
Learn Some thing deeply about this algorithms it will help you in many ways
Like…
In this video I explained what are the ways that your passwords get compromised
Learn Some thing deeply about this algorithms it will help you in many ways
Like…
This media is not supported in your browser
VIEW IN TELEGRAM
Next video: How to create a fidget spinner using python [ Share & Support ❤️ ]
from turtle import *
state = {'turn': 0}
def spinner():
"Draw fidget spinner."
clear()
angle = state['turn'] / 10
left(angle)
forward(100)
dot(120, 'red')
back(100)
left(120)
forward(100)
dot(120, 'red')
back(100)
left(120)
forward(100)
dot(120, 'red')
back(100)
left(120)
update()
def animate():
"Animate fidget spinner."
if state['turn'] > 0:
state['turn'] -= 1
spinner()
ontimer(animate, 20)
def flick():
"Flick fidget spinner."
state['turn'] += 50
tracer(False)
width(20)
onkey(flick, 'space')
listen()
animate()
done()
state = {'turn': 0}
def spinner():
"Draw fidget spinner."
clear()
angle = state['turn'] / 10
left(angle)
forward(100)
dot(120, 'red')
back(100)
left(120)
forward(100)
dot(120, 'red')
back(100)
left(120)
forward(100)
dot(120, 'red')
back(100)
left(120)
update()
def animate():
"Animate fidget spinner."
if state['turn'] > 0:
state['turn'] -= 1
spinner()
ontimer(animate, 20)
def flick():
"Flick fidget spinner."
state['turn'] += 50
tracer(False)
width(20)
onkey(flick, 'space')
listen()
animate()
done()
https://youtu.be/BKwnOOs0ml8. Guys video out now 🙋
YouTube
| How to create a Snake game using python | | AK python |
In this video we are going to see about how to create a snake game using python
We are using three libraries to create this epic game that is turtle, random and freegames
Snake game is an epic game. And it provides so many past moments to you
Download…
We are using three libraries to create this epic game that is turtle, random and freegames
Snake game is an epic game. And it provides so many past moments to you
Download…
👍1
from turtle import *
from random import randrange
from freegames import square, vector
food = vector(0, 0)
snake = [vector(10, 0)]
aim = vector(0, -10)
def change(x, y):
"Change snake direction."
aim.x = x
aim.y = y
def inside(head):
"Return True if head inside boundaries."
return -200 < head.x < 190 and -200 < head.y < 190
def move():
"Move snake forward one segment."
head = snake[-1].copy()
head.move(aim)
if not inside(head) or head in snake:
square(head.x, head.y, 9, 'red')
update()
return
snake.append(head)
if head == food:
print('Snake:', len(snake))
food.x = randrange(-15, 15) * 10
food.y = randrange(-15, 15) * 10
else:
snake.pop(0)
clear()
for body in snake:
square(body.x, body.y, 9, 'green')
square(food.x, food.y, 9, 'red')
update()
ontimer(move, 100)
hideturtle()
tracer(False)
listen()
onkey(lambda: change(10, 0), 'Right')
onkey(lambda: change(-10, 0), 'Left')
onkey(lambda: change(0, 10), 'Up')
onkey(lambda: change(0, -10), 'Down')
move()
done()
from random import randrange
from freegames import square, vector
food = vector(0, 0)
snake = [vector(10, 0)]
aim = vector(0, -10)
def change(x, y):
"Change snake direction."
aim.x = x
aim.y = y
def inside(head):
"Return True if head inside boundaries."
return -200 < head.x < 190 and -200 < head.y < 190
def move():
"Move snake forward one segment."
head = snake[-1].copy()
head.move(aim)
if not inside(head) or head in snake:
square(head.x, head.y, 9, 'red')
update()
return
snake.append(head)
if head == food:
print('Snake:', len(snake))
food.x = randrange(-15, 15) * 10
food.y = randrange(-15, 15) * 10
else:
snake.pop(0)
clear()
for body in snake:
square(body.x, body.y, 9, 'green')
square(food.x, food.y, 9, 'red')
update()
ontimer(move, 100)
hideturtle()
tracer(False)
listen()
onkey(lambda: change(10, 0), 'Right')
onkey(lambda: change(-10, 0), 'Left')
onkey(lambda: change(0, 10), 'Up')
onkey(lambda: change(0, -10), 'Down')
move()
done()
👍7👏1
import psutil
battery = psutil.sensors_battery()
percent = battery.percent
from pynotifier import Notification
Notification(
title="Battery Percentage.",
description=str(percent) + "% Battery remaining.",
duration=5, # Duration in seconds
).send()
battery = psutil.sensors_battery()
percent = battery.percent
from pynotifier import Notification
Notification(
title="Battery Percentage.",
description=str(percent) + "% Battery remaining.",
duration=5, # Duration in seconds
).send()
👍2
import COVID19Py
covid19 = COVID19Py.COVID19(data_source="jhu")
latest = covid19.getLatest()
from pynotifier import Notification
Notification(
title="Today COVID 19 News updates.",
description=str(latest),
duration=30, # Duration in seconds
).send()
covid19 = COVID19Py.COVID19(data_source="jhu")
latest = covid19.getLatest()
from pynotifier import Notification
Notification(
title="Today COVID 19 News updates.",
description=str(latest),
duration=30, # Duration in seconds
).send()