Skip to main content

Posts

Showing posts from May, 2020

5 Unique and Useful Python modules.

Motive           There are different types of modules in python which not everyone knows so we thought of introducing them to you guys. Let's start! Note: This is not a tutorial of how to use these but is to show that these modules also exist and if you want to know more you can visit there own page and if you want us to explain leave a comment below. Links to there page are also given below. Hope you found something useful. 1.Wikipedia          Yes, there is a module called Wikipedia in python, you can easily install Wikipedia by pip install wikipedia . We cannot rely on this module for advanced use. It was designed for ease of use and simplicity.  Learn More Here .  Here is a simple example: import wikipedia wikiPython = wikipedia.summary("Python", sentences=2) print(wikiPython)           One big disadvantage is that it works only if the internet is connected to your device. You can even control the number of sentences that you

Python Password Generator

Motive          If you have read my other blogs you might have understood that I watch a lot of YouTube videos, Today I came across a video the made a Password generator. But that doesn't work as expected to work. All it does it shuffles all letters and number and the pick some out according to the length we gave at the beginning of the program. But here comes the problem it does not always have all numbers and special characters and some times it's just even though we have given all the necessary characters. So I taught about an alternative. The Project         All we need is to import is a module called string and  random. Which are pre-installed in python so no pip install needed: import string import random         String is a module which gives access to all alphabets, uppercase and lowercase. Numbers and Special Characters. Even though we could write all those, it is a bit easier to do it this way. Check out their article to learn more,  String , I suggest you check th

Linear Search | Python | Finding a number from a list

Motive          I am a guy who watches a lot of YouTube videos, there I saw a video that teaches a Linear search in python so I taught to try it myself and make it easier for you to understand. Let's see how it's done.   The Project         First let's make a list of numbers and name the list as list . Then let's make a function called searchFor which takes one parameter called number . list = [1,2,3,4,5,6] def searchfor(number):    Then: def searchfor(number): index = 0 indexValue = list[index] Here,we create two variables called index and set it to 0 and indexValue to the number at the index in the list(indexValue = list[index]). After that: def searchfor(number): index = 0 indexValue = list[index] while number != indexValue: index += 1 indexValue = list[index] We run a while loop in which if number  (parameter) is not equal to the indexValue, we add one to index and the get the value in that index and again check

Fibonacci Sequence Algorithm in Python

Motive     To get a job as a programmer you need to pass the coding interviews in which certain questions/algorithms are asked to be solved.       The Project    What is the Fibonacci Sequence?          The Fibonacci Numbers are a series of numbers in which each number is the sum of the proceedings numbers for example 1,1,2,3,5,8,13 etc. Learn more  Here .         1. We are going to create a function that takes the n th number i.e F1=1, F2=1, F3=2, F4=3, F5=5, F6=8, F7=13 etc. In F4=3, 4 is the nth number and in F6=8, 6 is the nth number. But before that, we will make a list of the Fibonacci numbers and we can access them with its index. Let's begin, paste this code into your python ide: a=1 list=[0,1] while True: fib = list[a-1] + list[a] a+=1 list.append(fib) print(list) Run the code for about 2 sec and then press ctrl+c you will get something like this: First, we make a variable called a and give it the value of 1  Then, we make a list called list in which

Chrome Dino Game Automation with Python.

Motive           I saw a video on YouTube that made a python program to automate the chrome dino game at the end he shows a clip of the program playing the game. But there was a problem with the code I do not work when it's dark so I thought of turning the dark mode in the laptop so that it stays dark all the time but that did not work after reaching a score of 700 it becomes day again so I have to think of an alternative see how I did it. The Project  First Import the necessary modules in your IDE import pyautogui from PIL import Image, ImageGrab import time PyAutoGUI   lets Python control the mouse and keyboard, and other GUI automation tasks.                    First, open your terminal and run pip                          learn more on   Pyautogui