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()

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): ...