April 17, 2021

Area of triangle with given sides using c++

 Question :

if lengths of three sides of the triangle are input through the keyboard ,write a program to find the area of the triangle .

SCREENSHOTS 











SOURCE CODE 


#include <iostream>

#include<conio.h>

#include <math.h>

using namespace std;

int main()

{

int a,b,c ;

float area;

cout <<"Enter 3 sides of triangle : \n";

cin>>a>>b>>c;

area=sqrt(pow(((4*a*a*b*b)-((a*a)+(b*b)-(c*c))),2))/4;

cout<<area;

}

April 07, 2021

Reverse given 5 digit numbers using C++ programming

 Question: If a five-digit number is input through the keyboard. Write a program to reverse a number.


solution : 


Screenshot



source code 

#include <iostream>

#include<conio.h>

using namespace std ;

int main()

{

int n;

int rev[6],revn=0;

cout<<"Enter a 5 digit number : ";

cin >>n;

for(int i=1; i<6; i++)

{

rev[i]=n%10;

n=n/10;

}

for(int i=1; i<6; i++)

{

cout<<rev[i];

}

}

Sum of 5 digit number using c++

 QN 1. if a five-digit number is input through the keyboard ,write a program to calculate the sum of digits. (hint: Use the modules operator '%').

solution:

Screenshot 





SOURCE CODE

#include <iostream>

#include<conio.h>

using namespace std ;

int main()

{

int n;

int sum =0;

cout<<"Enter a 5 digit number : ";

cin >>n;

for(int i ; i<6; i++)

{

sum = sum + n%10;

n=n/10;

}

cout<<sum;

}



April 04, 2021

weather app using tkinter python

In this app, we use API to get the weather information. 
 we use free API in this project you can also buy.

screenshots of Weather app




SOURCE CODE 

#IMPORTS MODULE 
import tkinter as tk
import requests
import time
import os

#DEFINE FUNCTION TO GET WEATHER INFORMATION
def getweather(root):
    try:
        city=textfield.get()
        api="http://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=d9db53c6ebe4a8110caa93993b1d48d5"
        json_data=requests.get(api).json()
        condition= json_data['weather'][0]['main']
        temp=int(json_data['main']['temp']-273.15)
        temp_min = int(json_data['main']['temp_min'] - 273.15)
        temp_max = int(json_data['main']['temp_max'] - 273.15)
        pressure = json_data['main']['pressure']
        humidity = json_data['main']['humidity']
        wind = json_data['wind']['speed']
        sunrise=time.strftime("%I:%M:%S", time.gmtime(json_data['sys']['sunrise']-19800))
        sunset = time.strftime("%I:%M:%S", time.gmtime(json_data['sys']['sunset'] - 19800))

        final_info = condition + "\n" + str(temp) + "℃"
        final_data = "\nMax Temperature : "+str(temp_max)+"\nMin Temperature : "+str(temp_min)+"\nPressure : "+str(pressure)+"\nHumidity : "+str(humidity)+"\nWind Speed : "+str(wind)+"\nSunRise : "+str(sunrise)+"\nSunSet : "+str(sunset)


        l1.config(text = final_info)
        l2.config(text = final_data)
    except:
        invalid="invalid city name OR there is no internet connection !! "
        i.config(text=invalid)

#GUI PART USING TKINTER
root = tk.Tk()
root.geometry("500x600")
root.title ("weather app")
f=("poppins",15,"bold")
t=("poppins",35,"bold")
col='gray22'
fcol='gray'


root.configure(background = col)    #backgroung color
l0=tk.Label(root,text='City/Place Name',font=t,bg= col,fg=fcol).pack()
l3=tk.Label(root ,text='powered by ajay',font='poppins 10 bold', bg = col,fg= fcol ).place(x='350',y='550')


textfield=tk.Entry(root,font=t,bg=col,fg=fcol)
textfield.pack(pady=20)
textfield.focus()
textfield.bind('<Return>',getweather)

i=tk.Label(root,bg=col,fg=fcol,font ='areal 10 bold')
i.pack()

l1=tk.Label(root,font = t,bg=col,fg=fcol)
l1.pack()
l2=tk.Label(root,font=f,bg=col,fg=fcol)
l2.pack()

# it creates a loop to view the GUI continues.
root.mainloop()


Project GIT link












March 24, 2021

Decimal into Binary converter using python

In this blog you you can learn how to how to make decimal to binary converter program.


process of conversion :-












source code : 

#decimal to binary converter

def dec_bin(dec):                        #define function

    binnum=[0]*dec                        #list created

    i=0                                             #assign i for count

    while dec > 0:                            #while loop

        binnum[i] = dec%2                #logic part 1

        dec = dec//2                            #logic part 2

        i += 1                                      #increase by 1

    for j in range (i-1,-1,-1):                         #for loop for reverse the binary number to p

        print(binnum[j],end="")                    #printing binary number    

dec = int(input("enter the decimal number : "))                #take input through user 

dec_bin(dec)                                                                       #function calling.. 


March 23, 2021

Sum of all digit of number using python

 Question :

Find sum of all digit of number :-

this problem is solved by two method  :-

1st is without recursion method and 

2nd is using recursion method 

let's start ,

Without recursion method 

step 1 :

make a function with name sumofDigit(num) : and pass the argument which is entered from the user 

def sumofDigit(num):


step 2 :

we use while loop here for checking if num is grater then 0 is show in the code below :-

add=0

while num>0:

if the condition is True then we move to the next step


step 3 :

this step is totally on logic as shown below : -

add  =  add  + num%10

num = num//10

print(add)                #to print the result


step 4 :

in the step you come out from the function and call the function  as shown below : -

num=int (input("enter the number : "));            #take input through user 

sumofDigit(num)                     #function call 


COMPLETE SOURCE CODE 



1st method of without using recursion 

#sum of 4 digit number without recursion


num=int (input("Enter the number : "))

add=0

while num>0:

     add=add+num%10

     num=num//10


print(add)


2nd Method using recursion 

#sum of 4 digit using recurssion

def sdig(num):

    if num==0:

        return 0

    return ((num%10) + sdig(num//10))



num=int (input("Enter the number : "))

print(f"sum of digit of {num} is {sdig(num)}")


March 22, 2021

Reverse digit using python

 Question :

write a function reverse_number () to return the reverse of the number entered.

Example :

Reverse_number(1234) display 4321




Source code :




def reverse_number (num):

    add=""

    while (num > 0):

        n=num%10                                  # logic 

        num=num//10                                               


        add=str(add)+str(n)

    print(add)


num = int (input("Enter the number : "))

reverse_number(num)


March 20, 2021

InstaBot module Upload photo on instagram using python

 Instabot


In  this session  we learn how to upload picture using python library called instabot .

How to instabot on your pc .

step 1: 

go to the START, search  cmd then, press enter key

after that your command prompt is open as show in the given picture : -


step 2: 

you have to type pip install instbot and press ENTER  on the command prompt as shown in picture below : -



AFTER doing this all steps then your instabot is successfully installed on your pc . as shown in picture below : -



now go to the OPEN your IDLE and write the code below : -

Source Code


from instabot import Bot

bot=Bot()

bot.login(username= "yout username ",password="your password")

bot.upload_photo("C:/Users/ajay pandit/Desktop/UtubDownloader 18-03-2021 08_17_23.png" ,caption=" write caption here " )


March 19, 2021

mini robot project using python

 Mini robot using python 













In this project we use four library

1. SpeechRecognition library

2. wikipedia libirary

3. gTTS library

4. pyaudio library

5. playsound library 



source code

import speech_recognition as sr

import wikipedia

from gtts import gTTS

from playsound import playsound


#recording part

for i in range(1,10):

    rec = sr.Recognizer()

    with sr.Microphone() as source:

        print("clearing backgroung noise.....")

        rec.adjust_for_ambient_noise(source, duration=1)

        print("weating for your message : ")

        recaudio = rec.listen(source)

        print("recording done... !")

    try:

        # recording to text converting part

        print("printing the message ....")

        text = rec.recognize_google(recaudio, language='hindi-IN')

        print(f"your messange is : {format(text)}")


        # listining part

        topic = (f"searching for ---> {format(text)}")

        summ = wikipedia.summary(topic)

        print(summ)

        tts = gTTS(summ)

        tts.save(f"wiki{format(text)}.mp3")


        # reading audio file

        print("reading.....")

        playsound(f"wiki{format(text)}.mp3")


    except:

        print("keyword is not found !!")


March 18, 2021

Digital clock using C++

Digital clock using c++
Object oriented concepts are used in this program...........



 

source code 

#include<iostream>

#include<conio.h>

#include<windows.h>

using namespace std;

class time

{

public:

int h,m,s;

public:

void gettime()

{

int e=0;

while (e==0)

{

cout<<"hour : ";

cin>>h;

cout<<"minute : ";

cin>>m;

cout<<"secound : ";

cin>>s;

if (h<24 && m<60 && s<60)

{

e++;

}

else

{

system ("cls");

}

}

}

void conditions()

{

system("cls");

cout<<h<<":"<<m<<":"<<s<<endl;

Sleep(1000);

s++;

}

void secound()

{

if (s>59)

{

s=0;

m++;

}

}

void minute ()

{

if (m>59)

{

m=0;

h++;

}

}

void hour ()

{

if (h>24)

{

h=0;

}

}

};


int main()

{

int a=0;

time obj;

obj.gettime();

while(a==0)

{

obj.conditions();

obj.secound();

obj.minute();

obj.hour();

}

}

March 07, 2021

strong number using python

 Strong number is a special number whose sum of factorial of digits is equal to the original number. For example: 145 is strong number. Since, 1! + 4!

IDLE view : 













source code :

#strong number 145

def fact(n):    #calculating factorial 

    if (n>0):

        return (n*fact(n-1))

    else:

        return (1)

#strong number  code

add=0

num=input("enter the number : ")

l=(len(num))

for i in range(0,l):

    add=add+fact(int(num[i]))

if int(num)==add:

    print(f"{num} is strong number ")

else:

    print (f"{num} is not strong number ")

    



prime number using python

 Positive integer greater than 1 which has no other factors except 1 and the number itself is called a prime number. 2, 3, 5, 7 etc. are prime numbers as they do not have any other factors. But 6 is not prime (it is composite) since, 2 x 3 = 6.









num=int(input("enter the numbr : "))


for i in range (2,num):

    if (num%i != 0 ):

        print(f"{num} is  a prime number ")

        break

    else:

        print (f"{num} is not prime number ")

        break;


video :




March 06, 2021

perfect number program using python

 perfect number program using python

Perfect number, a positive integer that is equal to the sum of its proper divisors. The smallest perfect number is 6, which is the sum of 1, 2, and 3. Other perfect numbers are 28, 496, and 8,128.












source code

# enter number is perfect or not 

num = int (input("enter the number : "))

add=0
for i in range (1,num):
if(num%i==0):
add=add+i

if num==add:
print(f"{num} is profect number ")
else:
print (f"{num} is not profect number ")








March 01, 2021

create text input and submit button using kivy python

kivy project



 import kivy

from kivy.app import App
from kivy.uix.label import Label
from kivy.uix.gridlayout import GridLayout
from kivy.uix.textinput import TextInput
from kivy.uix.button import Button

class MyGradeLayout(GridLayout):
def __init__(self, **kwargs):
super(MyGradeLayout,self).__init__(**kwargs)
self.cols=2
#name:
self.add_widget(Label(text='name : ',font_size=30))
self.name=TextInput(multiline=False)
self.add_widget(self.name)
#movies:
self.add_widget(Label(text='movies : ',font_size=30))
self.movies = TextInput(multiline=False)
self.add_widget(self.movies)
#ratig:
self.add_widget(Label(text='rating : ',font_size=30))
self.rating = TextInput(multiline=False)
self.add_widget(self.rating)
#button
self.submit=Button(text="submit",font_size=32)
self.submit.bind(on_press = self.press)
self.add_widget(self.submit)

def press(self,instance):
name = self.name.text
movies = self.movies.text
rating = self.rating.text
#print(f"hello {name}, you love {movies}, because the rating of this moves is {rating}")
self.add_widget(Label(text=f"Hello {name},\n you love '{movies}' movies,\n because the rating of this moves is {rating}"))
#after press the button clear input boxes
self.name.text=""
self.rating.text=""
self.movies.text=""



class MyApp(App):
def build(self):
return MyGradeLayout()


if __name__=='__main__':
MyApp().run()

February 01, 2021

Create Music player
















from tkinter import *

from playsound import playsound

import os

root= Tk()

def play():

    playsound("C:\\Users\\Hacking knowledge\\Desktop\\songs\\a (1).mp3")

def allsong1(): 

    allsong=os.listdir("C:\\Users\\Hacking knowledge\\Desktop\\songs")

    print("LIST OF SONGS ")

    verticaltable="\n".join(allsong)

    print (verticaltable)

            

def push():

    pass


root.title("Aj player")

root.geometry("245x400")

f1=Frame(root,bg="yellow4",padx="7",borderwidth= "6")

f1.pack(side=LEFT,fill="y")


b1=Button(f1,text="all song",bg="yellow1",fg="gray",padx="10",pady="10",font="arial 10 bold",borderwidth="10",command=allsong1)

b1.pack(side=LEFT)

b2=Button(f1,text="stop",bg="yellow1",fg="gray",padx="10",pady="10",font="arial 10 bold",borderwidth="10")

b2.pack(side=LEFT)

b3=Button(f1,text="play",bg="yellow1",fg="gray",padx="10",pady="10",font="arial 10 bold",borderwidth="10",command=play)

b3.pack(side=LEFT)


root.mainloop()


January 31, 2021

Create button using tkinter python

 









from tkinter import *

obj=Tk()

def name():

    print ("ajay pandit")


def profilepic():

    root=Tk()

    root.geometry("0x0")

    root.title("ajay pandit")

    photo=PhotoImage(file="4.png")

    aj=Label(image=photo)

    aj.pack()

    root.mainloop()


def aboutus():

    print('''\n\n

The computer science engineer

expert on programming(c,c++,java,python,html,css,sql)

certified ethical hacker''')


def contactus():

    print('''\n\n

phonr no. : 0123456789

email : ajayoneness123@gmail.com

instagram.com/hacking_knowledge

www.codeajay.blogspot.com

fb.com/hackingknowledge''')

obj.geometry("500x900")

f1 =Frame(obj,bg="green",borderwidth=6,relief=RAISED)

f1.pack()

b1=Button(f1,text="contact us",font ="arial,20,bold",padx=10,pady=10,bg="gray",command=contactus)

b1.pack(side=RIGHT,anchor="nw")

b2=Button(f1,text="about us",font ="arial,10,bold",padx=10,pady=10,bg="gray",command=aboutus)

b2.pack(side=RIGHT,anchor="nw")

b3=Button(f1,text="profile pic",font ="arial,10,bold",padx=10,pady=10,bg="gray",command=profilepic)

b3.pack(side=RIGHT,anchor="nw")

b4=Button(f1,text="name",font ="arial,10,bold",padx=10,pady=10,bg="gray",command=name)

b4.pack(side=RIGHT,anchor="nw")

obj.mainloop()


January 27, 2021

Happy birth day project


 










from tkinter import *

import time

import playsound

#BORDER STYLE(relief)= SUNKEN, RAISED, GROOVE, RIDGE

for i in range(1,10):

    root=Tk()

    root.geometry("1000x1000")

    f1=Frame(root)

    f1.pack()

    f2=Frame(root)

    f2.pack()


    lb=Label(f1,text=f'''It's 28th jan \nshivraj birthday!!!\nHAPPY BIRTHDAY TO YOU SHIVRAJ''',bg="gray",

             fg="black",padx="40",pady="20",font="arial 30 bold", borderwidth=10,relief=RAISED)

    lb.pack(anchor="ne",fill="x")

    pic=PhotoImage(file="3.png")

    lb=Label(f2,image=pic,bg="purple",

             fg="black",padx="40",pady="20",font="arial 20 bold", borderwidth=10,relief=RAISED)

    lb.pack(anchor="ne",fill="x")

    root.mainloop()

    time.sleep(0.4)


January 26, 2021

Happy republic day


















from colorama import init 

from termcolor import colored 

import time 


for i in range (1,5):

print (colored('********************************* ','green'))

time.sleep(0.5)

for i in range (1,5):

print (colored('********************************* ','white'))

time.sleep(0.5)


for i in range (1,5):

print (colored('********************************* ','red'))

time.sleep(0.5)

for i in range (1,8):

print (colored('**'))

time.sleep(0.5)

print (colored ('\n\tHappy repbulic day ','yellow'))


January 25, 2021

The flag of NEPAL using python









 




for i in range (1 , 10):

print(" *" * (i))

time .sleep(0.5)

for i in range(1 , 10):

print ( " *"*(i))

time .sleep(0.5)

for i in range (1,8):

print (" *")

time .sleep(0.5)

print ("\n\n\tThe NEPAL")

Snake Water Gun game using python

 



import random


def game(computer , your ):

if computer==your:

return None

elif computer=="s":

if your == "w":

return False

elif your=="g":

return True

elif computer =="w":

if your=="g":

return False

elif your== "s":

return True

elif computer == "g":

if your=="w":

return True 

elif your== "s":

return False

print ("\t\tSNAKE WATER GUN GAME \n")

print("computer turn ....... \nsnake(s) water (w) or gun (g)\n\t\nprocessing.......\n")

rando=random.randint(1,3)

if rando==1:

computer="s"

elif rando==2:

computer="w"

elif rando==3:

computer="g"


your = input ("your turn ::\n snake (s) water (w) or gun (g)  :  ")

a=game(computer,your)


print (f"\ncomputer choose {computer}")


if a== None :

print ('game is tie')

elif a:

print ('you win !!!')

else:

print("you lose !!!")


find the cube of the range given digits. || codeAj

Find the cube of the range given Digits. Source Code r= int ( input ( "enter the range of digit : " )) def number_conter (n): ...