Posts

Python Turtle

Image
The Python turtle library consists of all important methods and functions  that  we will need to create our designs and images. Import the turtle library  using  the following command.     import turtle We can access all methods and functions. First, we need to create a dedicated window where we carry out each drawing command. We can do it by initializing a variable for it.     s=turtle.getscreen() Example: import turtle s=turtle.getscreen()     #Creating Turtle Screen turtle.mainloop()          #To stop the screen to display Output: Turtle Motion: The turtle can move forward and backward in direction that it's facing. Let's see the following functions. forward(disatnce) or turtle.fd(distance) -  It moves the turtle in the forward direction by a certain distance. It takes one parameter distance,  which can be an integer or float.           Example:    ...

Rename Multiple File

Image
import os Folderpath='E:/Old Laptop/Notice/Art Class/Images' def rename(Folderpath,NewName,Number,Extension):     list=os.listdir(Folderpath)     os.chdir(Folderpath)     Number=0     for i in list:         os.rename(i,NewName+str(Number)+'.'+Extension)         Number=Number+1 rename(Folderpath,'Image ',1,'jpg') print("File Renamed Successfully!")    If you have any doubts, feel free to post it in comment Section.

Dobble Card Game

Image
Dobble is a simple pattern recognition game in which players try to find an image shown on two cards.  Each card in Dobble features eight different symbols, with the symbols varying in size from one card to the next. Any two cards have exactly one symbol in common.  Coding: #string contains the constant ascii_letters that has all lowercase and uppercase letters concatenated import string     import random        while(True):      symbols = []     symbols = list(string.ascii_letters)        card1 = [0]*5                         card2 = [0]*5                   #pos1 and pos2 contains some random integer ranging from 0 to 4     pos1 = random.randint(0,4)             pos2 = random.randint(0,4)     #select a random symbol fro...

Hangman Game

Image
import random print('\t'"HANGMAN GAME") print('\t'"******* ****") name=input("What is your Name? ") print('\n''\t'"WELCOME!!",name,'\n'"Let's Play the Game...") print("Try to guess the word in less than 10 attempts...."'\n') print("HINT: TAMIL MOVIE NAME"'\n') with open("word.txt") as d:   #Open file     text=d.read().splitlines()   #Read a file-read() & Split a file into list-splitlines() word=random.choice(text)   #Random Choice turn=10       guess='' while(1):     words=''     for char in word:           if char in guess:             words+=char         else:             words+="."                            if words==word:         print('\n'"~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")       ...

Fibonacci Number Using Recursion Method

Image
Fibonacci series is a series of numbers formed by the addition of the preceeding two numbers in the series. Examples of Fibonacci Series: 0+1+1+2+3+5.... 0 and 1 are the first two terms of the series. These two terms are printed directly. The third term is calculated by adding the first two terms. In this case 0 and 1. So, we get 0+1=1. Hence 1 is printed as the third term. The next term is generated by using the second and third term and not using the first term. n=int( input ( "Enter the Number:"  )) def   Fib ( n ):     if  n== 1 :          return   0      elif  n== 2 :          return   1      elif  n<= 0 :          return  ( "Invalid" )      else :         return(Fib(n -1 )+Fib(n -2 ))   ...

Factorial Number

Image
The factorial of a number is the product of all the integers from 1 to that number. For example, the factorial of 5 is  5*4*3*2*1 .  Factorial is not defined for negative numbers, and the factorial of zero is one, 0!=1. n=int(input("Enter the Number: ")) def factorial(n): if(n==0): return 1 elif(n<0): return("Incorrect number") else: return(n*factorial(n-1)) print('\n'"Factorial of",n,"is",factorial(n)) If you have any doubts, feel free to post it in comment Section.

Palindrome Checking

Image
Read the Bill Amount for Customer Check if it is greater than 10000 if it is true, Read the Customer Name and  check if customer name is Palindrome if it is true, Offer a gift cheque Code: Amt=int(input("Enter Bill Amount: Rs.")) if Amt>=10000: Name=input("Enter Customer Name: ") if Name==Name[::-1]: print("You are Eligible for Discount") print("Congrats!! You have 10% Discount") else: print("Sorry!! You are Not Eligible for Discount") else: print("Thank You For Shopping") Output: If you have any doubts, feel free to post it in comment Section.