# Top 10 loop questions in python For interview ## 1.Write a program to find factorial of given number.

fact=1

i=1

n=int(input(“enter the number”))

while i<=n:

fact=fact*i

i=i+1

print(fact)

Output:

enter the number4

24

## 2.Write a program to find Fibonacci Series.

n=int(input(“how many terms???”))

n1=0

n2=1

count=0

for i in range(1,n):

print(n1,end=’ ‘)

count=n1+n2

n1=n2

n2=count

Output: how many terms???10

0 1 1 2 3 5 8 13 21 34

## 3. Write a program to check whether the given number is Armstrong number or not.

n=372

sum=0

p=n

while n>0:

x=int(n%10)

sum=sum +x*x*x

n=n/10

if p==sum:

print(“%i is Armstrong number “%p)

else:

print(“%i is not Armstrong number “%p)

Output:

153 is Armstrong number

## n=int(input(“Enter the number”))

if n>1:

for i in range(2,n):

if (n%i==0):

print(“%i is not prime number “%n)

break

else:

print(“%i is prime number “%n)

else:

print(“%i is not prime number “%n)

Output:

Enter the number97

97 is prime number

1. ## Write a program to check whether the given number is Perfect  number or not.

n=int(input(“Enter the number”))

sum=0

for i in range(1,n):

if n%i==0:

sum=sum+i

print(sum)

if sum==n:

print(“%i is perfect number “%n)

else:

print(“%i is not perfect number “%n)

Output:

Enter the number28

28 is perfect number

## 6.Write a program to find Armstrong Numbers in an interval(1 to 1000).

for n in range(1,1001):

p=n

sum=0

while p>0:

x=int(p%10)

sum=sum+x*x*x

p=int(p/10)

if sum==n:

print(n)

Output:

1

153

370

371

407

## 7.Write a program to print following Output:

****

****

****

****

i=1

while i<=4:

j=1

while j<=4:

print(“*”,end=”)

j=j+1

print()

i=i+1

Output:

****

****

****

****

## 8.Write a program to print following Output:

*

**

***

****

i=1

while i<=4:

j=1

while j<=i:

print(“*”,end=”)

j=j+1

print()

i=i+1

Output:

*

**

***

****

1. ## Write a program to print following Output:

*

**

***

****

i=1

while i<=4:

k=4

while k>i:

print(‘ ‘,end=”)

k=k-1

j=1

while j<=i:

print(“*”,end=”)

j=j+1

print()

i=i+1

Output:

*

**

***

****

## 10.Write a program to print 1 to 10 multiplication table.

i=1

while i<=10:

j=1

while j<=10:

print(i*j ,end=’\t’)

j=j+1

print()

i=i+1

Output:

1 2 3 4 5 6 7 8 9 10

2 4 6 8 10 12 14 16 18 20

3 6 9 12 15 18 21 24 27 30

4 8 12 16 20 24 28 32 36 40

5 10 15 20 25 30 35 40 45 50

6 12 18 24 30 36 42 48 54 60

7 14 21 28 35 42 49 56 63 70

8 16 24 32 40 48 56 64 72 80

9 18 27 36 45 54 63 72 81 90

10 20 30 40 50 60 70 80 90 100

Python has garnered worldwide attention and has surpassed the popularity margin which has made Python a high-level, object-oriented, interpreted & the most sought-after programming language. Python classes in Pune, deliver this dynamic programming language in an easy & simplified way to the learners.

## Why is Python preferred for development?

In the interview point of view, if an interviewer asked you “What is Python?”, then the generalized answer can be, “Python is an object-oriented programming language which works with its simplicity, powerful-libraries and readability” for newbies.

Python is a premier, flexible, and powerful open-source language with some powerful libraries for data manipulation & analysis. Python is used in highly featured quantitative domains such as finance, oil, gas, medicine, electronics, IT, signal processing and more. Python provides the features listed below.

• Simplicity
• Portability
• Embeddable & extensible
• Interpreted
• The huge number of libraries
• Object-oriented

LotusITHub’s Python training institute in Pune focuses on fundamentals of Python along with the Statistics and Machine Learning that helps to gain expertise in applied Data Science at scale using Python. The training includes coaching with several activities, assignments, and scenarios that are practical experience in addressing predictive modelling problems.

LotuITHub’s Python course will cover both basic and advanced concepts of Python that starts from Python scripts, sequence, file operations and more which uses libraries like pandas, NumPy, matplotlib, scikit, and master.

## The objective of Python coaching classes

Python is considered as a “Next Big Thing” for the professionals in the data analytics domain. It runs on Windows, Linux/Unix, Mac OS & cuts development time in half with its simple to read syntax and easy compilation feature.

• Programmatically download & analyze data with visualization
• Python deals with the ordinal, categorical, and encoding techniques for different types of data
• Python functions to facilitate code reuse with the core Python scripting elements such as variables and flow control structures.
• Real-time data processing with tools & techniques for predictive modelling in order to gain expertise to handle business in future.

## Why Python?

Python is one of the most popular languages and easier to code & understand. It works as a bridge between businesses and developers to bring a program in a market as compared to other languages such as C#, Java, etc. At Python classes in Pune, you will understand how all types of application can build on Python starting from analytical to UI. Python applications are quicker to implement as there is no need to declare variable types.

## How does Python work?

Following are the key interpreters that translate the high-level Python language to low-level machine language.

Variables

Variables can be object types and scope which can be used to hold user inputs, local states, etc. Variables have defined names with which it is referred into the code.

Python supports the following standard data types viz; numbers, strings, sets, lists, tuples and dictionaries.

Assign the value to the variable

Declare & assign value to a variable which is known as binding in Python

Assignment sets a value to a variable:

myFirstVariable = 1

mySecondVariable = 2

myFirstVariable = “Hello You”

Data types are dynamically typed in python.

Numeric

It supports Integers, decimals, floats are supported.

value = 1 #integer

value = 1.2 #float with a floating point

Strings

It is a sequence of letters enclosed in quotation marks and once they are created, cannot be changed.

a = ‘me’

a=’y’ It will show Error

Operations

It allows to perform computation on variables as Python supports *, /, +, -, and floor division

1//3 #returns 0

1/3 #returns 0.333

Following are the Modulus operators

• String Operations
• Casting
• Set Operations
• Ternary Operator

Comments

There two types of comments, single line comment & multiline comment

Single-Line Comments

#this is a single line comment

Multiple Line Comments

One can use:

“`this is a multi

line

comment“`

Expressions

Boolean operations can be performed with Expressions

• Equality: ==
• Not Equal: !=
• Greater: >
• Less: <
• Greater Or Equal >=
• Less Or Equal <=

Pickling

Conversion of the object into string & using it into a file is known as pickling & the reverse of it is called as unpickling.

Functions

Executable sequence statements from the code are known as functions, moreover, repeatable code creates a reusable function.

Modules

A component that groups a similar functionality of python solution and provides the concept to share data and services called modules. Modules reduce the variable name clashes and encourage re-usability.

Packages

A directory of modules is called a package in the python large number of functionalities are grouped into the module files to create a package to distribute and manage modules.

The lotusITHub’s Python course includes the basic and step-by-step thorough understanding of the language. However, Python programming certification course enables you to learn data science concepts from scratch. Click on www.lotusithub.com to know more or visit our Python institute in Pune at Karve Nagar, Kothrud, Dhayari, Warje, and Narhe to attend the FREE demo session.

© 2021 Lotus It hub

Theme by Anders NorénUp ↑