Python Assignment 1
Python Assignment 1
Ans:2 Python is called a dynamically typed language because type of the variable is
determined only during runtime. It stores that value at some memory location and
then binds that variable name to that memory container.
1.Python has extensive libraries which can be used for developing websites and
software, data analysis, and data visualization
2.It is easy to use and has increased productivity.
3.It is Easily Portable
1.Data Engineering
2.Data Science
3.Data Analytics
4.Web Development
5.Scientific programming
6.GUI Interface
7.Gaming
Ans:5 Variables are specific name given to memory location where the values are
stored.
Ans:7 String(str)
Asn:8 Converting one data type to another data type is type casting.
Ans:9 By Default, input() cannot take multiple inputs because type of input() is
str as it is depends on packing and unpacking
Ans:10 Keywords are predefined words or reserved words in python and It is case
sensitive
Ans:12 Indentation refers to spaces which defines a block of code. The code
block(body of a function,loops etc) starts with identation and ends
with the first unintended line.
Example:
for i in range(10):
print(i)
Ans:14 Operators are special symbols in python that carry out arithmetic or
logical computations.The value that the operator operates on is called operand.
Operator Types:
1)Arithmetic Operators.
2)Relational Operators.
3)Boolean Operators.
4)Bitwise Operators.
5)Assignement Operators.
6)Special Opeartors(Identity Operator and Membership
Operator)
Ans:15 1. (Float Divison): This operator divides left operand with right operand
and gives the result value in floating values if present.
Eg: 5/2 = 2.5
2.(Integer Divison): This operator divides left operand with right operand
and gives the near lowest whole number Eg: 5//2 = 2
Ans:16 #Code#
print("iNeuron"*4)
Ans:17 #Code#
num = int(input("Enter the no.: "))
if num%2 == 0:
print("It is even no.")
else:
print("It is odd no.")
Ans:20 Conditional statement are also called as Decision Statements which is used
to execute certain set of statements based on specified condtion.
1)if
2)if-else
3)elif
4)nested if
Ans:21 If: the program evaluates the condition and will execute statements only if
given condition is True.
Elif: Elif keyword executes multiple conditions by including one or more check
after if keyword is executed.
Else: Else keyword provides the output if (If) condition is False. Syntax: if
(Condtion): statement else: statement
Ans22: #Code#
Ans23: #Code#
Ans24: #Code#
Ans25:
- The number must be divisible by five:-
#Code#
numbers = [12, 75, 150, 180, 145, 525, 50]
for items in numbers:
if items%5 == 0:
print(items)
- If the number is greater than 150, then skip it and move to the next number:-
#Code#
numbers = [12, 75, 150, 180, 145, 525, 50]
for items in numbers:
if items<150:
print(items)
- If the number is greater than 500, then stop the loop:-
#Code#
numbers = [12, 75, 150, 180, 145, 525, 50]
for items in numbers:
if items>500:
break
else:
print(items)