0% found this document useful (0 votes)
15 views

For loop first 5 programme

The document contains multiple Python programs for various tasks: generating a multiplication table for a given number, reversing the digits of a number, printing Fibonacci and Tribonacci series for a specified number of terms, and calculating the sum of all even numbers up to a given number. Each program prompts the user for input and displays the results accordingly. The code snippets illustrate basic programming concepts such as loops and conditionals.

Uploaded by

aditya149424
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

For loop first 5 programme

The document contains multiple Python programs for various tasks: generating a multiplication table for a given number, reversing the digits of a number, printing Fibonacci and Tribonacci series for a specified number of terms, and calculating the sum of all even numbers up to a given number. Each program prompts the user for input and displays the results accordingly. The code snippets illustrate basic programming concepts such as loops and conditionals.

Uploaded by

aditya149424
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

#Write a programme to find table of any number 'n'

n=int(input("Enter the number whose table you want:"))

for i in range(1,11):

print(n, 'x', i, '=', n*i)

#Write a programme to reverse digits of a number

n=(input("Enter the number whose digits you want to reverse:"))

rn=""

for digit in n :

rn = digit + rn

#(note-gap is important)

rn = int(rn)

print("Your Reversed number is ", rn)

#Write a programme to print n number of terms in fibonacci series

a=int(input("Enter the number of terms you want in fibonacci series:"))

b=0

c=1

for i in range(a):

print(b, end = " ")

b, c = c, b + c

#Write a programme to print n number of terms in Tribonacci series

a=int(input("Enter the number of terms you want in Tribonacci series:"))

b=0

c=0

d=1
for i in range(a):

print(b, end = " ")

b, c, d = d, c, b + c + d

#Write a Python program to calculate the sum of all even numbers from 1 to n numbers.

n=int(input("Enter no till you want sum :"))

sum=0

for number in range(1, n+1):

if n % 2 == 0 :

sum += n

print("The sum of all even numbers from 1 to", n, "is", sum)

You might also like