Skip to main content

Featured

Tic Tac Toe

Tic Tac Toe Tic Tac Toe is a simple, two-player strategy game played on a 3x3 grid. Players take turns marking a square with either an "X" or an "O", with the goal of being the first to align three of their marks in a row, column, or diagonal.  I have made a simple Tic Tac Toe game using html, css, javascript.  The game doesnot have much features. The game is created to be played by two peoples. It is just a simple game. The code of this game you get in my github page   Link of this game code is below: Tic Tac Toe Game Code /

Python Wikipedia

Intro

Python is high-level, general purpose programming language. By using python we can create different stuffs like dictionary, mobile application, web application, etc. By using python we can also search about any famous place, person, etc.  Like we search in wikipedia, we can get information about any famous places, person etc  from python by using wikipedia module.

Wikipedia in python is the library that makes it easy to access and parse data from Wikipedia.

Installation

For the installation of Wikipedia module , Python should be installed in your computer and pip as well. After this all you can open your command prompt or powershell and type

pip install wikipedia

Now Lets Write the program

import wikipedia

Search = input("type that you want to search") #here I want to search about Nepal
result = wikipedia.search(Search)
try:
  for sr in result:
    print(sr)
    print("-----------------------------------")
    print(wikipedia.page(sr).summary)
    print("******************************************")
    print()
except Exception as e:
  pass

You can also see the output in this link:  https://replit.com/@chandanshresth1/Cmd-Wikipedia#main.py

Lets see how above program is working

First of all we imported the wikipedia module then we asked the user what to search. Then we write result = wikipedia.search(Search). Here we are telling the wikipedia module to search about something we asked the user to type. After this we used the try and except because if there will any error it will not arrive during the program execution. In 4th line we wrote result = wikipedia.search(Search) this will return a list which contains the term related  to the user enter.  In for loop,  for every items in the list are being search in wikipedia and getting the summary of every items in list. Then the program will display the results.

Comments

Popular Posts