Posts

Showing posts from August, 2020

My first kivy game--pong ball

 ##### pong.kv file##### <pongBall>: size:100,100 canvas: Ellipse: pos:self.pos size:self.size <pongPaddle>: size:50,300 canvas: Rectangle: pos:self.pos size:self.size <pongGame>: ball:pong_ball player1:playerLeft player2:playerRight canvas: Rectangle: pos :self.center_x -5 ,0 size:10,self.height Label: font_size:70 center_x:root.width/4 top: root.top-50 text:str(root.player2.score) Label: font_size:70 center_x:root.width*3/4 top: root.top-50 text:str(root.player1.score) pongBall: id:pong_ball center:self.parent.center pongPaddle: id:playerLeft x:root.x center_y:root.center_y pongPaddle: id:playerRight x:root.width-self.width center_y:root.center_y #main.py file from kivy.app import App from kivy.uix.widget import Widget from kivy.properties import NumericProperty , ReferenceListProperty,ObjectProperty   from kivy.vector import Vector from kivy.clock import Clo...

Colur foll multicolored

 from tkinter import * from random import choice lis=["green","blue","red","black","white","yellow"] root=Tk() root.geometry("1040x1900") c1=Canvas(root,height=1900,width=1040,background="grey") c1.pack(fill="both") def texts(row,column):  text=color()  fill=color()  while text==fill:   fill=color()  c1.create_text(row,column,text=text,fill=fill,font="comicsanns 10") def color():  return str(choice(lis)) height=100 def make():   texts(100,height)  texts(300,height)  texts(500,height)  texts(700,height)  texts(900,height) while height<1900:   make()  height+=200  root.mainloop()

Query fecther

 #wolfram alpha api   import wolframalpha # Taking input from user question = input('Question: ') # App id obtained by the above steps app_id = "T7JEE3-8VXU93896P" # Instance of wolf ram alpha # client class client = wolframalpha.Client(app_id) # Stores the response from # wolf ram alpha res = client.query(question) # Includes only text from the response answer = next(res.results).text print(answer)

Snake water gun console game

 import random  def user_input():     inp=input("enter\n s - snake\n w -water \n g - gun\n")      return(inp)        def bot_choice():     choice_list=["s","g","w"]     choice=random.choice(choice_list)     return(choice) user_win=0 bot_win=0 tie=0    def result(user, bot):          global user_win     global bot_win     global tie          if user == "s" and bot=="g":                 print(f"You chose {user} and bot chose {bot}\n bot wins")         bot_win+=1     elif user == "g" and bot=="w":                   print(f"You chose {user} and bot chose {bot}\n bot wins")          bot_win+=1      elif user == "w" and bot=="s":          print...

Clutter organizer

 import os,sys #getting cwd cwd=os.getcwd() print(f"folder : {cwd}\n\n") #listing files and removing lis= os.listdir() if lis==["organizer.py"]:  print(f"No files found in folder : {os.getcwd()}")  sys.exit() lis.remove("organizer.py") files=lis.copy() class main:  def __init__(self):   pass     def getext(ext_name):   exts=[fil for fil in files if os.path.splitext(fil)[1].lower() in ext_name]   return exts  def create_if_not(folder):      if not os.path.exists(folder):       os.makedirs(folder)  def move(foldername,filee):       for fi in filee:                     os.replace(fi,f"{cwd}/{foldername}/{fi}")      #===creating folders===# print("=========================================") print("Defining folder's") main.create_if_not("python_Images") main.create_if_not("python_Docs") main.create_if_not("python_...

Otp system

 import random import datetime,os os.system("clear") otp=int(random.randint(100000,999999)) time=datetime.datetime.now().hour def greet():     if time>=0 and time<12:         print('Good morning!')     elif time<=12 and time>16:         print("Good afternoon!")     else:         print('Good evening!') greet() print(f"Please don't share this OTP with anyone\nYour OTP is {otp}\nI repet your OTP is {otp}\nGood-Bye")

Whiteboard tkinter

 #=======imports=======# from tkinter import * from tkinter.colorchooser import askcolor root=Tk() ## variable defining#### colour="blue" #========Theme Bacground========# def changeBg():         (triple, hexstr) = askcolor()         if hexstr:          canvas.config(background=hexstr) def Light():         root.title("Alvin's Whiteboard")         canvas.config(background="white")          def Dark():      root.title("Alvin's blackboard")      canvas.config(background="black") #========fg colour===========# def changeFg():         global colour         (triple, hexstr) = askcolor()         if hexstr:          colour=hexstr def blue():  global colour  colour="blue" def white():  global colour  colour="white" def red(): ...