Skip to main content

Posts

Showing posts with the label Artificial intelligence

Use Python to Convert any image to cartoon!

 Welcome back to the blog! In this blog we are going to see how you can convert any picture into a cartoon using python programming language. Here is the program! -------------------------------------------------------------------------------------------------------------------------- #we will first import the required libraries import cv2 import numpy as np # reading the image img=cv2.imread("code.jpg") #add the path of the image you want to convert or if the image is in the same folder write the name of the image with the correct extension #working on edges gray=cv2.cvtColor(img,cv2.COLOR_BGR2GRAY) gray=cv2.medianBlur(gray,5) edges=cv2.adaptiveThreshold(gray,255,       cv2.ADAPTIVE_THRESH_MEAN_C,       cv2.THRESH_BINARY,9,9) #Here it is cartoonization color=cv2.bilateralFilter(img,9,250,250) cartoon=cv2.bitwise_and(color,color,mask=edges) cv2.imshow("Image",img) cv2.imshow("Edges",edges) cv2.imshow("Cartoon",cartoon) cv2.waitkey(0) cv2.destroyA...

Snakes and Ladders Game!

 Hey! Welcome back to my blog!  In this blog we will learn to create our one of the favorite childhood game "SNAKES AND LADDERS". I hope everyone is aware about this game. I still remember I used to play this game during my summer vacation and perhaps those were the best days.  Okay, let's start python coding for the same game! So for this particular piece of code, I have assumed the following game board and according to that numbers are assigned to the snakes and ladders. --------------------------------------------------------------------------------------------------------------- from PIL import Image import random end=100 def show_board():     img=Image.open('C:\\Users\\asus01\\Desktop\\slb.jpg')     img.show() def check_ladder(points):         if points==3:             print("Ladder")             return 51         elif points==6:     ...

Use Python to know about Artificial Intelligence

 Hey, welcome back!   You'll be happy to know that you can use python to know about any topic related to your research from wikipedia. Let's check the code.     #import module import requests import pandas as pd from bs4 import BeautifulSoup def getdata(url):     r=requests.get(url)     return r.text htmldata=getdata("https://en.wikipedia.org/wiki/Artificial_Intelligence") soup= BeautifulSoup(htmldata, 'html.parser') data='' for data in soup.find_all("p"):     print(data.get_text()) Here is the output of the code. You can use the same code for acquiring various kind of information just by doing a slight change.  htmldata=getdata("https://en.wikipedia.org/wiki/(#Entering the topic name") Assume, you want to know about solar eclipse, here is the code for it. Observe the slight change in it. #import module import requests import pandas as pd from bs4 import BeautifulSoup def getdata(url):     r=requests.get(url)    ...

GAME : SOLVE JUMBLED WORDS! ( Game Programming With Python)

 Hello there, in this article we are going to help the python learning beginners to create a simple game called as "SOLVE THE JUMBLED WORDS".  The piece of code for the same is given : import random   def choose():     words=['rainbow','computer','science','programming','Cool','mathematics','Good','player','condition','student','happy','hope','Joker','Simple','deaf']     pick=random.choice(words)     return pick   def jumble(word):     jumbled="".join(random.sample(word,len(word)))     return jumbled   def thank(p1n,p2n,p1,p2):     print(p1n,"Your score is : ",p1)     print(p2n,"Your score is : ",p2)     print("Thanks for playing")     print("Have a nice day!")       def play():     p1name=input("Enter the name of player 1: ")     p2name=input...