Ad Code

✨🎆 JOIN MERN, JAVA, PYTHON, AI, DEVOPS, SALESFORCE Courses 🎆✨

Get 100% Placement Oriented Program CLICK to new more info click

Loop Tutorials in Python,For,While,For--else,While--else example in Python

Python Loop Tutorials

Introduction to Loops in Python

Loops are used to print range-based data using a common repeatable block. They are also called iterative statements because they help enumerate data from a List, Tuple, Dictionary, Set, and even Database objects.

Example: If we want to print numbers from 1 to 1000, we use loop statements.


1) While Loop Example in Python

2) For Loop Example in Python

3) Nested For Loop Example in Python


Flow of Loop

  • Forward: i = min → i ≤ max → i = i + 1 (range(min, max))
  • Backward: i = max → i ≥ min → i = i - 1 (range(max, min, -1))
  • Infinite: i = min/max, no condition, increment/decrement manually

Types of Loops

1) While Loop / While–Else Loop

Used for condition-based looping, including infinite loops.

Syntax:

init
while(condition):
    statement
    increment

Programs on While Loop

Q) Print 1 to 10

i = 1
while i <= 10:
    print(i)
    i = i + 1

Q) Print 10 to 1

i = 10
while i >= 1:
    print(i)
    i = i - 1

Q) Print Table of Any Number

num = int(input("Enter number"))
i = 1
while i <= 10:
    print(num, "*", i, "=", num*i)
    i = i + 1

Q) Print 1 to 5 and 5 to 1 in a single loop

i = 1
while i <= 10:
    if i <= 5:
        print(i)
    else:
        print(11 - i)
    i = i + 1

Infinite While Loop Example

flag = True
s = "Your long string here"
c = 0

while flag:
    print(s[c])
    c += 1
    if c == len(s):
        flag = False

Using break statement

while True:
    print(s[c])
    c += 1
    if c == len(s):
        break

Assignments on While Loop

1) Square & Cube of One Digit Number

start = int(input("Enter start"))
end = int(input("Enter end"))

i = start
while i < end:
    print(i, i*i, i*i*i)
    i += 1

2) Reverse a Number

num = 54326
s = ""

while num != 0:
    a = num % 10
    num = num // 10
    s = s + str(a)

print(s)

Prime Number Examples (Multiple Solutions)

Solution 1

num = int(input("Enter number"))
count = 0

i = 1
while i <= num:
    if num % i == 0:
        count += 1
    i += 1

if count == 2:
    print("Prime")
else:
    print("Not Prime")

Solution 2 (Efficient)

num = int(input("Enter number"))
i = 2
flag = 0

while i < num:
    if num % i == 0:
        flag = 1
        break
    i += 1

print("Prime" if flag == 0 else "Not Prime")

For Loop in Python

range() is used to define start and end of loop.

for i in range(min, max):
    statements

for i in range(max, min, -1):
    statements

Fibonacci Series

a = -1
b = 1

for i in range(1, 11):
    c = a + b
    print(c)
    a = b
    b = c

Factorial with Full Expression

num = int(input("Enter number"))
f = 1
s = ""

for i in range(num, 1, -1):
    f *= i
    s += str(i) + "*"

print("Factorial is", s + "1 =", f)

Nested For Loop Patterns

✔ Number patterns ✔ Alphabet patterns ✔ Pyramid patterns ✔ Alternating patterns All pattern programs from your raw content are preserved and formatted cleanly:
for i in range(5, 0, -1):
    for j in range(1, i+1):
        print(j, end=' ')
    print()
(Repeat for entire section — all programs included from your content.)

ATM Mini Project (While Loop)

flag = False
bal = 5000

for i in range(1, 4):
    pin = input("Enter PIN: ")
    if pin == "1234":
        flag = True
        break
else:
    print("Attempts over")

while flag:
    op = input("C=Credit, D=Debit, B=Balance, E=Exit: ")

    if op in ['C','c']:
        amount = int(input("Enter amount: "))
        bal += amount
        print("Balance:", bal)

    elif op in ['D','d']:
        amount = int(input("Enter amount: "))
        if bal >= amount:
            bal -= amount
            print("Balance:", bal)
        else:
            print("Insufficient balance")

    else:
        break

Infinite Loop → Text to Speech Example

pip install pyttsx3

import pyttsx3, time
engine = pyttsx3.init()

i = 1
while i <= 10:
    if i <= 5:
        engine.say("You are at floor {0}".format(i))
    else:
        engine.say("You are at floor {0}".format(11-i))
    time.sleep(1)
    engine.runAndWait()
    i += 1

Conclusion

This complete tutorial covers all Python loop types—While, For, Nested Loops, Infinite loops, prime number logic, factorial, reverse digits, patterns, and a mini ATM project. Perfect for beginners and teaching purposes.

Nested For Loop in Python

Using a nested for loop, we execute one loop inside another. Outer loop controls the rows, and the inner loop controls the columns.

for i in range(start, end):      # Outer loop → rows
    for j in range(start, end):  # Inner loop → columns
        Statement
    print()  # New line

Pattern 1:

1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5
1 2 3 4 5

Pattern 2:

1 2 3 4 5
1 2 3 4
1 2 3
1 2
1

Solution:

for i in range(5, 0, -1):
    for j in range(1, i+1):
        print(j, end=' ')
    print()

Pattern 3 — (i,j table)

I   J
1   5
2   4
3   3
4   2
5   1
for i in range(1, 6):
    for j in range(1, 7-i):
        print(j, end=' ')
    print()

Pattern 4 — Alphabet Triangle

A B C D E
A B C D
A B C
A B
A
for i in range(1,6):
    for j in range(1,7-i):
        print(chr(64+j), end=' ')
    print()

Pattern 5 — Alphabet Increment Pyramid

A
A B
A B C
A B C D
A B C D E
for i in range(1, 6):
    for j in range(1, i+1):
        print(chr(64 + j), end=' ')
    print()

Assignment Pattern

1
1 2
1 2 3
1 2 3 4
1 2 3 4 5

Uppercase + lowercase alternating pattern

A B C D E
a b c d
A B C
a b
A

Solution:

for i in range(70, 65, -1):
    for j in range(65, i):
        if i % 2 == 0:
            print(chr(j), end=' ')
        else:
            print(chr(j + 32), end=' ')
    print()

Pattern — Uppercase/Lowercase Alternating

A a B b C
A a B b
A a B
A a
A

Solution:

for i in range(70, 65, -1):
    k = 65
    for j in range(65, i):
        if j % 2 == 0:
            print(chr(k + 32), end=' ')
            k = k + 1
        else:
            print(chr(k), end=' ')
            k = k + 1
    print()

Pattern — Alternating Forward & Backward

1 2 3 4 5
5 4 3 2
1 2 3
5 4
1

Solution:

for i in range(1, 6):
    for j in range(1, 7-i):
        if i % 2 == 0:
            print(6 - j, end=' ')
        else:
            print(j, end=' ')
    print()

Binary Alternating Pattern

1 0 0 1 0
1 0 0 1
1 0 0
1 0
1

Solution:

for i in range(1, 6):
    a = 1
    b = 0
    for j in range(1, 7-i):
        if j % 2 == 0:
            print(b, end=' ')
            b = 1
        else:
            print(a, end=' ')
            a = 0
    print()

Alphabet Shift Pattern

A B C D E
  B C D E
    C D E
      D E
        E

Solution:

for i in range(0, 5):
    ch = 65
    for k in range(0, i):
        print(' ', end=' ')
        ch = ch + 1
    for j in range(i, 5):
        print(chr(ch), end=' ')
        ch = ch + 1
    print()

Diamond Style Star Pattern

    *
  * * *
* * * * *
  * * *
    *

Solution:

start = 3
l = 2

for i in range(1, 6):
    if i <= 3:
        for k in range(start, i, -1):
            print(" ", end='')
        for j in range(0, 2*i-1):
            print("*", end='')
    else:
        for k in range(start, i):
            print(" ", end='')
        for j in range(0, 2*l-1):
            print("*", end='')
        l = l - 1
    print()

إرسال تعليق

385 تعليقات

  1. #print 10 to 1
    print(" Decrease value 10 -1 ")
    i=10
    while (i>=1):
    print(i)
    i=i-1
    print("\n*************")
    print ( "Increase value 1-10 ")
    #print 1 to 10
    i=1
    while (i<=10):
    print(i)
    i=i+1

    ردحذف
  2. #print 5 to 1 and 1 to 5 programm
    print(" Decrease value 10 -1 ")
    i=5
    while (i>=1):
    print(i)
    i=i-1
    print("\n*************")
    print ( "Increase value 1-10 ")
    #print 1 to 5
    i=1
    while (i<=5):
    print(i)
    i=i+1

    ردحذف
  3. #perform the addition of a digit positive number? 1 to 10 = 55
    i=1
    sum=0
    while (i<=10):
    sum = sum + i
    print(i)
    i=i+1
    print("------------------------")
    print ("The Sum is " ,sum)

    ردحذف
  4. for i in range(5,0,-1):
    for j in range(1,i+1):
    print(i,end=' ')
    print()

    ######
    Output :
    5 5 5 5 5
    4 4 4 4
    3 3 3
    2 2
    1

    ردحذف
  5. Write a program to calculate factorial number

    n = int(input("Enter the number:"))
    result = 1

    for i in range(n,0,-1):
    result = result*i
    print("factorial of",n,"is",result)

    ردحذف
  6. ATM Program Solution

    flag=False
    p=1721
    bal=500
    for i in range(1,4):
    pin = int(input("enter pin code"))
    if pin==p:
    flag=True
    break
    while(flag):



    if flag:
    ch = input(" Press C for credit \n Press D for bedit \n Press b for check balance \n press e for exit")
    if ch=='c':
    amt = int(input("enter amount"))
    bal+=amt
    elif ch=='d':
    amt = int(input("enter amount"))
    bal-=amt
    elif ch=='b':
    print("Your current balance is ",bal)
    else:
    break


    else:
    print("Incorrect pin code and your all attempt has completed")






    ردحذف
  7. wap to print 1to10 using while lopp
    i=1
    while(i<=10)
    ptint(i)
    i=1+1

    ردحذف
  8. wap to 10 to 1 using while loop
    i=10
    while(i>=1):
    print(i)
    i=1-1

    ردحذف
  9. #wap to calculate table using while loop
    a=int(input("enter number"))
    i=1
    while(i<=10)
    b=a*1
    print(b)
    i=i+1

    ردحذف
  10. wap to print 1to5 and 5to1 in single loop
    i=1
    while(i<=10):
    if(i<=5):
    print(i)
    else:
    print(11-i)
    i=i+1

    ردحذف
  11. wap to print (111 2 4 8 3 9 27)
    num=1
    i=1
    while(i<=9)
    if(num<=9)
    print(str(num)+""+str(num*i)+""+str(num*i*i))
    num=num+1
    i=i+1

    ردحذف
  12. #square and cube of one digit positive number
    num=1
    i=1
    while(i<=9):
    if(num<=9):
    print(str(num*num))
    num=num+1
    i=i+1
    #calculate cube
    #wap to calculate square and cube of a number
    num=1
    i=1
    while(i<=9):
    if(num<=9):
    print(str(num*num*num))
    num=num+1
    i=i+1

    ردحذف
  13. #check prime number
    num=int(input("check prime number"))
    c=0
    i=1
    while(i<=num):
    if num%i==0:
    c=c+1
    i=i+1

    if c==2:
    print("prime no")
    else:
    print("not prime")

    ردحذف
  14. Program for table of a number>>>>

    num=int(input("enter number to caculate table"))
    i=1
    while(i<=10):
    print(str(num) + "*"+ str(i) + "=" + str(num*i))
    i=i+1
    Ex--->>
    101*1=10
    101*2=202
    '
    '
    '
    '
    '
    101*9=909
    101*10=1010

    ردحذف
  15. #wap reverse a number using whileelse
    num=int(input("enter number that you want to reverse"))
    s=""
    while(num!=0):
    s=s+str(num%10)
    num=num//10
    else:

    print(s)

    ردحذف
    الردود
    1. deependra singh jadaun8 نوفمبر 2020 في 6:45 م

      program run nahi ho rha h

      حذف
  16. Program to check whether number is prime or not--->>>

    num = int(input("enter number"))
    total=0
    i=1
    while i<=num:
    if num%i==0:
    total=total+1
    i=i+1

    if total==2: #Prime number is which is divisible by 1 and itself both,so this
    condition is used
    print("It is a prime number")
    else:
    print("It is not a prime number")

    ردحذف
  17. Program to print 1 to 4 and 4 to 1 using a single while loop--->>

    i=1
    while(i<=8):
    if i<=4:
    print(i)
    else:
    print(9-i)
    i=i+1

    ردحذف
  18. #wap to print 12345
    #12345
    #12345
    #12345
    #12345
    for i in range(1, 6):
    temp = ''
    for j in range(1, 5):
    temp += str(j)
    print(temp)

    ردحذف
  19. 1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1
    for i in range(5,0,-1):
    for j in range(1,i+1):
    print(j,end='')
    print()

    ردحذف
  20. A B C D E
    A B C D
    A B C
    A B
    A
    for i in range(70,65,-1):
    for j in range(65,i):
    j=chr(j)
    print(j,end=' ')
    print()

    ردحذف
  21. #wap to print
    """A
    A B
    A B C
    A B C D
    A B C D E"""
    for i in range(1,6):
    for j in range(65,65+i):
    print(chr(j), end= '')
    print()

    ردحذف
  22. Assignment of Nested For Loop In Python:

    1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5


    for i in range(1,6):
    for j in range(1, i+1):
    print(j, end="")
    print()

    ردحذف
  23. """A B C D E
    a b c d
    A B C
    a b
    A"""
    for i in range(70,65,-1):
    for j in range(65,i):
    if i%2==0:
    print(chr(j),end="")
    else:
    print(chr(j+32),end="")
    print()

    ردحذف
  24. Program to calculate Square and cube of a number---->>


    strt=int(input("enter starting point"))
    end=int(input("enter ending point"))
    i=strt
    while(i<end):
    s=i*i
    e=i*i*i
    print(s,e.i)
    i=i+1

    Ex.---enter starting point4
    enter ending point9
    4 16 64
    5 25 125
    6 36 216
    7 49 343
    8 64 512

    ردحذف
  25. Program to print 12345678910--->>

    for i in range(1, 3):
    tp = ""
    for j in range(1, 11):
    tp += str(j)
    print(tp)

    ردحذف
  26. Program to print sum of numbers---->>>

    sum=0
    i=1
    p=""
    while i<15:
    sum=sum+i
    if i<14:
    p= p+str(i)+ "+"
    else:
    p= p+str(i)+ "="
    i=i+1
    print(p,sum)

    ردحذف
  27. Program to print reverse of a number---->>

    num=int(input("enter number"))
    s=""
    while(num!=0):
    s=s+str(num%10)
    num=num//10
    else:
    print("reverse is",s)

    ردحذف
  28. Program to print reverse of a number using while loop---->>

    num=int(input("enter number"))
    s=""
    while(num!=0):
    s=s+str(num%10)
    num=num//10
    print("rev is",s)

    ردحذف
  29. Program to calculate factorial of a number----->>

    num=int(input("Enter the number"))
    r=1

    for i in range(num,0,-1):
    r=r*i
    print("factorial of entered number is",r)

    ردحذف
  30. Program for factorial-->


    num = int(input("enter the number"))
    f=1
    i=num

    while i>1:
    f=f*i

    i=i-1

    print("factorial is ",f)

    ردحذف
  31. """1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5"""
    for i in range(1,6):
    for j in range(1,6):
    print(j,end='')
    print()

    ردحذف
  32. """A B C D E
    A B C D
    A B C
    A B
    A"""
    for i in range(70,65,-1):
    for j in range(65,i):
    print(chr(j),end="")
    print()

    ردحذف
  33. """A
    A B
    A B C
    A B C D
    A B C D E"""
    for i in range(65,70):
    for j in range(65,i+1):
    print(chr(j),end='')
    print()

    ردحذف
  34. """1
    1 2
    1 2 3
    1 2 3 4
    1 2 3 4 5"""
    for i in range(1,6):
    for j in range(1,i+1):
    print(j,end='')
    print()

    ردحذف
  35. """A B C D E
    a b c d
    A B C
    a b
    A
    """
    for i in range(70,65,-1):
    for j in range(65,i):
    if i%2==0:
    print(chr(j),end='')
    else:
    print(chr(j+32),end='')
    print()

    ردحذف
  36. Q :- wap to print 1 to 10 using while loop ?
    Solution:-
    i=1
    while(i<=10):
    print(i)
    i=i+1

    ردحذف
  37. Q:- wap to 10 to 1 using while loop ?
    Solution :-
    i=10
    while(i>=1):
    print(i)
    i=i-1

    ردحذف
  38. Q :- WAP to print a table of any entered number ?
    Solution :-
    n=int(input(" Enter number to Caculate table :- "))
    i=1
    while(i<=10):
    print(str(n) + " * "+ str(i) + " = " + str(n*i))
    i=i+1

    ردحذف
  39. Q:- wap to print 1 to 5 and 5 to 1 using a single while loop ?
    Solution:-
    i=1
    while(i<=10):
    if i<=5:
    print(i)
    else:
    print(11-i)
    i=i+1

    ردحذف
  40. wap to Calculate Square and Cube of one digit positive number ?
    Solution:-
    start = int(input("Enter starting point :- "))
    end = int(input("Enter ending point :- "))

    i=start
    while(i<end):
    s=i*i
    c=i*i*i
    print(i, " = Square is :- " ,s, " Cube is :- ",c)
    i=i+1

    ردحذف
  41. Q:- wap to calculate factorial of a number with complete expression ?
    Solution :-

    n = int(input("Enter number to calculate factorial :- "))
    i=n
    fact=1
    while i>=1:
    fact = fact*i
    i= i-1

    print("Factorial of " , n , " is ",fact)

    ردحذف
  42. Q:- wap to reverse number ?
    Solution:-
    n = int(input("Enter Number :- "))
    s=''
    while n!=0:
    s=s+str(n%10)
    n=n//10
    else:
    print(s)

    ردحذف
  43. Q:- wap to check prime number using While - else statement in Python ?
    Solution:-
    n=int(input("Enter number to check prime or not prime :- "))
    i=2
    while i<n:
    if n%i==0:
    print("This is not Prime Number.")
    break
    i=i+1
    else:
    print("This is Prime Number.")

    ردحذف
  44. Q:- wap to print 1 to 10 ?
    Solution:-

    for i in range(1,11):
    print(i)

    ردحذف
  45. Q:- wap to print 10 to 1 ?
    Solution:-
    for i in range(10,0,-1):
    print(i)

    ردحذف
  46. Q:- wap to print a table of odd numbers ?
    Solution:-
    n=int(input("Enter a Number :- "))
    if n%2!=0:
    for i in range(1,11):
    a=n*i
    print(a)
    else:
    print("Enter only Odd Number.")

    ردحذف
  47. Q:- wap to print a table of even numbers ?
    Solution:-
    n=int(input("Enter a Number :- "))
    if n%2==0:
    for i in range(1,11):
    a=n*i
    print(a)
    else:
    print("Enter only Even Number.")

    ردحذف
  48. deependra singh jadaun6 نوفمبر 2020 في 9:22 ص

    program to calculate square and cube of one digit positive no.
    i=1
    while i<10:
    print(i , i**2 , i**3)
    i=i+1

    ردحذف
  49. deependra singh jadaun6 نوفمبر 2020 في 9:36 ص

    WAP to print 1 to 5 and 5 to 1 again 1 to 5 and 5 to 1 using a single while loop?
    i=1
    while i<=20:
    if i<=5:
    print(i)
    else:
    if i<=10:
    print(str(11-i))
    else:
    if i<=15:
    print(i-10)
    else:
    print(21-i)
    i=i+1

    ردحذف
  50. deependra singh jadaun13 نوفمبر 2020 في 3:01 م

    wap to calculate table of odd no.
    i=int(input("enter any no."))

    for n in range (1,11):
    if i%2==0:
    print("enter only odd no.")
    else:
    if i%2 !=0:

    print(str(i)+ "*" +str(n)+"="+str(n*i))

    ردحذف




  51. # PYTHON (6 To 7 PM BATCH)
    #Program to print 1 to 5 and 5 to 1 again 1 to 5 and 5 to 1 using while loop

    i=1
    w=0
    while(w<=20):
    if i<=5:
    print(i)
    elif i==6 or i<=10:
    print(11-i)

    elif i==11:
    i = 0

    i=i+1
    w=w+1

    ردحذف
  52. #PYTHON(6 To 7 BATCH)
    #CODE to perform the addition of a one-digit positive number
    i= 0
    a= 1
    s=0
    while(i<=10):
    if i<=9:
    print(a,"+",i,"=",a+i)
    else:
    print("\nTotal","=",s)
    s=s+a+i
    i=i+1

    ردحذف
  53. # PYTHON( 6 To 7 BATCH)
    # Program to factorial of a number with complete expression
    num = int(input("Enter the number for factorial:\t"))
    i=num
    f=1
    while i>=1:
    f = f*i
    print(i,end = 'X')
    i= i-1
    if i==1:
    print(i,"=",end ='')
    print("\t",f)
    break

    ردحذف
  54. #PYTHON(6 to 7 PM BATCH)
    #CODE to reverse any Number or Alphabet

    num = input("Enter Number or Alphabet:\t")
    print(num[::-1])

    ردحذف
  55. #WAP to calculate square and cube of one digit positive number?

    a = int(input("Enter number = "))
    i =1
    while ( i<=a):
    print(str(i) +" "+ str(i * i) +" "+ str(i * i * i))
    i = i+1

    ردحذف
  56. ABHISHEK GOYAL
    #WAP to print a table of any entered number?

    num=int(input("enter number to caculate table"))
    i=1
    while(i<=10):
    num=num*i
    i=i+1
    print(num)

    ردحذف
  57. ABHISHEK GOYAL
    #WAP to calculate square and cube of one digit positive number?

    a = int(input("enter starting point"))
    b = int(input("enter ending point"))

    i=a
    while(i<b):
    s=i*i
    c=i*i*i
    print(i,s,c)
    i=i+1

    ردحذف
  58. ABHISHEK GOYAL
    #WAP to perform the addition of a one-digit positive number?

    sum=0
    i=1
    s= ''
    while i<10:
    sum=sum+i
    if i<9:
    s = s + str(i) + "+"
    else:
    s = s + str(i) + "="
    i=i+1

    print(s,sum)

    ردحذف
  59. ABHISHEK GOYAL
    #WAP to calculate factorial of a number with complete expression?

    num = int(input("Enter number to calculate factorial"))
    i=num
    f=1
    while i>=1:
    f = f*i
    i= i-1

    print("factorial is ",f)

    ردحذف
  60. ABHISHEK GOYAL
    #WAP to check prime number?

    num = int(input("enter number to check prime"))
    i=2
    count=0
    while i<num:
    if num%i==0:
    count=1
    break
    i=i+1

    if count==0:
    print("prime")
    else:
    print("not prime")

    ردحذف
  61. ABHISHEK GOYAL
    #WAP to reverse number?


    num = int(input("enter number"))
    s=''
    while num!=0:
    s=s+str(num%10)
    num=num//10
    else:
    print(s)

    ردحذف
  62. 1 to 9 = 55
    sum=0
    i=1
    s= ''
    while i<10:
    sum=sum+i
    if i<9:
    s = s + str(i) + "+"
    else:
    s = s + str(i) + "="
    i=i+1

    print(s,sum)

    ردحذف
  63. num=int(input("enter number to caculate table"))
    i=1
    while(i<=10):
    print(str(num) + "*"+ str(i) + "=" + str(num*i))
    i=i+1

    ردحذف
  64. i=1
    while(i<=10):
    if i<=5:
    print(i)
    else:
    print(11-i)
    i=i+1

    ردحذف
  65. start = int(input('enter starting point'))
    end = int(input('enter ending point'))

    i=start
    while(i<end):
    s=i*i
    c=i*i*i
    print(i,s,c)
    i=i+1

    ردحذف
  66. cout = 0
    while count < 4:
    print('welcome to python')
    count += 1

    ردحذف
  67. # PYTHON(6 to 7 PM BATCH)

    print("i","\t","j")
    for i in range(1,6):

    for j in range(2,1,-1):
    j=6-i
    print(i,end='')
    print("\t",j)

    # OUTPUT
    i j
    1 5
    2 4
    3 3
    4 2
    5 1

    ردحذف
  68. # PYTHON(6 to 7 PM BATCH)
    # Using Nested For Loop

    for i in range(6,1,-1):
    print("\n")
    for j in range(1,8-i):
    print(j,end='')

    #OUTPUT
    1

    12

    123

    1234

    12345

    ردحذف
  69. #WAP to check prime number?
    num = int(input("Enter number to check prime number = "))
    i =1
    count = 0

    while i<=num:
    if num % i==0:
    count = count + 1
    i =i+1

    if count == 2:
    print(str(num) +" is a prime number")
    else:
    print(str(num) +" is not prime number")

    ردحذف
  70. #WAP to print 1 to 5 and 5 to 1 again 1 to 5 and 5 to 1 using a single while loop?
    i =1

    while(i<= 20):
    if i<=5:
    print(i)
    elif i <=10:
    print(11-i)
    elif i<=15:
    print(i-10)
    else:
    print(i-15)
    i = i+1

    ردحذف
  71. #WAP to print 1 to 5 and 5 to 1 again 1 to 5 and 5 to 1 using a single while loop?
    i =1

    while(i<=20):
    if i<= 5:
    print(i)
    elif i>5 and i<=10:
    print(11-i)
    elif i>10 and i<= 15:
    print(i-10)
    else:
    print(21-i)
    i =i +1

    ردحذف
  72. #WAP to perform the addition of a one-digit positive number?
    sum =0
    i =1
    s =''

    while(i<=10):
    sum = sum + i
    if i<10:
    s = s+str(i) +"+"
    else:
    s= s+str(i) + "="
    i = i+1

    print(s,sum)

    ردحذف
  73. #WAP to reverse any digit number?
    num = int(input("Enter number = "))
    s = ''
    while(num!=0):
    s = s+ str(num%10)
    num = num//10
    else:
    print(s)

    ردحذف
  74. #WAP to check prime number using While--else statement in Python?
    num = int(input("Enter number = "))
    i = 2
    while i <num:
    if num %i ==0:
    print(str(num)+" Is Not Prime")
    break
    i =i+1
    else:
    print(str(num) +" Is Prime")

    ردحذف
  75. #WAP to calculate factorial of any number?
    num = int(input("Enter number = "))
    i = num
    f = 1
    #s= ''

    while( i>= 1):
    f = f * i
    #s = s +str(i) + "*"
    i=i-1

    print("factorial of "+ str(num)+" = "+ str(f))

    ردحذف
  76. #WAP to print a table of odd numbers?
    num = int(input("Enter number"))
    if num%2!=0:
    for i in range(1,11):
    print(str(num) + " * " + str(i) + "="+str(num*i))

    else:
    print("Enter odd number")

    ردحذف
  77. #WAP to display fibonacci series?
    a = -1
    b = 1

    for i in range(1,11):
    c= a+b
    print(c)
    a=b
    b=c

    ردحذف
  78. #WAP to calculate factorial of any number with complete expression?
    n = int(input("Enter number"))
    f= 1
    s=''

    for i in range(n, 1,-1):
    f =f*i
    s = s +str(i) +"*"

    print(str(s)+"1="+str(f))

    ردحذف
  79. #WAP to calculate the sum of one digit positive number?
    s = int(input("Enter number"))
    for i in range(1,s):
    s = s+i


    else:
    print(s)

    ردحذف
  80. #NESTED FOR LOOP
    for i in range(10,0,-1):
    for j in range(1, i+1):
    print(j,end='')
    print()

    ردحذف
  81. # nested_for_loop
    for i in range(1 ,6):
    for j in range(1,7-i):
    print( j, end='')
    print()

    ردحذف
  82. #Nested_for-loop_ABCDE_abcd
    for i in range(70,65,-1):
    for j in range(65,i):
    if i%2==0:
    print(chr(j),end='')
    else:
    print(chr(j+32), end='')
    print()

    ردحذف
  83. for i in range(65, 91):
    for j in range(65, i+1):
    print(chr(j), end='')
    print()

    ردحذف
  84. for i in range(70,65,-1):
    for j in range(65, i):
    if j %2 != 0:
    print(chr(j), end='')
    else:
    print(chr(j+32), end='')
    print()

    ردحذف
  85. #Nested_loop AaBbC

    for i in range(70, 65, -1):
    t = 65
    for j in range(65,i):
    if j%2 !=0:
    print(chr(t), end='')
    t =t+1
    else:
    print(chr(t+32), end='')
    print()

    ردحذف
  86. for i in range(1,6):
    for j in range(1, 7-i):
    if i % 2==0:
    print(6-j, end='')
    else:
    print(j, end='')
    print()

    ردحذف
  87. ABHISHEK GOYAL
    for i in range(70,65,-1):
    k=65
    for j in range(65,i):
    if j%2==0:
    print(chr(k+32),end=' ')
    k=k+1
    else:
    print(chr(k),end=' ')

    print()

    ردحذف
  88. ABHISHEK GOYAL
    for i in range(70,65,-1):
    k=65
    for j in range(65,i):
    if j%2==0:
    print(chr(k+32),end=' ')
    k=k+1
    else:
    print(chr(k),end=' ')

    print()

    ردحذف
  89. ABHISHEK GOYAL
    for i in range(70,65,-1):
    k=65
    for j in range(65,i):
    if j%2==0:
    print(chr(k+32),end=' ')
    k=k+1
    else:
    print(chr(k),end=' ')

    print()

    ردحذف
  90. ABHISHEK GOYAL
    for i in range(0,5):
    ch=65
    for k in range(0,i):
    print(' ',end=' ')
    ch=ch+1
    for j in range(i,5):
    print(chr(ch),end=' ')
    ch=ch+1

    print()

    ردحذف
  91. import time

    print("Please insert Your CARD")

    #for card processing
    time.sleep(5)

    password = 1234

    #taking atm pin from user
    pin = int(input("enter your atm pin "))

    #user account balance
    balance = 5000

    #checking pin is valid or not
    if pin == password:
    #loop will run user get free
    while True:

    #Showing info to user

    print("""
    1 == balance
    2 == withdraw balance
    3 == deposit balance
    4 == exit
    """
    )

    try:
    #taking an option from user
    option = int(input("Please enter your choise "))
    except:
    print("Please enter valid option")

    #for option 1
    if option == 1:
    print("Your current balance is",{balance})

    if option == 2:

    withdraw_amount = int(input("please enter withdraw_amount "))



    balance = balance - withdraw_amount

    print({withdraw_amount},"is debited from your account")



    print("your updated balance is",{balance})



    if option == 3:

    deposit_amount = int(input("please enter deposit_amount"))

    balance = balance + deposit_amount



    print({deposit_amount},"is credited to your account")



    print("your updated balance is",{balance})



    if option == 4:

    break


    else:
    print("wrong pin Please try again")

    ردحذف
  92. # PYTHON (6 To 7 PM BATCH)
    # CODE to Calculate Factorial of a Number with Complete Expression.

    a = int(input("Enter The Number:-"))

    b = 1
    for i in range(1,a+1):
    if i <a:
    b=i*b
    print(i,"*",end='')
    if i==a:
    b=i*b
    print(i,"=",b)

    ردحذف
  93. # PYTHON( 6 To 7 PM BATCH)
    # Code to reverse any digit number.

    a =int(input("Enter The Number :-\t"))

    b = str(a)

    c = str()

    for i in b:
    c=i +c
    a= int(c)

    print("Digit after reverse:-",a)

    ردحذف
  94. #Vishal Baghel#
    #Program for Single digit table & Two digit Fectorial With the help of Single while loop#
    f= 1
    i = 1
    while (i<100):
    if(i<=9):
    t=i*i
    f = f*i
    print("Single Digit No "+str(i)+ " Table is "+str(t))
    else:
    #f= i*(i-1)*(i-2)*(i-3)*(i-4)*(i-5)*(i-6)*(i-7)*(i-8)*(i-9)#
    f = f*i
    print("Two Digit No "+str(i)+ " Factorial is "+str(f))

    i = i+1

    ردحذف
  95. #Vishal Baghel#
    #Program for print 12345 , 54321,12345,54321 with the help of single while loop#
    i=1
    while(i<=20):
    if (i<=5):
    print(" ",i)
    elif(i>5 and i<=10):
    i2 = (11-i)
    print(" ",i2)
    elif(i>10 and i<=15):
    i3 = i-10
    print(" ",i3)
    else:
    i4 = 21-i
    print(" ",i4)

    i = i+1

    ردحذف
  96. #Reverce number Program By Surendra
    i=int(input("Please Enter Your Number"))
    rev = 0
    while (i>0):
    rev = (rev*10)+i%10
    i=i//10
    print("Reverse=",rev)

    ردحذف
  97. #WAP to print 1 to 5 ,5 to 1 , 1 to 5 , 5 to 1.
    i=1
    while(i<=20):
    if i<=5:
    print(i)
    elif (i<11):
    print(11-i)
    elif (i<16):
    print(i-10)
    elif(i<21):
    print(21-i)
    if((i+4)==9) and (i==5) :
    print("")
    elif((i-1)==9) and (i==10):
    print("")
    elif((i-6)==9) and (i==15):
    print("")
    elif((i-11)==9) and (i==20):
    print("")
    i=i+1

    ردحذف
  98. #Ravi Vyas
    num=int(input("Enter phonen number"))
    rev=0
    while (num>0):
    rev=(rev*10)+num%10
    num=num//10
    print(rev)

    ردحذف
  99. #Akash patel
    Lift program:-
    i=1
    While(i<=20):
    If (i<=5):
    Print(i)
    elif(i>=6 and i<=10):
    Print(11-i)
    elif(i>=11 and i<=15):
    Print(i-10)
    else:
    Print(21-i)

    ردحذف
  100. #Akash patel
    Reverse mobile number
    i=int(input(" Enter Your mobile Number"))
    rev = 0
    while (i>0):
    rev = (rev*10)+i%10
    i=i//10
    print("Reverse=",rev)

    ردحذف
  101. #Akash patel
    Sum of two digit number:-
    i=10,sum=0
    While(i>=10 and i<=99):
    Sum=sum+i
    Print(sum)

    ردحذف
  102. #AKASH PATEL
    table&factorial program
    num=int(input("enter number")
    i=1
    fact=1
    if num<=9:
    while(i<=10):
    table=num*i
    print(table)
    i=i+1
    else:
    while(i<=num):
    fact=fact*i
    i=i+1
    print(fact)

    ردحذف
  103. Program to calculate table if number is one digit postive and calculate factorial if number is two digit positive?

    num = int(input("Enter first number"))
    if num>0 and num<10:
    i=1
    while(i<=10):
    print(num*i)
    i=i+1

    else:
    if num>=10 and num<100:
    print("FACTORIAL")
    f=1
    i=num
    while(i>1):
    f=f*i
    i=i-1
    print(f)

    else:
    print("Invalid Number")

    ردحذف
  104. #1-5 , 5-1 and against 1-5 ,5-1
    i=1
    while(i<=20):
    if i<=5:
    print(i)

    elif(i>=5 and i<=10):
    print(11-i)

    elif(i>=11 and i<=15):
    print(i-10)

    elif (i>15 and i<=20):
    print(21-i)

    i=i+1

    ردحذف
  105. #Vishal Baghel#
    #WAP for calculate factorial of enter no and print factorial process ex. factorial of 3 , 3*2*1 #
    n1 = int(input("Enter number to find out factorial = "))
    i=n1
    f=1
    while i>=1:
    f = f*i
    print(str(i)+ " * ",end='')
    i= i-1


    print(" Enter no. factorial is ",f)

    ردحذف
  106. #Vishal Baghel#
    #WAP for check enter no prime or not #
    n1 = int(input("Enter number to find out factorial = "))
    no = int(input("Enter Any no. for check it prime or not = "))
    i =1
    c = 0
    while(i<=no):
    if(no%i==0):
    c= c+1
    i= i+1
    if(c==2):
    print("It is Prime no.")
    else:
    print("It is not Prime no.")

    ردحذف
  107. #Akash patel
    #WAP to check prime number

    num = int(input("enter number to check prime"))
    i=2
    a=0
    while i<num:
    if num%i==0:
    a=1
    i=i+1

    if a==0:
    print("prime")
    else:
    print("not prime")

    ردحذف
  108. #1-5 , 5-1 and against 1-5 ,5-1
    i=1
    while(i<=20):
    if i<=5:
    print(i)

    elif(i>=5 and i<=10):
    print(11-i)

    elif(i>=11 and i<=15):
    print(i-10)

    elif (i>15 and i<=20):
    print(21-i)

    i=i+1

    ردحذف
  109. #Akash patel
    square and cube of 1 digit postive number
    i=1
    while(i<10):
    square=i*i
    cube=i*i*i
    print(square)
    print(cube)
    i=i+1

    ردحذف
  110. #program to calculate factorial with complete expression'

    n1 = int(input("Enter number to calculate factorial = "))
    i=n1 #i=5
    f=1
    s=''
    while i>1:
    f = f*i # f= 120
    s = s + str(i) + "*"
    i= i-1 # i=1


    print(s+"1" + "=" + str(f))

    ردحذف
  111. Check Prime Number without using third variable?
    num = int(input("Enter number")) #6

    i=2
    while i<=num/2: # 2<6
    if num%i==0: # 6%2
    print("not prime")
    break

    i=i+1


    if (num//2+1)==i:
    print("prime")

    ردحذف
  112. #Table Print By using For Lop
    x = int(input("Enter Number To Find Table"));
    for y in range(1,11):
    y=y*x
    print(y);

    ردحذف
  113. Q1 WAP to display prime number in fibonacci series?
    Q2 WAP to print series of prime number?
    Q3 WAP to check that number is armstrong number?
    Q4 WAP to display table of prime number and factorial of composite number?



    ردحذف
    الردود
    1. Program of Prime Number Series?

      start = int(input("Enter start"))
      end = int(input("Enter end"))

      for num in range(start,end):
      for i in range(2,num):
      if num%i==0:
      break
      else:
      print(num)

      حذف
  114. #Check Armstrong Number Using For Loop
    num = int(input("Enter Yout Number To Check Amstrong Or Not"))
    orig = num
    sum = 0
    for i in range(num,0,-1):
    sum = sum+(num%10)*(num%10)*(num%10)
    num = num //10
    if orig ==sum:
    print("This Is Amstring Number")
    else :
    print("This Is Not Amstrong")

    ردحذف
  115. # WAP to display table of prime number and factorial of composite number?
    #Ravi vyas
    num=int(input("enter number:"))
    c=0
    n=0
    for i in range(1,num+1):
    if num%i==0:
    c=c+1
    if c==2:
    print("prime number")
    for i in range(1,11):
    print(num*i)
    else:
    print("composite number")
    f=1
    for i in range(num,1,-1):
    f=f*i
    print(f)


    ردحذف
  116. # WAP to check that number is armstrong number?
    #Ravi vyas
    a=int(input("enter number:"))
    t=a
    sum=0
    for i in range(1,a):
    r=t%10
    sum=sum+r*r*r
    t=t//10

    if a==sum:
    print("armstrong:"+str(a))
    else:
    print("not armstrong"+str(a))

    ردحذف
  117. WAP to check Armstrong number?
    num=153
    num1=num
    sum=0
    while num1!=0:
    rem = num1%10 #1
    sum=sum+ rem**3 # sum = 152 +1
    num1=num1//10 #num1 = 0
    print(sum)
    if num==sum:
    print("armstronng")

    else:
    print("normal number")

    ردحذف
  118. #print 12345
    #jeet
    for i in range (1,6):
    for j in range (i,6):
    Print(j,end='')
    Print ()

    ردحذف
  119. #PRABAL DUBEY
    #12345
    #2345
    #345
    #45
    #5
    for i in range (1,6):
    for k in range (i,6):
    print (k,end=" ")
    print()

    ردحذف
  120. #print 12345
    #Ravi vyas
    for i in range(1,6):
    for j in range(i,6):
    print(j,end=" ")
    print()

    ردحذف
  121. #Nested Loop 12345.....5 Program By Surendra
    for i in range(1,6):
    for j in range(i,6):
    print(j,end='')
    print()

    ردحذف
  122. #PRABAL DUBEY
    #ABCDE
    # BCDE
    # CDE
    # DE
    # E
    s=0
    for i in range (65,70):
    for k in range(s):
    print(' ',end='')
    for j in range(i,70):
    print(chr(j),end="")
    s=s+1
    print()

    ردحذف
  123. #Using Nested For Loop A-E program
    s=0
    for i in range (65,70):
    for k in range(s):
    print(' ' ,end='')
    for j in range (i,70):
    print(chr(j),end='')
    print()
    s=s+1

    ردحذف
  124. #A-a in Nested For Loop
    for i in range(5,0,-1):
    a=65
    b=97
    for j in range(0,i):
    if j%2==0:
    print(chr(a),end='')
    a+=1
    else:
    print(chr(b),end='')
    b+=1
    print()

    ردحذف
  125. #Using Nested For Loop A-E program By Surendra
    s=0
    for i in range (65,70):
    for k in range(s):
    print(' ' ,end='')
    for j in range (i,70):
    print(chr(j),end='')
    print()
    s=s+1

    ردحذف
  126. # PRINT LIKE THIS

    *********
    *******
    @@@@@
    @@@
    @
    #
    #VISHAL BAGHEL#

    num= int(input("Enter number Of Rows = "))
    for i in range(1,num+1):
    for j in range(0,i-1):
    print(" ",end="")

    for k in range(0,num*2-(i*2-1)):
    if(i<=2):
    print("*",end="")
    else:
    print("@",end="")
    print()

    ردحذف
  127. Program to print 1 to N and then N to 1

    """ PROGRAM 1 """"
    num=int(input("enter a number:::"))

    i=1
    j=num
    while(i<=num*2):

    if(i<=num):
    print(i)
    else:
    print(j)
    j-=1

    i+=1

    """"PROGRAM 2"""


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

    i=1

    while(i<=num*2):


    if(i<=num):
    print(i)

    else:
    print( ((num*2)+1)-i )

    i+=1




    ردحذف
  128. d=int(input("from"))
    e=int(input("to"))
    squre=' '
    cube=' '
    while (d<=e):
    squre=d*d
    cube=d*d*d
    print("squre and cube of "+str(d) ," ",squre ," " ,cube)
    d=d+1

    ردحذف
  129. number=1
    while (number<=10):
    if(number<=5):
    print(number)
    else:
    print(11-number)
    number=number+1

    ردحذف
  130. factorial=1
    i=int(input("enter number to find its factorial"))
    while (i>=1):
    factorial=factorial*i
    i=i-1
    print(factorial)

    ردحذف
  131. #NIKHIL SINGH CHOUHAN

    '''wap to 1 to 10

    i=1
    while(i<=10):
    print(i)
    i=i+1

    #print 1 to n
    n=int(input("enter number"))
    i=1
    while(i<=n):
    print(i)
    i=i+1
    # wap print 10 to n

    n=int(input("enter number"))
    i=10
    while(i>=n):
    print(i)
    i=i-1'''

    #wap to print frome n to 1

    '''n=int(input("enter number"))
    while(n>=1):
    print(n)
    n=n-1'''

    #wap sum from 1 to n

    '''n=int(input("enter number"))
    sum=0
    a=1
    while(n>=a):
    sum=sum+a
    a=a+1
    print(sum)'''

    #wap sum of square frome 1 to n

    '''n=int(input("enter number"))
    a=1
    sum=0
    while(n>=a):
    sum=sum+a*a
    a=a+1
    print(sum)'''


    #wap sum of cube 1 to n

    '''n=int(input("enter number"))
    a=1
    sum=0
    while(n>=a):
    sum=sum+a*a*a
    a=a+1
    print(sum)'''


    #wap print only even number between 1 to n

    '''i=int(input("enter number"))
    a=1
    while(i>=a):
    if(a%2==0):
    print(a)
    a=a+1'''

    #wap to find sum of even number frome 1 to n


    '''i=int(input("enter number"))
    a=1
    sum=0
    while(i>=a):
    if(a%2==0):
    sum=sum+a
    a=a+1
    print(sum)'''


    '''# wap to find sum of first n even number?


    i=int(input( "enter number"))
    sum=0
    count=0
    a=1
    while(counta):
    sum=sum+(i%10)
    i=i//10
    print(sum)'''


    #wap to cheak weather number is armstrong number is not

    '''i=154
    org=i
    sum=0
    while(i>0):
    sum=sum+(i%10)*(i%10)*(i%10)
    i=i//10
    print(sum)
    if(org==sum):
    print("armstrong number:")
    else:
    print("its notr armsstrong number")'''


    #wap find a product of given number

    '''i=int(input("enter number"))
    prod=1
    while(i>0):
    prod=prod*(i%10)
    i=i//10
    print(prod)'''


    #wap to find sum of even number nd product of even number?



    '''i=int(input("enter number"))
    sum=0
    prod=1
    while(i>0):
    if(i%2==0):
    sum=sum+(i%10)
    i=i//10
    elif(i%2!=0):
    prod=prod*(i%10)
    i=i//10
    print(prod)'''



    #wap to find reverse of number


    '''i=int(input("enter number"))
    rev=0
    while(i>0):
    rev=rev*10+(i%10)
    i=i//10
    print(rev)'''



    #WAP to print a table of any entered number?
    '''i=int(input("enter number"))
    a=1
    while(a<=10):
    print(str(i)+"*"+str(a)+"="+str(i*a))
    a=a+1'''


    '''#WAP to print 1 to 5 and 5 to 1 using a single while loop?


    i=1
    while(i<=10):
    if(i<6):
    print(i)
    i=i+1
    else:
    print(11-i)
    i=i+1'''


    #WAP to calculate square and cube of one digit positive number?

    '''1 1 1
    2 4 8
    3 9 27'''


    a = int(input("enter starting point"))
    b = int(input("enter ending point"))

    i=a
    while(i<b):
    k=i*i
    l=i*i*i
    print(i,k,l)
    i=i+1'''

    ردحذف
  132. i=int(input("enter number"))
    fact=1
    x=1
    if (i%2!=0):
    while(fact<=10):
    x=i*fact
    print(str(i),"*",str(fact)," = ",x)
    fact=fact+1
    elif i%2==0:
    while (i>=1):
    fact=fact*i
    i=i-1
    print(fact)

    ردحذف
  133. #Q) WAP to print 1 to 10..??
    value=1;
    while(value<=10):
    print(value);
    value=value+1; #value+=1;

    ردحذف
  134. #Q) WAP to print 1 to n..??
    n=int(input("Enter value of n : "));
    value=1;
    while(value<=n):
    print(value);
    value=value+1; #value+=1;

    ردحذف
  135. #Q) WAP to print 10 to 1..??
    value=10;
    while(value>=1):
    print(value)
    value=value-1 #value-=1;

    ردحذف
  136. #Q) WAP to print 10 to 1..??
    value=10;
    while(value>=1):
    print(value)
    value=value-1 #value-=1;

    ردحذف
  137. #Q) WAP to print n to 1..??
    value=int(input("Enter value of n : "));
    while(value>=1):
    print(value)
    value=value-1 #value-=1;

    ردحذف
  138. #Q) WAP to print a table of any entered number..??
    no=int(input("Enter any number : "));
    k=1;
    while(k<=10):
    print(no,"*",k," = ",k*no)
    k=k+1; #k+=1;

    ردحذف
  139. #Q) WAP to print 1 to 5 and 5 to 1 using a single while loop..??
    value=k=1;
    while(value<=10):
    if(value<=5):
    print(value);
    else:
    if(value>6):
    k=k+2; #k+=2;
    print(value-k);
    value=value+1; #value+=1;

    ردحذف
  140. #Q) WAP to calculate square and cube of one digit positive number?
    #1 1 1
    #2 4 8
    #3 9 27
    #...........................
    here=int(input("Input first : "));
    there=int(input("Input Second : "));
    while(here<=there):
    print((here)," ",(here*here)," ",(here*here*here))
    here=here+1; #here+=1;

    ردحذف
  141. no=int(input("Enter a one digite possitive number : "));
    while(no>0 and no<10):
    print("this number's square is :",no*no," and cube is :",no*no*no);
    break;
    else:
    print("you put something else! because thats not a one digite possitive number.....");

    ردحذف
  142. calc=10
    Sumeven=0
    Sumodd=0
    while(calc<=99):
    if(calc%2==0):
    Sumeven=Sumeven+calc
    calc=calc+1
    if(calc%2!=0):
    Sumodd=Sumodd+calc
    calc=calc+1
    print("sum of all 2digit even number is",Sumeven)
    print("sum of all 2digit odd number is",Sumodd)

    ردحذف
  143. #Q) WAP to print 1 to 5 and 5 to 1, then again 1 to 5 and 5 to 1, using a single while loop..??
    #Note for viewers : this is myWay, without using second while loop program.....
    value=k=l=1;
    while(value<=10):
    if(value<=5):
    print(value);
    else:
    if(value>6):
    k=k+2;
    print(value-k);
    value=value+1;
    if(value==11 and l!=2):
    l=l+1;
    value=k=1;

    ردحذف
  144. #Q) WAP to perform the addition of a one-digite positive number?
    incr=1; val=0; strAdd='';
    while(incr<10):
    strAdd+=str(incr);
    if(incr<9):
    strAdd+='+';
    val+=incr;
    incr+=1;
    print(strAdd,'=',val);

    ردحذف
  145. #Q) WAP to calculate factorial of a number with Complex Expression? with user choice......
    # hint : factorial of five is just like that, 5*4*3*2*1=120.
    no=int(input("Entered number to calcFactorial : "));
    val=1; strFacts='';
    while(no>=1):
    strFacts+=str(no);
    if(no!=1):
    strFacts+='*';
    val*=no; no-=1;
    print(strFacts,'=',val);

    ردحذف
  146. #Q) WAP to check prime number?
    #Note for Viewers : there are my way solution's three programs, and there are two more way's solutions with the questions, so also looked it, okkey.....
    #________solution_1________
    no=int(input("Entered a number : "));
    k=2; s=0;
    while(k<no and s==0):
    if(no%k==0):
    s=1;
    k+=1;
    if(s==0):
    print("It's a prime no.....");
    else:
    print("It's not a prime no.....")
    #________solution_2________
    no=int(input("Entered a number : "));
    k=2; s=0;
    while(k<no):
    if(no%k==0):
    s+=1;
    k+=1;
    print("It's a prime no.....") if(s==0) else print("It's not a prime no.....");
    #________solution_3________
    no=int(input("Entered a number : "));
    k=2; s=0;
    while(k<no//2):
    if(no%k==0):
    s+=1;
    k+=1;
    print("It's a prime no.....") if(s==0) else print("It's not a prime no.....");

    ردحذف
  147. #Q)WAP to reverse any digit number?
    #hint, for example, user enter 12345, then the output will be 54321
    no=int(input("Enter a number : "));
    s=0;
    while(no!=0):
    k=no%10;
    s=(s*10)+k;
    no=no//10;
    print("Reversed number is : ",s)

    ردحذف
  148. char=65
    while(char<=122):
    if(char>90 and char<97):
    print(" ")
    else:
    print(chr(char))
    char=char+1

    ردحذف
  149. #Q1) WAP to display table of odd number and factorial of even number?
    #________________solution_1_________________
    no=int(input("Enter a number : "));
    i=k=1;
    if(no%2==0):
    while(i<=10):
    print(no,"*",i," = ",no*i);
    i=i+1;
    else:
    while(i<=no):
    k=k*i;
    if(i==no):
    print("factorial of",no,"is :",k);
    i+=1;
    #______________solution_2___________
    no=int(input("Enter a number : "));
    i=k=1;
    no1= 10 if(no%2==0) else no;
    while(i<=no1):
    if(no%2==0):
    print(no,"*",i," = ",no*i);
    else:
    k=k*i;
    if(i==no):
    print("factorial of",no,"is :",k);
    i+=1;

    ردحذف
  150. #Q2.1)WAP to display max and second max number in mobile number?
    #Note : its a program if there is two same biggest no is available, but is not printing its..... (theBESTway)
    no=int(input("Enter a number : "));
    a=b=k=0;
    while(no!=0):
    k=no%10;
    if(ak):
    b=k;
    no=no//10;
    print("Largest number is :",a,"second largest no is :",b);

    #Q2.2) WAP to find max digit, second max digit in mobile number?
    #Note : its a program if there is two same biggest no is available so it print it.....(notTheBESTway)
    no=int(input("Enter a number : "));
    s=x=y=0;
    while(no!=0):
    k=no%10;
    if(x<k):
    y=x;
    x=k;
    elif(y<k and y!=x):
    y=k;
    no=no//10;
    print("big digite is :",x,", small digite is :",y)

    ردحذف
  151. #Q2.1)WAP to display max and second max number in mobile number?
    #Note : its a program if there is two same biggest no is available, but is not printing its..... (theBESTway)
    no=int(input("Enter a number : "));
    a=b=k=0;
    while(no!=0):
    k=no%10;
    if(ak):
    b=k;
    no=no//10;
    print("Largest number is :",a,"second largest no is :",b);

    #Q2.2) WAP to find max digit, second max digit in mobile number?
    #Note : its a program if there is two same biggest no is available so it print it.....(notTheBESTway)
    no=int(input("Enter a number : "));
    s=x=y=0;
    while(no!=0):
    k=no%10;
    if(x<k):
    y=x;
    x=k;
    elif(y<k and y!=x):
    y=k;
    no=no//10;
    print("big digite is :",x,", small digite is :",y)

    ردحذف
  152. #Q3) WAP to reverse any digite number?
    no=int(input("Enter a number : "));
    l=0;
    while(no!=0):
    k=no%10;
    l=(l*10)+k;
    no=no//10;
    print(l);

    ردحذف
  153. #Q4)WAP to calculate sum of all even digite and odd digite of two digit __possitive__ numbers?
    #________way_1 (with two digite possitive number)____________
    evenNo=oddNo=0; i=10
    while(i<100):
    if(i%2==0):
    evenNo+=i;
    else:
    oddNo+=i;
    i+=1;
    print("All the evenNumber's calculation is :",evenNo)
    print("All the oddNumber's calculation is :",oddNo)
    #________way_2 (with two digits possitive or negative number)____________
    evenNo=oddNo=0; i=-99
    while(i<100):
    if(i%2==0):
    evenNo+=i; #evenNo+=i;
    else:
    oddNo+=i; #oddNo+=i;
    i+=1;
    if(i==-9):
    i=10
    print("All the evenNumber's calculation is :",evenNo)
    print("All the oddNumber's calculation is :",oddNo)

    ردحذف
  154. #Q5)WAP to display A to Z and a to z in single while loop?
    #______________solution_1___________
    i=65
    while(i!=123):
    print(chr(i));
    i+=1;
    if(i==91):
    i=97;
    #______________solution_2___________
    i=65
    while(i!=91):
    print(chr(i)," -- ",chr(i+32));
    i+=1;

    ردحذف
  155. table=int(input("enter odd number to get table"))
    if(table%2!=0):
    for i in range(1,11):
    print(str(table),"*",str(i),"=",(table*i))
    else:
    print("entred number is not odd number")

    ردحذف
  156. num=int(input("enter number"))
    x=-1
    y=1
    z=' '
    print("fabonacci series")
    for i in range(0,num):
    z=x+y
    print(z)
    x=y
    y=z

    ردحذف
  157. #WAP to print a table of odd numbers?
    num=int(input("Enter the number = "))
    if num%2!=0:
    for i in range(1,11):
    k=num*i
    print(str(num)+"*"+str(i)+"="+str(k))
    else:
    print("Enter only odd Number")

    #WAP to display fibonacci series?
    a=-1
    b=1
    for i in range(0,11):
    c=a+b
    print(c)
    a,b=b,c

    ردحذف
  158. #parth
    #pattern program
    for i in range(5,0,-1):
    ch=65
    for j in range(1,i+1):
    print(chr(ch),end=' ')
    ch=ch+1
    print()

    ردحذف
  159. #binary pattern
    for i in range(1,6):
    a=0
    b=1
    for j in range(1,7-i):
    if j%2==0:
    print(b,end=' ')
    b=1
    else:
    print(a,end=' ')
    a=0
    print()

    ردحذف
  160. #star patter
    picture=[
    [0,0,0,1,0,0,0],
    [0,0,1,1,1,0,0],
    [0,1,1,1,1,1,0],
    [1,1,1,1,1,1,1],
    [0,0,0,1,0,0,0],
    [0,0,0,1,0,0,0]
    ]
    for row in picture:
    for pixel in row:
    if(pixel==1):
    print('*', end='')
    else:
    print(' ', end='')
    print('')

    ردحذف
  161. #wap
    # A a B b C
    # A a B b
    # A a B
    # A a
    # A
    for i in range(1,6):
    ch=65
    for j in range(1,7-i):
    if j%2==0:
    print(chr(ch+32),end=' ')
    ch+=1
    else:
    print(chr(ch),end=' ')
    print()
    5 4 3 2 1
    1 2 3 4
    5 4 3
    1 2
    5

    for i in range (1,6):
    for j in range (1,7-i):
    if i%2==0:
    print(j,end=' ')
    else:
    print(6-j,end=' ')
    print()
    1 2 3 4 5
    5 4 3 2
    1 2 3
    5 4
    1

    for i in range (1,6):
    for j in range (1,7-i):
    if i%2==0:
    print(j,end=' ')
    else:
    print(6-j,end=' ')
    print()
    1 0 0 1 0
    1 0 0 1
    1 0 0
    1 0
    1

    for i in range(1,6):
    a,b=1,0
    for j in range(1,7-i):
    if j%2==0:
    print(b,end=' ')
    b=1
    else:
    print(a,end=' ')
    a=0
    print()
    #fac=5*4*3*2*1=120
    num=5
    r=1
    s=""
    for i in reversed(range(1,num+1)):
    r=r*i
    s=s+str(i)+"*"
    print(s+"="+str(r))
    A B C D E
    A B C D
    A B C
    A B
    A

    for i in range(0,5):
    ch=65
    for k in range(0,i):
    print(" ",end=' ')
    for j in range(i,5):
    print(chr(ch),end=' ')
    ch+=1
    print()

    ردحذف
  162. SACHIN KUMAR GAUTAM
    #PRINT * PATTERN


    for i in range(1,6):
    for k in range(1,6-i):
    print(" ",end=" ")
    for j in range(1,(2*i-1)+1):
    print("*",end=" ")
    print("\n")


    ردحذف
  163. #1 2 3 4 5
    #1 2 3 4 5
    #1 2 3 4 5
    #1 2 3 4 5
    #1 2 3 4 5
    for i in range(1,6):
    for j in range(1,6):
    print(j,end=' ')
    print()

    ردحذف
  164. #1 2 3 4 5
    #1 2 3 4
    #1 2 3
    #1 2
    #1
    for i in range(5,0,-1):
    k=1
    for j in range(1,i+1):
    print(k,end=' ')
    k=k+1
    print()

    ردحذف
  165. #A B C D F
    #A B C D
    #A B C
    #A B
    #A
    for i in range(5,0,-1):
    k=65
    for j in range(1,i+1):
    print(chr(k),end=' ')
    k=k+1
    print()

    ردحذف
  166. #A
    #A B
    #A B C
    #A B C D
    #A B C D F
    for i in range(1,6):
    k=65
    for j in range(1,i+1):
    print(chr(k),end=' ')
    k=k+1
    print()

    ردحذف
  167. #1
    #1 2
    #1 2 3
    #1 2 3 4
    #1 2 3 4 5
    for i in range(1,6):
    k=1
    for j in range(1,i+1):
    print(k,end=' ')
    k=k+1
    print()

    ردحذف
  168. #A B C D E
    #a b c d
    #A B C
    #a b
    #A
    for i in range(5,0,-1):
    k= 97 if(i%2==0) else 65
    for j in range(1,i+1):
    print(chr(k),end=' ');
    k=k+1;
    print()

    ردحذف
  169. #A B C D E
    #a b c d
    #A B C
    #a b
    #A
    for i in range(5,0,-1):
    k= 97 if(i%2==0) else 65
    for j in range(1,i+1):
    print(chr(k),end=' ');
    k=k+1;
    print()

    ردحذف
  170. #A a B b C
    #A a B b
    #A a B
    #A a
    #A
    for i in range(5,0,-1):
    k=0
    for j in range(1,i+1):
    s= 97 if(j%2==0) else 65
    print(chr(s+k),end=' ')
    if(j%2==0):
    k+=1;
    print()

    ردحذف
  171. #1 2 3 4 5
    #5 4 3 2
    #1 2 3
    #5 4
    #1
    for i in range(5,0,-1):
    k= 5 if(i%2==0) else 1
    for j in range(k,i+1):
    print(k,end=' ')
    k= k-1 if(i%2==0) else k+1
    print()

    ردحذف
  172. #1 0 0 1 0
    #1 0 0 1
    #1 0 0
    #1 0
    #1
    for i in range (5,0,-1):
    for j in range(1,6):
    if(j<=i):
    k=1 if j%3==1 else 0
    print(k,end=" ")
    print()

    ردحذف
  173. #A B C D E
    # B C D E
    # C D E
    # D E
    # E
    for i in range(1,6):
    k=0
    for j in range(1,6):
    if(j<i):
    print(" ",end=" ")
    else:
    print(chr(65+k),end=" ")
    k+=1
    print()

    ردحذف
  174. # *
    # * * *
    #* * * * *
    # * * *
    # *

    #on developer choice, means 5 is fixed.....
    n=5
    n=n+1;
    for i in range(1,6):
    k = i if(i<=n//2) else k-1;
    for j in range(1,n):
    if(j>=4-k and j<=2+k):
    print("*",end=' ');
    else:
    print(" ",end=' ');
    print()

    #on user choice.....
    n=(int(input("enter any num")) + 1)
    for i in range(1,n):
    k=i if(i<=n//2) else k-1
    for j in range(1,n):
    if(j>=(((n//2)+1)-k) and j<=(((n//2)-1)+k)):
    print("*",end=" ")
    else:
    print(" ",end=" ")
    print()

    ردحذف
  175. s=''
    for i in range(1,13):
    if i<6:

    s=s+str(i)+" "

    elif i<10:
    if i==6:
    s=s+"\n"+str(i-5) + " "
    else:
    s= s+str(i-5)+" "

    elif i<13:
    if i==10:
    s=s+"\n"+str(i-9) +" "
    else:
    s= s+str(i-9)+" "



    print(s)

    ردحذف
  176. #Abhishek Singh
    # Printing Diamond shape:-
    ch="-"
    num=5

    i=1
    while(i<=num):
    print(" "*(num-i),(ch+" ")*i)
    i+=2

    i=num-2

    while(i>0):
    print(" "*(num-i),(ch+" ")*i)
    i-=2

    ردحذف
  177. calculate square and cube of one digit positive number

    i= 1
    while(i<10):
    s=i*i
    c=i*i*i
    print(i,s,c)
    i=i+1

    ردحذف
  178. print 1 to 5 and 5 to 1 again 1 to 5 and 5 to 1 using a single while loop

    i=1
    while(i<=20):
    if i<=5:
    print(i)
    elif i>5 and i<=10:
    print(11-i)
    elif i>10 and i<=15:
    print(i-10)
    else:
    print(21-i)
    i=i+1

    ردحذف
  179. perform the addition of a one-digit positive number

    i=1
    sum=0
    while(i<10):
    sum=sum+i
    i=i+1
    print(sum)

    ردحذف
  180. '''
    Solve these problems using Nested For loop:-
    output :-
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    1 2 3 4 5
    '''
    #solution
    for i in range(6,1,-1):
    for j in range(1,6):
    print(j,end='')
    print()

    ردحذف
  181. '''
    Solve these problems using Nested For loop:-
    output :-
    A B C D E
    A B C D
    A B C
    A B
    A
    '''
    for i in range(70,65,-1):
    for j in range(65,i):
    print(chr(j),end='')
    print()

    ردحذف


  182. Reverse no.

    num=int(input("enter number"))
    s=''
    while (num!=0):

    s=s+str(num%10)
    num=num//10
    print(s)

    ردحذف
  183. 1 2 3 4 5
    1 2 3 4
    1 2 3
    1 2
    1

    for i in range(1,6):

    for j in range(1,7-i):
    print(j,end=" ")
    print()

    ردحذف
  184. WAP to calculate square and cube of one digit positive number

    stnum=int(input("enter starting number "))
    endnum=int(input("enter end number "))
    i=stnum
    while(i<=endnum):
    s=i**2
    c=i**3
    print(i,s,c)
    i=i+1

    ردحذف
  185. WAP to print 1 to 5 and 5 to 1 again 1 to 5 and 5 to 1 using a single while loop

    num=1
    while(num<=10):
    if num<=5:
    print(num)
    else:
    print(11-num)
    num=num+1

    ردحذف
  186. i=1
    while(i<=10):
    print(i)
    i=i+1

    ردحذف
  187. num=int(input("enter number to calculate tabble"))
    i=1
    while(i<=10):
    print(num*i)
    i=i+1

    ردحذف
  188. num=int(input("enter a number"))
    end=int(input("enter a ending point"))
    i=num
    while(i<end):
    sq=i*i
    cu=i*i*i
    print("squre is "+str(sq)+str("cube is ")+str(cu))
    i=i+1

    ردحذف
  189. i=1
    while(i<=20):
    if i<6:
    print(i)
    elif i>6 and i<=10:
    print(11-i)
    elif i<16 and i>10:
    print(i-10)
    else:
    print(21-i)
    i=i+1

    ردحذف
  190. num=int(input("enter number to check prime number"))
    i=2
    count=0
    while i<num:
    if num%i==0:
    count=1
    break
    i=i+1
    if count==0:
    print("prime")
    else:
    print("not prime")

    ردحذف
  191. WAP to reverse any digit number

    num=int(input("Enter a number : "));
    c=0;
    while num!=0:
    k=num%10;
    num=num//10
    c=(c*10)+k;

    print("Reversed number is : ",c)

    ردحذف
  192. to calculate factorial of any number
    num = int(input("enter number to calculate factorial"))
    f=1
    i=num
    s=''
    while i>1:
    f=f*i
    s=s+str(i)+"*"
    i=i-1

    print("factorial is ",s+"1=",f)

    ردحذف
  193. n=int(input("enter a number"))
    r=0
    while n%10!=0:
    c=n%10
    r=r*10+c
    n=n//10
    print(r)

    ردحذف
  194. num=7415180220
    m=0
    sm=0
    while (num!=0):
    rev=num%10

    num=num//10
    if m<rev:
    sm=m
    m=rev
    elif sm<rev and sm!=m:
    sm=rev
    print(m,"",rev)

    ردحذف
  195. # atm programm
    print(" -: WELCOME :- \n Please insert your Card ")
    #print(time.start)
    flag=False
    p=2021
    bal=5000
    for i in range(1,4):
    pin = int(input("enter pin code "))
    if pin==p:
    flag=True
    break
    while(flag):
    if flag:
    ch = input(" Press C for credit \n Press D for bedit \n Press b for check balance \n press e for exit ")
    if ch=='c':
    amt = int(input("Enter Credit amount "))
    bal+=amt
    print(bal)
    elif ch=='d':
    amt = int(input("Enter Debit amount "))
    bal-=amt
    print(bal)
    elif ch=='b':
    print("Your current balance is ",bal)
    print(bal)
    elif ch=="e":
    print(" -: THANK YOU :- ")
    break

    else:
    print("Incorrect pin code and your all attempt has completed")

    ردحذف
  196. n=int(input("enter a number for print table"))
    if n%2!=0:
    for i in range(1,11):
    s=n*i
    print(s)
    else:
    print("enter odd no")

    ردحذف
  197. n=int(input("enter a number for print table"))
    if n%2!=0:
    for i in range(1,11):
    s=n*i
    print(s)
    else:
    print("enter odd no")

    ردحذف

POST Answer of Questions and ASK to Doubt