<
Introduction to Python Programming
Python is a high-level, interpreted programming language. That means Python code is executed by an interpreter, which reads and runs your program line by line, without a separate manual compilation step.
In many places you will see Python described as a scripting language. Scripting languages are typically executed by an interpreter and are often used to automate tasks, build applications quickly, and glue different systems together.
Other Script-Based Languages and Technologies
Along with Python, several other popular technologies are commonly used in a script-based or interpreted way:
- PHP
- Ruby
- JavaScript (JS)
On top of JavaScript, we also have powerful libraries and frameworks such as:
- jQuery
- Angular
- Node.js
- React
These are not separate languages, but tools built around JavaScript that make it easier to create modern web and server applications.
How Python Evolved
Python was originally designed as a simple and powerful language for scripting and automating tasks, including working with operating systems and system utilities.
Today, Python has grown into a complete technology platform, with a rich ecosystem of libraries and frameworks that support:
- Application software development
- Web development
- Data science and machine learning
- Automation, scripting, and much more
What Can You Build with Python?
1. Desktop Applications
Desktop applications are installed directly on your computer and work even without the internet. Examples include Notepad, MS Office, antivirus software, personal firewalls, and billing systems.
Popular Python options:
- Tkinter — the standard GUI library that comes with Python.
- PyQt — a powerful toolkit for building professional desktop applications.
2. Web Applications
Web applications run on servers and are accessed through a browser using the Internet or an intranet. Examples include platforms similar to YouTube or Twitter.
Popular Python web frameworks:
- Django — a high-level web framework for rapid development.
- Flask — a lightweight, flexible micro-framework.
- Pyramid — a flexible framework for larger, custom web apps.
3. Mobile Applications
Python can also be used to build multi-platform mobile applications with touch-based interfaces.
Popular framework:
- Kivy — used to build mobile and multitouch applications.
4. Data Science and Analytics
Python is one of the most popular languages for data science. It is used for:
- Data analysis
- Data engineering
- Data visualization
- Data processing and operations
Important Python libraries:
- NumPy — numerical computing and arrays
- Pandas — data analysis and data frames
- SciPy — scientific computing
- Matplotlib — data visualization and plotting
5. Machine Learning
Machine learning works closely with data science to build models that learn from data and make predictions. Python provides an easy way to implement machine learning algorithms.
Popular tool:
- scikit-learn — a powerful library for classical machine learning algorithms.
6. IoT (Internet of Things) Applications
IoT applications connect devices like sensors, lights, and home appliances to the internet. Python is often used on small devices (like Raspberry Pi) to build:
- Home automation systems
- Sensor-based monitoring
- Smart gadgets and prototypes
7. Cloud-Based Applications
Cloud means an online platform that provides common access to applications and data from anywhere, on any device. Python is well supported on all major cloud platforms:
- AWS (Amazon Web Services)
- Microsoft Azure
- Google Cloud Platform
You can use Python to build and deploy scalable cloud applications, APIs, and microservices.
8. Game Development
Python can also be used for 2D game development and for learning the basics of game logic and design.
Popular library:
- Pygame — a library used to build simple and educational games in Python.
9. Device Control and Networking
Python can interact with devices like Wi-Fi modules, Bluetooth devices, and various sensors. It is very popular for writing scripts that control or automate hardware.
10. Security, Automation, and Firewalls
Python is widely used in cybersecurity and IT automation for:
- Writing security scripts
- Log analysis and monitoring
- Automating firewall rules and network tasks
Python Practice Assignments
Try these assignments to practice basic Python programming and logic:
-
Difference between two dates (in years)
Write a program to calculate the difference between two dates in years. The dates will be entered (or stored) inddmmyyyyformat, for example:
12052016
13062019
Output should show the year difference (for example:2019 - 2016 = 3). -
Sum of all digits in date of birth
Write a program to calculate the sum of all digits in a date of birth entered inddmmyyyyformat. -
Feet & Inches Conversion
Write a program to:- Convert feet to inches
- Convert inches to feet
-
Convert kilometers to meters
Write a program to convert a value given in kilometers to meters. -
Convert decimal to binary
Write a program to convert a decimal (base-10) number into its binary (base-2) representation. -
Salary calculation program
Write a program to calculate the following salary components:basicta(Travel Allowance)da(Dearness Allowance)comm(Commission)emppf(Employee PF)employerpf(Employer PF)hra(House Rent Allowance)advancesal(Advance Salary)nl(number of leave days taken by employee)tsal(Total Salary)leave(Per-day leave deduction)ctc(Cost to Company)grosssal(Gross Salary after deductions)
Use the following formulas and values:
basic = 5000 ta = basic * (2 / 100) da = basic * (5 / 100) comm = basic * (5 / 100) emppf = basic * (8.33 / 100) employerpf = basic * (3.67 / 100) hra = basic * (10 / 100) advancesal = 500 nl = 3 # number of leave days tsal = basic + ta + da + comm leave = tsal / 30 ctc = basic + ta + da + comm + emppf + hra grosssal = tsal - emppf - (nl - 1) * leave - advancesal print("Package is ", 12 * ctc) print("Gross salary is ", grosssal) print("Leave Deduction days ", nl - 1, " and amount is ", (nl - 1) * leave) print("PF Deduction is ", emppf) print("TA is ", ta, "\nDA is ", da, "\nCommission is ", comm, "\nHRA is ", hra, "\nAdvance Salary is ", advancesal)
These assignments will help you get comfortable with Python syntax, operators, and basic logic building.

68 Comments
number = 123
ReplyDeleterev_num = 0
while (number > 0) :
rev_num = (rev_num*10) + number%10
number = (int)(number/10)
print(rev_num)
This program should be created without loop and if use loop then use indentation
ReplyDeletenum =123
ReplyDeletea = num%10 #3
num= num//10 #12
b= num%10 #2
c=num//10 #1
rev = a*100+b*10+c*1
print(rev)
What is Interpreter and script both are same?
ReplyDeleteProgram of Compund Interest?
ReplyDeletep=1000000
r=7.5
t=20
n=12
R = r/100
ci= p*((1+R/n)**(n*t))
print("Total amount including interest is ",ci,"\n interest ",(ci-p))
# area of traingle
ReplyDeletel=int(input("enter length value=") )
b=int(input("enter breath value="))
area=1/2*l*b
Print("enter length value=" , "enter breath value= , area)
#reverse number using While loop
ReplyDeletenumber=123
rev_num=0
while(number>0):
rev_num=(rev_num*10)+number%10
number=(int)(number/10)
print(rev_num)
#compount interest program
ReplyDeletep=15000
r=7.5
t=3
n=12
R=r/100
ci=p*((1+R/n)**(n*t))
print("Total ammount including interest is ",ci,"/n interest",(ci-p))
# Difference between two date in year
ReplyDelete# created by Shiva
firstdate = int("02061998") #ddmmyyyy
lastdate = int("03072021")
f1 = firstdate%10000
print(f1)
f2 = lastdate%10000
print(f2)
year = f2-f1
print(year)
#Program of Compund Interest
ReplyDeletep=1000000
r=7.5
t=20
n=12
R = r/100
ci= p*((1+R/n)**(n*t))
print("Total amount including interest is ",ci,"\n interest ",(ci-p))
# area of traingle
ReplyDeletel=int(input("enter length value=") )
b=int(input("enter breath value="))
area=1/2*l*b
Print("enter length value=" , "enter breath value= , area)
# Difference between two date in year
ReplyDeletefirstdate = int("02061998") #ddmmyyyy
lastdate = int("03072021")
f1 = firstdate%10000
print(f1)
f2 = lastdate%10000
print(f2)
year = f2-f1
print(year)
#wap find square and cube of number
ReplyDeletea=5
print(a*a)
print(a*a*a)
#swap of two number using third variable in jupyter
ReplyDeletea=10
b=20
print("before swap")
print(a,b)
temp=a
a=b
b=temp
print("after swap")
print(a,b)
#reverse 5 digits number without loop
ReplyDeletemun=int(input("enter any number:-"))
a=mun%10
mun=mun//10
b=mun%10
mun=mun//10
c=mun%10
mun=mun//10
d=mun%10
mun=mun//10
e=mun%10
mun=mun//10
print(a,b,c,d,e)
#WAP to display the middle number is a three-digit number?
ReplyDeletea=int(input("enter the value"))
b=int(input("enter the second value"))
c=a%10
a=a//10
c=a%10
d=b%10
b=b//10
d=b%10
print("the first mid no is",c ,"the second mid no is",d)
#WAP to calculate Square and Cube of any assigned number.
ReplyDeletea=int(input("enter number for square and cube"))
square=(a*a)
print("the assgined square is",square)
cube=(a*a*a)
print("the Assgined cube is",cube)
#Area of Tringle
ReplyDeleteb=10
h=20
Area=(b*h)/
/2
print(Area)
#Adding complex number using complex number
ReplyDeleteA=2+4J
B=4+5J
c=A+B
print(A)
print(B)
print("addition of complex number", c)
print(c)
#convert temperature from Celsius to Fahrenheit?
ReplyDelete'''formula --> fahrenheit = (celsius * 1.8) + 32'''
celsius=float(input(" Temperature in Celsius : "))
fahrenheit=(celsius*1.8)+32
print("{0} degree Celsius is equal to {1} degree Fahrenheit".format (celsius,fahrenheit))
#calculate Simple Interest where rate and time will be constant and
ReplyDeletethe principal will be an integer
CONST = (2.5,4.5)
p=450000
si = (p*CONST[0]*CONST[1])/100
print(si)
ReplyDelete#Program to calculate AREA of Triangle,RECT and CIRCLE?
CONST = (3.14,200,50)
r = 5
height=20
width=300
areaOfCircle = CONST[0]*r*r
areaOfTriangle = (CONST[1]*height)/2
areaOfRectangle = width*CONST[2]
print("Area of Cirlce is",areaOfCircle)
print("Area of Triangle is",areaOfTriangle)
print("Area of Rectangle is ",areaOfRectangle)
#calculate the total salary of an employee where basic, ta, da, comm, pf,hra, leave will be entered by the users
ReplyDeletebasic_salary = int(input("enter ur basic salary: "))
ta = int(input("enter ur ta: "))
da = int(input("enter ur da: "))
comm = int(input("enter ur comm: "))
pf = int(input("enter ur pf amount: "))
num_of_leave = int(input("enter ur num of leave: "))
leave_amount = num_of_leave*((basic_salary+ta+da+comm+pf)/30)
net_salary =basic_salary + ta + da + comm + pf - leave_amount
print("ur net salary=",net_salary)
#WAP to evaluate the middle number in three-digit numbers based on order?
ReplyDeletex = int(input("Enter 3 digit number = "))
a = x % 100
b = a // 10
print("Middle number is = ",b)
#multiplication of a complex number:-
ReplyDeletea=2+5j
b=4+6j
print("a=",a)
print("b=",b)
c=(a*b)
print("multiplication of a complex number:",c)
#WAP to calculate difference of two date in year.
ReplyDeletefstdate=int(input("enter the first date of birth in ddmmyyyy"))
lstdate=int(input("enter last date of birth in ddmmyyyy"))
f1=fstdate%10000
f2=lstdate%10000
year=(f1-f2)
print("%d" % year)
#WAP to calculate sum of all digit in date of birth.
ReplyDeletenum=int(input("enter dob in form of ddmmyyyy"))
a=num%10000
num1=num//10000
b=num1%100
num2=num1//100
c=num2%10
sum=a+b+c
print(sum)
#WAP to Convert feet to inch and inch to feet?
ReplyDelete#inch==feet*12
feet=float(input("enter the value"))
inch=feet*12
print("the value of inch is ",inch)
# WAP to convert km to meter?
ReplyDelete#1km=1000 meters
km=float(input("enter km"))
meter=km*1000
print("the value in meter is ",meter)
#WAP to Convert to inch to feet .
ReplyDelete#feet==inch/12
inch=float(input("enter the value of inch"))
feet=inch/12
print("the convertion inch to feet is ",feet)
#WAP to Convert to inch to feet .
ReplyDelete#feet==inch/12
inch=float(input("enter the value of inch"))
feet=inch/12
print("the convertion inch to feet is ",feet)
#WAP to calculate difference of two date in year.
ReplyDeletefirstdate=12052017
nowdate=28092021
f1= (firsdate%1000)
print (f1)
f2=(nowdate%1000)
print (f2)
year=f2-f1
print(year)
#WAP to convert km to meret .
ReplyDeletekm=int(input("enter km"))
meter=km*1000
print(meter)
#addition of dob of yash
ReplyDeletedob=10091997
a=dob%10 #7
dob=dob//10 #1009199
b=dob%10 #9
dob=dob//10 #100919
c=dob%10 #9
dob=dob//10 #10091
d=dob%10 #1
dob=dob//10 #1009
e=dob%10 #9
dob=dob//10 #100
f=dob%10 #0
dob=dob//10 #10
g=dob%10 #0
dob=dob//10 #1
h=dob%10
dob=dob//10
print(a+b+c+d+e+f+g+h)
#output is 36
#WAP to convert km to meret .
ReplyDeletekm=int(input("enter km"))
meter=km*1000
print(meter)
#WAP to convert km to meret .
ReplyDeletekm=int(input("enter km"))
meter=km*1000
print(meter)
# difference of two date in year
ReplyDeletepritesh=int("01111997")
shlok=int("25111999")
p=pritesh%10000
s=shlok%10000
diff=s-p
print("Difference of two date in year is:",diff)
# sum of DOB
ReplyDeletep=int("12111997")
a=p%10 #7
p=p//10 #1211199
b=p%10 #9
p=p//10 #121119
c=p%10 #9
p=p//10 #12111
d=p%10 #1
p=p//10 #1211
e=p%10 #1
p=p//10 #121
f=p%10 #1
p=p//10 #12
g=p%10 #2
p=p//10 #1
print("Sum of dob is ",a+b+c+d+e+f+g+p)
# conversion into km to meter
ReplyDeletea=float(input("Enter distance in KM:"))
M=1000*a
print(M)
convert decimal to binary
ReplyDeletea=bin(5)
print(a)
#program to calculate difference between two dates in year
ReplyDeletedate1 = int(input("Enter First Date in ddmmyyyy"))
date2 = int(input("Enter Last Date in ddmmyyyy"))
y1=date1 % 10000
y2=date2 % 10000
diff = y2-y1
print("Difference between two date in year is ",diff)
#program to calculate sum of all digit in dob
ReplyDeletedob = int(input("Enter date of birth in ddmmyyyy"))
a = dob%10 # 2
dob = dob//10 # 1001199
b = dob%10 # 9
dob = dob//10 #100119
c = dob%10 #9
dob = dob//10 #10011
d = dob%10 #1
dob = dob//10 #1001
e = dob%10 #1
dob = dob//10 #100
f = dob%10 #0
dob = dob//10 #10
g = dob%10 #0
h = dob//10 #1
s = a+b+c+d+e+f+g+h
print(s)
1.WAP to calculate difference of two date in year, date should be assigned on ddmmyyyy
ReplyDeletefrom datetime import date
firstdate = int("12052016") #ddmmyyyy
lastdate = int("13062019")
f1 = firstdate%10000
print(f1)
f2 = lastdate%10000
print(f2)
year = f2-f1
print(year)
1.WAP to calculate the sum of all digits in date of birth?
ReplyDeletenum = int(input("Enter your birth year: "))
x = num //1000
print(x)
x1 = (num - x*1000)//100
print(x1)
x2 = (num - x*1000 - x1*100)//10
print(x2)
x3 = num - x*1000 - x1*100 - x2*10
print(x3)
x4 = x+x1+x2+x3
print ("sum of all digits in your birth year",x4)
3.WAP to Convert feet to inch and inch to feet?
ReplyDeletefeet = int(input("Enter the length in feet:"))
# convert feet to Inches
Inch = 12 * feet;
print("The length in Inches is", round(Inch, 2))
Inches = int(input("Enter the value of length in Inches:"))
# convert Inches to Feet
Feet = Inches / 12;
print("The length in Feet", round(Feet, 2))
4.WAP to convert km to meter?
ReplyDeletekm=int(input("Enter Kilo Meters:"))
m=km*1000
print(m)
decimal number
ReplyDeletenumber = int(input("Enter any decimal number: "))
# print equivalent binary number
print("Equivalent Binary Number: ", bin(number))
decimal number
number = int(input("Enter any decimal number: "))
# print equivalent binary number
print("Equivalent Binary Number: ", bin(number))
ReplyDelete1.WAP to calculate the sum of all digits in date of birth?
num = int(input("Enter your birth year: "))
x = num //1000
print(x)
x1 = (num - x*1000)//100
print(x1)
x2 = (num - x*1000 - x1*100)//10
print(x2)
x3 = num - x*1000 - x1*100 - x2*10
print(x3)
x4 = x+x1+x2+x3
print ("sum of all digits in your birth year",x4)
************************************************************************************************************
2.WAP to calculate difference of two date in year, date should be assigned on ddmmyyyy
date1 = int(input("Enter First Date in ddmmyyyy"))
date2 = int(input("Enter Last Date in ddmmyyyy"))
y1=date1 % 10000
y2=date2 % 10000
diff = y2-y1
print("Difference between two date in year is ",diff)
or
firstdate = int("02061998") #ddmmyyyy
lastdate = int("03072021")
f1 = firstdate%10000
print(f1)
f2 = lastdate%10000
print(f2)
year = f2-f1
print(year)
****************************************************************************************************************
3.WAP to Convert feet to inch and inch to feet?
feet = int(input("Enter the length in feet:"))
# convert feet to Inches
Inch = 12 * feet;
print("The length in Inches is", round(Inch, 2))
Inches = int(input("Enter the value of length in Inches:"))
# convert Inches to Feet
Feet = Inches / 12;
print("The length in Feet", round(Feet, 2))
***************************************************************************
4.WAP to convert km to meter?
km=int(input("Enter Kilo Meters:"))
m=km*1000
print(m)
*****************************************************************************
5.WAP to convert decimal to binary?
decimal number
number = int(input("Enter any decimal number: "))
# print equivalent binary number
print("Equivalent Binary Number: ", bin(number))
******************************************************************************
WAP to calculate basic, ta, da, comm, pf, HRA, Leave, numberofleave will be entered by the users?
print("SALARY PROGRAM")
name= str(input("Enter name of employee:"))
basic=float(input("Enter Basic Salary :"))
da=float(basic*0.25)
hra=float(basic*0.15)
pf=float((basic+da)*0.12)
ta=float(basic*0.075)
netpay=float(basic+da+hra+ta)
grosspay=float(netpay-pf)
print("\n\n")
print("S A L A R Y D E T A I L E D B R E A K U P ")
print("==============================================")
print(" NAME OF EMPLOYEE : ",name)
print(" BASIC SALARY : ",basic)
print(" DEARNESS ALLOW. : ",da)
print(" HOUSE RENT ALLOW.: ",hra)
print(" TRAVEL ALLOW. : ",ta)
print("==============================================")
print(" NET SALARY PAY : ",netpay)
print(" PROVIDENT FUND : ",pf)
print("==============================================")
print(" GROSS PAYMENT : ",grosspay)
print("==============================================")
************************************************************************************
1.WAP to calculate the sum of all digits in date of birth?
ReplyDeletenum = int(input("Enter your birth year: "))
x = num //1000
print(x)
x1 = (num - x*1000)//100
print(x1)
x2 = (num - x*1000 - x1*100)//10
print(x2)
x3 = num - x*1000 - x1*100 - x2*10
print(x3)
x4 = x+x1+x2+x3
print ("sum of all digits in your birth year",x4)
************************************************************************************************************
2.WAP to calculate difference of two date in year, date should be assigned on ddmmyyyy
date1 = int(input("Enter First Date in ddmmyyyy"))
date2 = int(input("Enter Last Date in ddmmyyyy"))
y1=date1 % 10000
y2=date2 % 10000
diff = y2-y1
print("Difference between two date in year is ",diff)
or
firstdate = int("02061998") #ddmmyyyy
lastdate = int("03072021")
f1 = firstdate%10000
print(f1)
f2 = lastdate%10000
print(f2)
year = f2-f1
print(year)
****************************************************************************************************************
3.WAP to Convert feet to inch and inch to feet?
feet = int(input("Enter the length in feet:"))
# convert feet to Inches
Inch = 12 * feet;
print("The length in Inches is", round(Inch, 2))
Inches = int(input("Enter the value of length in Inches:"))
# convert Inches to Feet
Feet = Inches / 12;
print("The length in Feet", round(Feet, 2))
***************************************************************************
4.WAP to convert km to meter?
km=int(input("Enter Kilo Meters:"))
m=km*1000
print(m)
*****************************************************************************
5.WAP to convert decimal to binary?
decimal number
number = int(input("Enter any decimal number: "))
# print equivalent binary number
print("Equivalent Binary Number: ", bin(number))
******************************************************************************
WAP to calculate basic, ta, da, comm, pf, HRA, Leave, numberofleave will be entered by the users?
print("SALARY PROGRAM")
name= str(input("Enter name of employee:"))
basic=float(input("Enter Basic Salary :"))
da=float(basic*0.25)
hra=float(basic*0.15)
pf=float((basic+da)*0.12)
ta=float(basic*0.075)
netpay=float(basic+da+hra+ta)
grosspay=float(netpay-pf)
print("\n\n")
print("S A L A R Y D E T A I L E D B R E A K U P ")
print("==============================================")
print(" NAME OF EMPLOYEE : ",name)
print(" BASIC SALARY : ",basic)
print(" DEARNESS ALLOW. : ",da)
print(" HOUSE RENT ALLOW.: ",hra)
print(" TRAVEL ALLOW. : ",ta)
print("==============================================")
print(" NET SALARY PAY : ",netpay)
print(" PROVIDENT FUND : ",pf)
print("==============================================")
print(" GROSS PAYMENT : ",grosspay)
print("==============================================")
************************************************************************************
#shalu
ReplyDeletench =int("enter the value of inch")
feet= inch % 12
print("the convertion inch to feet is",feet)
#shalu
ReplyDeletedef getdifference(dt1,dt2):
dt1=[12,5,2016]
dt2=[13,6,2019]
print("difference between two dates is",getdifference(dt1,dt2))
#shalu
ReplyDeletea=123
print(a)
num1=a%10
a=int(a/10)
num2=a%10
num3=a//10
res=num1*100+num2*10+num3*1
print(res)
#second method
b=45678
print(b)
num1=b%10
b=(b//10)
num2=b%10
b=(b//10)
num3=b%10
b=(b//10)
num4=b%10
b=(b//10)
num5=b%10
b=(b//10)
res=num1*10000+num2*1000+num3*100+num4*10+num5*1
print(res)
#shalu
ReplyDelete#sum
num=27091995
a=num%1000
num=num//1000
b=num%100
num=num//100
c=num%10
sum=a+b+c
print(a+b+c)
WAP to calculate the sum of all digits in date of birth?
ReplyDeletenum = int(input("Enter your birth year: "))
x = num //1000
print(x)
x1 = (num - x*1000)//100
print(x1)
x2 = (num - x*1000 - x1*100)//10
print(x2)
x3 = num - x*1000 - x1*100 - x2*10
print(x3)
x4 = x+x1+x2+x3
print ("sum of all digits in your birth year",x4)
************************************************************************************************************
wap to calculate the total salary of an employee where basic ,ta, da,comm,pf,hra,leave,advance salary will be entered by the users?
Deletebasic=5000
ta=basic*(2/100)
da=basic*(5/100)
comm=basic*(5/100)
emppf=basic*(8.33/100)
employerpf=basic*(3.67/100)
hra=basic*(10/100)
advancesal=500
nl=3
tsal=basic+ta+da+comm
leave=tsal/30
ctc=basic+ta+da+comm+emppf+hra
grossal=tsal-emppf-(nl-1)*leave-advancesal
print("package is",12*ctc)
print("gross salary is",grossal)
print("leave deduction days,nl-1" and "amount is",(nl-1)*leave)
print("pf diduction is",emppf)
print("ta is",ta,"/n da is" ,da,"/n comm is",comm,"/n hra is",hra,"/n advance salary is",advancesal)
#Difference of two date in year?
ReplyDeletefirstdate=int(input("enter first dob in ddmmyyyy"))
seconddate=int(input("enter second dob in ddmmyyyy"))
f1=firstdate%10000
print(f1)
f2=seconddate%10000
print(f2)
year=f2-f1
print(year)
#sum of all digits in dob
ReplyDeletenum = int(input("enter dob in from of ddmmyyyy"))
r1=num%10000
num1=num//10000
print(r1 ,num1)
r2=num1%100
num2=num1//100
print(r2,num2)
r3=num2%10
print(r3)
sum = r1+r2+r3
print(sum)
#convert inch to feet
ReplyDeleteinch = float(input("enter a value "))
feet = inch//12
print(feet)
#convert feet to inch?
ReplyDeletefeet=float(input("enter the value"))
inch=feet*12
print(inch)
#Decimal to binary?
ReplyDeletenum=12
s=""
a=num%2#0
s=s+str(a)
num=num//2#6
a=num%2#0
s=s+str(a)
num=num//2#3
a=num%2#1
s=s+str(a)
num=num//2#1
a=num%2#1
s=s+str(a)
print(s)
#reverse a nos
ReplyDeletenum=123
a=num%10
b=num//10
c=b//10
d=b%10
print(a*100+d*10+c*1)
dn=int(input("Enter any no"))
ReplyDeleterem=0
bn=0
place=1
while(dn!=0):
rem=dn%2
bn=bn+(rem*place)
place=place*10
dn=dn//2
print(bn)
ReplyDeleteup=float(input("enter price")) #unit price
cons=float(input("enter consumption")) #consumption
load=float(input("enter extra load unit"))
bill=up*cons
print("Total bill without load=",bill)
bill2=2*up*load
print("extra load bill=",bill2)
bill3=up*cons+2*(up*load)
print("Total bill with extra load=",bill)
This comment has been removed by the author.
ReplyDeletefirstdate = int(input("enter firstdate"))
ReplyDeletelastdate = int(input("enter lastdate"))
a1= firstdate%10000
a2 = lastdate%10000
year=a2-a1
print(year)
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDelete#WAP to calculate the sum of all digits in date of birth?
ReplyDeletedob=12012001
a=dob%10 #1
dob=dob//10 #1201200
b=dob%10 #0
dob=dob//10 #120120
c=dob%10 #0
dob=dob//10 #12012
d=dob%10 #2
dob=dob//10 #1201
e=dob%10 #1
dob=dob//10 #120
f=dob%10 #0
dob=dob//10 #12
g=dob%10 #2
dob=dob//10 #1
h=dob%10
dob=dob//10
print(a+b+c+d+e+f+g+h)
POST Answer of Questions and ASK to Doubt