Top 100 Product Based Companies in India.pdf
408.8 KB
Document from Itsmekriish
On dividing a number by 56, we get 29 as remainder. On dividing the same number by 8, what will be the remainder ?
4 5 6 7
4 5 6 7
Anonymous Quiz
0%
4
33%
5
33%
6
33%
7
Which one of the following is the common factor of (4743 + 4343) and (4747 + 4347) ?
Anonymous Quiz
0%
(47 - 43)
50%
(47 + 43)
50%
(4743 + 4343)
0%
None of these
Which one of the following can't be the square of natural number ?
Anonymous Quiz
33%
32761
0%
81225
33%
42437
0%
20164
33%
None of these
What are local variables and global variables in Python?
Entry
Global Variables: Variables declared outside a function or in a global space are called global variables. These variables can be accessed by any function in the program.
Local Variables: Any variable declared inside a function is known as a local variable. This variable is present in the local space and not in the global space.
Entry
Global Variables: Variables declared outside a function or in a global space are called global variables. These variables can be accessed by any function in the program.
Local Variables: Any variable declared inside a function is known as a local variable. This variable is present in the local space and not in the global space.
When to use a tuple vs list vs dictionary in Python?
Entry
Use a tuple to store a sequence of items that will not change.
Use a list to store a sequence of items that may change.
Use a dictionary when you want to associate pairs of two items.
Entry
Use a tuple to store a sequence of items that will not change.
Use a list to store a sequence of items that may change.
Use a dictionary when you want to associate pairs of two items.
Explain some benefits of Python
Entry
Python is a dynamic-typed language. It means that you don’t need to mention the data type of variables during their declaration.
Python supports object-orientated programming as you can define classes along with the composition and inheritance.
Functions in Python are like first-class objects. It suggests you can assign them to variables, return from other methods and pass them as arguments.
Developing using Python is quick but running it is often slower than compiled languages.
Python has several usages like web-based applications, test automation, data modeling, big data analytics, and much more.
Entry
Python is a dynamic-typed language. It means that you don’t need to mention the data type of variables during their declaration.
Python supports object-orientated programming as you can define classes along with the composition and inheritance.
Functions in Python are like first-class objects. It suggests you can assign them to variables, return from other methods and pass them as arguments.
Developing using Python is quick but running it is often slower than compiled languages.
Python has several usages like web-based applications, test automation, data modeling, big data analytics, and much more.
What is Lambda Functions in Python?
Junior
A Lambda Function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression.
Consider:
x = lambda a : a + 10
print(x(5)) # Output: 15
Junior
A Lambda Function is a small anonymous function. A lambda function can take any number of arguments, but can only have one expression.
Consider:
x = lambda a : a + 10
print(x(5)) # Output: 15
How do I modify a string in python?
Junior
You can’t because strings are immutable in python. In most situations, you should simply construct a new string from the various parts you want to assemble it from. Work with them as lists; turn them into strings only when needed.
>>> s = list("Hello zorld")
>>> s
['H', 'e', 'l', 'l', 'o', ' ', 'z', 'o', 'r', 'l', 'd']
>>> s[6] = 'W'
>>> s
['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']
>>> "".join(s)
'Hello World'
Junior
You can’t because strings are immutable in python. In most situations, you should simply construct a new string from the various parts you want to assemble it from. Work with them as lists; turn them into strings only when needed.
>>> s = list("Hello zorld")
>>> s
['H', 'e', 'l', 'l', 'o', ' ', 'z', 'o', 'r', 'l', 'd']
>>> s[6] = 'W'
>>> s
['H', 'e', 'l', 'l', 'o', ' ', 'W', 'o', 'r', 'l', 'd']
>>> "".join(s)
'Hello World'
What is a Negative Index in Python?
Junior
Negative numbers mean that you count from the right instead of the left. So, list[-1] refers to the last element, list[-2] is the second-last, and so on.
Junior
Negative numbers mean that you count from the right instead of the left. So, list[-1] refers to the last element, list[-2] is the second-last, and so on.
How the string does get converted to a number?
Junior
To convert the string into a number the built-in functions are used like int() a constructor. It is a data type that is used like int (‘1’) == 1.
float() is also used to show the number in the format as float(‘1’) = 1.
The number by default are interpreted as a decimal and if it is represented by int(‘0x1’) then it gives an error as ValueError. In this the int(string,base) the function takes the parameter to convert string to number in this the process will be like int(‘0x1’,16) == 16. If the base parameter is defined as 0 then it is indicated by octal and 0x indicates it as a hexadecimal number.
There is function eval() that can be used to convert a string into number but it is a bit slower and present many security risks #python
Junior
To convert the string into a number the built-in functions are used like int() a constructor. It is a data type that is used like int (‘1’) == 1.
float() is also used to show the number in the format as float(‘1’) = 1.
The number by default are interpreted as a decimal and if it is represented by int(‘0x1’) then it gives an error as ValueError. In this the int(string,base) the function takes the parameter to convert string to number in this the process will be like int(‘0x1’,16) == 16. If the base parameter is defined as 0 then it is indicated by octal and 0x indicates it as a hexadecimal number.
There is function eval() that can be used to convert a string into number but it is a bit slower and present many security risks #python
#printing numbers right triangle shape in column wise
num = int(input("number of rows: "))
for row in range(num):
val = row + 1
dec = num - 1
for col in range(row+1):
print(format(val,"<4"),end=" ")
val = val + dec
dec = dec - 1
print()
num = int(input("number of rows: "))
for row in range(num):
val = row + 1
dec = num - 1
for col in range(row+1):
print(format(val,"<4"),end=" ")
val = val + dec
dec = dec - 1
print()
#Reverse floyd's Triangle
n = int(input("nunber of rows: "))
k = 0
for i in range(n):
k = k + i
m = n + k
for i in range(n):
for j in range(i+1):
print(m,end=" ")
m = m - 1
print()
n = int(input("nunber of rows: "))
k = 0
for i in range(n):
k = k + i
m = n + k
for i in range(n):
for j in range(i+1):
print(m,end=" ")
m = m - 1
print()
num = int(input("enter the number of rows: "))
k = 0
for i in range(num):
m = num + k
for j in range(i+1):
print(m,end=" ")
m = m-1
print()
k = 0
for i in range(num):
m = num + k
for j in range(i+1):
print(m,end=" ")
m = m-1
print()
#right angle triangle shape
num = int(input("enter the number of rows: "))
for i in range(num):
for j in range(i+1):
print(format("*","<4"),end=" ")
print()
num = int(input("enter the number of rows: "))
for i in range(num):
for j in range(i+1):
print(format("*","<4"),end=" ")
print()
Number system
1. natural number : 1,2,3,4,5......... infinity.
2. whole numbers : 0,1,2,3,4,5,
.... infinity.
3. intergers : -infinity..........-3,-2,-1,0,1,2,3,...... infinity.
4.even number : the number which are divisible by 2 are called even number. ex: 0,2,4,6,8,10... infinity.
5.odd number : the number which are not divisible by 2 are called odd number. ex: 1,3,5,7,9,11,13,15...... infinity.
6. prime number : the number which have exactly two factors that means one factor and itself are called prime number ex: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97..... infinity. 1 to 100 number between 25 prime numbers
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
8. compiste number : more than two factors are called compiste numbers
ex: The composite numbers 1 to 100 are 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 21, 20, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 56, 55, 57, 58, 60, 63, 62, 64, 65, 66, 69,68, 70, 72, 75, 74, 76, 78, 77, 80, Except for these, all other numbers are prime numbers.
9. non compiste numbers:
{0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, ...}
note :
1 + prime numbers = non composite numbers
1 + composite numbers = non prime numbers
11. real numbers
a) rational numbers : exact value
ex: 1, 2, 5/2, √9, 4/2...
b) irrational numbers: approximately value
ex: √2, 0.565656565655....
40/6,......
1. natural number : 1,2,3,4,5......... infinity.
2. whole numbers : 0,1,2,3,4,5,
.... infinity.
3. intergers : -infinity..........-3,-2,-1,0,1,2,3,...... infinity.
4.even number : the number which are divisible by 2 are called even number. ex: 0,2,4,6,8,10... infinity.
5.odd number : the number which are not divisible by 2 are called odd number. ex: 1,3,5,7,9,11,13,15...... infinity.
6. prime number : the number which have exactly two factors that means one factor and itself are called prime number ex: 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97..... infinity. 1 to 100 number between 25 prime numbers
2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97
8. compiste number : more than two factors are called compiste numbers
ex: The composite numbers 1 to 100 are 4, 6, 8, 9, 10, 12, 14, 15, 16, 18, 21, 20, 22, 24, 25, 26, 27, 28, 30, 32, 33, 34, 35, 36, 38, 39, 40, 42, 44, 45, 46, 48, 49, 50, 51, 52, 54, 56, 55, 57, 58, 60, 63, 62, 64, 65, 66, 69,68, 70, 72, 75, 74, 76, 78, 77, 80, Except for these, all other numbers are prime numbers.
9. non compiste numbers:
{0, 1, 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97, 101, 103, 107, 109, 113, 127, 131, 137, 139, 149, 151, 157, 163, 167, ...}
note :
1 + prime numbers = non composite numbers
1 + composite numbers = non prime numbers
11. real numbers
a) rational numbers : exact value
ex: 1, 2, 5/2, √9, 4/2...
b) irrational numbers: approximately value
ex: √2, 0.565656565655....
40/6,......