SlideShare a Scribd company logo
2
Most read
5
Most read
1.) a). Write a program to input Welcome message
a = input("enterthe message")
print(a)
7.) Write a python program to add, multiply,divide twonumbers.
a = int(input(“enterthe firstnumber”))
b = int(input(“enterthe secondnumber”))
sum= a+b
diff = a-b
prod = a*b
quo= a/b
print(“sumof numbersis:“ , sum)
print(“difference of numbers:“,diff)
print(“productof numbers:“,prod)
print(“quotientof numbers:”,quo)
2. Write a program to displaylargest and smallestnumber between2 numbers.
a = int(input(“enterfirstnumber”))
b = int(input(“entersecondnumber”))
if a>b :
print(“the greaternumberis”,a)
else :
print(“the greaternumberis”,b)
3.) Write a program to displaylargest and smallestnumber between3 numbers.
a=float(input(“enterfirstnumber”))
b=float(input(“entersecondnumber“))
c=float(input(“enterthirdnumber”))
if a >b and a >c :
print(“the greatestnumberis“,a)
elif b>0 andb>c :
print(“the greatestnumberis“,b)
else:
print(“the greatestnumberis“,c)
10. a).Write a program to generate this pattern usingnestedloops
n=int(input(“entervalueof n”))
sum=0
for I inrange (1,n) :
if (n%i==0) :
sum = sum + i
If sum ==n:
Print(“the number”,n,”isaperfectnumber”)
Else :
Print(“the number”,n”,isnotperfectnumber”)
6.) Perfectnumber program
n=int(input(“entervalueof n”))
sum=0
for i in range (1,n) :
if (n%i==0) :
sum = sum + i
if sum==n :
print("the number",n,"isaperfectnumber")
else :
print("the number",n,"isnotperfectnumber")
Palindrome or not
num=int(input(“entervalue of n:”))
wnum= num
rev= 0
while (wnum>0):
dig = wnum% 10
rev = rev*10 + dig
wnum= wnum//10
if num == rev:
print("numberispallindrome")
else:
print("numberisnotpallindrome")
Armstrong number
num=int(input(“enterthe number:”))
sum=0
temp=num
while (temp>0):
digit= temp%10
sum += digit** 3
temp= temp// 10
if num == sum:
print(num,"isanarmstrongnumber")
else:
print(num,"isnotanarmstrongnumber")
Pattern
wrong Check for Indentspace for print statement
for i in range(1,6):
for j inrange(1,i+1):
print("*",end="")
print()
*
*
*
*
*
for i in range(1,6):
for j inrange(1,i+1):
print("*",end="")
print("n")
*
* *
* * *
* * * *
* * * * *
for i in range(6,0,-1):
for j inrange(1,i+1):
print(j,end="")
print()
123456
12345
1234
123
12
1
for i in range(1,6):
for j inrange(65,65+i):
print(chr(j),end="")
print()
A
AB
ABC
ABCD
ABCDE
python programs .docx

More Related Content

PDF
xii cs practicals class 12 computer science.pdf
PDF
xii cs practicals
PDF
Xi CBSE Computer Science lab programs
PDF
Sample Program file class 11.pdf
PDF
Python programs
PDF
python practicals-solution-2019-20-class-xii.pdf
PDF
Sasin nisar
DOCX
PYTHON PROGRAMS
xii cs practicals class 12 computer science.pdf
xii cs practicals
Xi CBSE Computer Science lab programs
Sample Program file class 11.pdf
Python programs
python practicals-solution-2019-20-class-xii.pdf
Sasin nisar
PYTHON PROGRAMS

Similar to python programs .docx (20)

PPTX
Practice_Exercises_Control_Flow.pptx
PPTX
Chapter 9 Conditional and Iterative Statements.pptx
DOCX
Python lab manual all the experiments are available
PPTX
PRACTICAL FILE(COMP SC).pptx
DOCX
Important C program of Balagurusamy Book
PDF
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
PPTX
PYTHON PROGRAMMING INTERVIEW QUESTIONS.pptx
PDF
15CS664- Python Application Programming- Question bank 1
DOCX
Python Laboratory Programming Manual.docx
PPTX
Chapter 9 Conditional and Iterative Statements.pptx
PDF
python_lab_manual_final (1).pdf
PDF
cos 102 - getting into programming with python.pdf
PDF
III MCS python lab (1).pdf
PDF
Raspberry Pi - Lecture 5 Python for Raspberry Pi
DOC
Programada chapter 4
PDF
Python programming Workshop SITTTR - Kalamassery
PDF
Introduction to phyton , important topic
PDF
PYTHON_PROGRAM(1-34).pdf
PPTX
ANSHUL RANA - PROGRAM FILE.pptx
PPTX
assisgnment 2 python.pptx important questions
Practice_Exercises_Control_Flow.pptx
Chapter 9 Conditional and Iterative Statements.pptx
Python lab manual all the experiments are available
PRACTICAL FILE(COMP SC).pptx
Important C program of Balagurusamy Book
solution-of-practicals-class-xii-comp.-sci.-083-2021-22 (1).pdf
PYTHON PROGRAMMING INTERVIEW QUESTIONS.pptx
15CS664- Python Application Programming- Question bank 1
Python Laboratory Programming Manual.docx
Chapter 9 Conditional and Iterative Statements.pptx
python_lab_manual_final (1).pdf
cos 102 - getting into programming with python.pdf
III MCS python lab (1).pdf
Raspberry Pi - Lecture 5 Python for Raspberry Pi
Programada chapter 4
Python programming Workshop SITTTR - Kalamassery
Introduction to phyton , important topic
PYTHON_PROGRAM(1-34).pdf
ANSHUL RANA - PROGRAM FILE.pptx
assisgnment 2 python.pptx important questions
Ad

More from AnonymousRuslwNZZl (8)

DOC
Visual c++ lab plan MC1755-VC++-L-LP.doc
DOC
Visual C++ questions MC1755-VC++ - L-VVQ.doc
DOC
Visual C++ lab manual MC1755-VC++ - L-LM.doc
DOC
Database management MC9218-DBMS-L-QB.doc
DOC
Database Management S MC9218-DBMS-L-LM.doc
DOC
Design and analysis of algorithm MC9229-DAA-L-LM.doc
PPTX
MS Excel and it’s basic functions.pptx
PPTX
GIMP Tutorial.pptx
Visual c++ lab plan MC1755-VC++-L-LP.doc
Visual C++ questions MC1755-VC++ - L-VVQ.doc
Visual C++ lab manual MC1755-VC++ - L-LM.doc
Database management MC9218-DBMS-L-QB.doc
Database Management S MC9218-DBMS-L-LM.doc
Design and analysis of algorithm MC9229-DAA-L-LM.doc
MS Excel and it’s basic functions.pptx
GIMP Tutorial.pptx
Ad

Recently uploaded (20)

PDF
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
PDF
Empowerment Technology for Senior High School Guide
PPTX
Computer Architecture Input Output Memory.pptx
PDF
advance database management system book.pdf
PPTX
20th Century Theater, Methods, History.pptx
PDF
FORM 1 BIOLOGY MIND MAPS and their schemes
PDF
HVAC Specification 2024 according to central public works department
PPTX
Share_Module_2_Power_conflict_and_negotiation.pptx
PPTX
TNA_Presentation-1-Final(SAVE)) (1).pptx
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
PPTX
Introduction to Building Materials
PDF
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
My India Quiz Book_20210205121199924.pdf
PDF
Hazard Identification & Risk Assessment .pdf
PPTX
Unit 4 Computer Architecture Multicore Processor.pptx
PDF
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
PDF
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)
1.3 FINAL REVISED K-10 PE and Health CG 2023 Grades 4-10 (1).pdf
Empowerment Technology for Senior High School Guide
Computer Architecture Input Output Memory.pptx
advance database management system book.pdf
20th Century Theater, Methods, History.pptx
FORM 1 BIOLOGY MIND MAPS and their schemes
HVAC Specification 2024 according to central public works department
Share_Module_2_Power_conflict_and_negotiation.pptx
TNA_Presentation-1-Final(SAVE)) (1).pptx
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
Chinmaya Tiranga quiz Grand Finale.pdf
Vision Prelims GS PYQ Analysis 2011-2022 www.upscpdf.com.pdf
Introduction to Building Materials
David L Page_DCI Research Study Journey_how Methodology can inform one's prac...
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
My India Quiz Book_20210205121199924.pdf
Hazard Identification & Risk Assessment .pdf
Unit 4 Computer Architecture Multicore Processor.pptx
MBA _Common_ 2nd year Syllabus _2021-22_.pdf
BP 704 T. NOVEL DRUG DELIVERY SYSTEMS (UNIT 1)

python programs .docx

  • 1. 1.) a). Write a program to input Welcome message a = input("enterthe message") print(a) 7.) Write a python program to add, multiply,divide twonumbers. a = int(input(“enterthe firstnumber”)) b = int(input(“enterthe secondnumber”)) sum= a+b diff = a-b prod = a*b quo= a/b print(“sumof numbersis:“ , sum) print(“difference of numbers:“,diff) print(“productof numbers:“,prod) print(“quotientof numbers:”,quo) 2. Write a program to displaylargest and smallestnumber between2 numbers. a = int(input(“enterfirstnumber”)) b = int(input(“entersecondnumber”)) if a>b : print(“the greaternumberis”,a) else : print(“the greaternumberis”,b) 3.) Write a program to displaylargest and smallestnumber between3 numbers. a=float(input(“enterfirstnumber”)) b=float(input(“entersecondnumber“)) c=float(input(“enterthirdnumber”)) if a >b and a >c : print(“the greatestnumberis“,a)
  • 2. elif b>0 andb>c : print(“the greatestnumberis“,b) else: print(“the greatestnumberis“,c) 10. a).Write a program to generate this pattern usingnestedloops n=int(input(“entervalueof n”)) sum=0 for I inrange (1,n) : if (n%i==0) : sum = sum + i If sum ==n: Print(“the number”,n,”isaperfectnumber”) Else : Print(“the number”,n”,isnotperfectnumber”) 6.) Perfectnumber program n=int(input(“entervalueof n”)) sum=0 for i in range (1,n) : if (n%i==0) : sum = sum + i if sum==n : print("the number",n,"isaperfectnumber") else : print("the number",n,"isnotperfectnumber")
  • 3. Palindrome or not num=int(input(“entervalue of n:”)) wnum= num rev= 0 while (wnum>0): dig = wnum% 10 rev = rev*10 + dig wnum= wnum//10 if num == rev: print("numberispallindrome") else: print("numberisnotpallindrome") Armstrong number num=int(input(“enterthe number:”)) sum=0 temp=num while (temp>0): digit= temp%10 sum += digit** 3 temp= temp// 10 if num == sum: print(num,"isanarmstrongnumber") else: print(num,"isnotanarmstrongnumber") Pattern
  • 4. wrong Check for Indentspace for print statement for i in range(1,6): for j inrange(1,i+1): print("*",end="") print() * * * * * for i in range(1,6): for j inrange(1,i+1): print("*",end="") print("n") * * * * * * * * * * * * * * * for i in range(6,0,-1): for j inrange(1,i+1):
  • 5. print(j,end="") print() 123456 12345 1234 123 12 1 for i in range(1,6): for j inrange(65,65+i): print(chr(j),end="") print() A AB ABC ABCD ABCDE