Labels

Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

January 09, 2022

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):
count=0
while(n>0):
count = count + 1
n=n//10
return count

print(number_conter(3452679806753))
i=0
while True:
l=i**3
print(l)
i+=1
if number_conter(l) == r:
break

checkout next

December 20, 2021

Password Generator using python || codeAj

 Password Generator  using python


import random
lower='abcdefghijklmnopqrstuvwxyz'
upper = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
number = '0123456789'
symbol='[]{}#()*;._-'
all=lower+upper+number+symbol
length=8
i=1
while(i<=10):
password = "".join(random.sample(all,length))
print(password)
i+=1

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








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

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