Skip to main content

Featured

The STEM Revolution: From Classrooms to Code Camps

  In Nepal, the "STEM Revolution" represents a significant departure from memorization and a move toward experiential, hands-on science, technology, engineering, and math education. This approach recognizes that although traditional classrooms are fundamental, they frequently fail to provide students with the critical thinking and problem-solving abilities that the modern world requires.  It is motivated by a shared understanding that in order for Nepal's youth to prosper in the digital era, they must not only comprehend ideas but also learn how to use them creatively to address pressing issues. Making education relevant and enabling students to be creators of technology rather than merely consumers are the goals of this revolution. Dynamic, unofficial learning settings like maker spaces, robotics clubs, and programming camps are at the core of this movement. These programs, which are frequently run by neighborhood tech companies and non-profits, act as dynamic centers...

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