forked from Samiullah-Kalhoro/hacktoberfest_21
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathQuestions.txt
248 lines (196 loc) · 9.48 KB
/
Questions.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
In this Text file please ONLY answer the following questions to contribute to Hacktoberfest 2021 and to make a Pull Request.
Note: These are very easy questions and for beginners in Open source community.
Q1: How to add a comment in java?
A: //This is a comment
Q2: How to add a comment in Python?
A: #this is how you add comments in Python.
Q3: How to add a multi-line comment in python?
A: """ This is how we can add
Multi-line comments
in python"""
Q4: print hello world in Python
A: print("Hello World")
Q5: print hello world in java
A: System.out.print("Hello World");
Q6: print hello world in javascript using console.log
A: console.log(“hello world”);
Q7: Add a readme in this repository for the steps to make a PR.
A: Added
Q8: What are HTML & CSS?
A: HTML is a markup language,
CSS is a styling language.
Q9: What’s an algorithm?
A: A process or set of rules to be followed in calculations or other problem-solving operations, especially by a computer.
Q10: What is flowchart?
A: A flowchart is simply a graphical representation of steps. It shows steps in sequential order and is widely used in presenting the flow of algorithms, workflow or processes. Typically, a flowchart shows the steps as boxes of various kinds, and their order by connecting them with arrows.
Q11: What are variables?
A:variables are symbolic name for information, information contained by variables is represented by name of the variables.
Q12: What are loops?
A: Loops are sequence of instructions that is continually repeated until a certain condition is reached.
Q13: Compiler vs Interpreter?
A: Interpreter translates just one statement of the program at a time into machine code. Whereas, compiler scans the entire program and translates the whole of it into machine code at once.
Q14: What is Machine Code?
A: Machine code (MC) is the executable instruction code provided by all running computer system programs and applications. MC language is a low-level code interpreted and converted from high-level source code and understood only by the machine.
Q15: Name some HTML tags
A: <!DOCTYPE> , <html> , <head>, <title>, <body>, <p>, <br>, <footer>
Q16: What are ternary operators? Write syntax.
A: The ternary operator is employed to execute code supported the results of a binary condition. It takes during a binary condition as input, which makes it almost like an 'if-else' control flow block. It also, however, returns a worth , behaving almost like a function.
Syntax: result = binaryCondition ? valueReturnedIfTrue : valueReturnedIfFalse;
Q17: What are jumping statements? Name them.
A:Jump statements are used to alter the flow of loop when you want to skip a part of the loop or want to terminate the loop
in other words they transfer the program execution control to specific statements
jump statements are:
1 goto
2 continue
3 return
Q18: How many types of operator are there?Name them.
A:There are 8types of operator .
1. Unary . eg: expr++ , expr--
2. Arithmetic . eg: * , / , % , + , -
3. Shift . eg: << , >> , >>>
4. Relational . eg: == , !=
5. Bitwise . eg: & , ^ ,|
6. Logical . eg: && , || , ? :
7. Ternary . eg: ? :
8. Assignment . eg: = , += , -= , *= , /= , %= , &= , ^= , |= , <<= , >>= , >>>=
Q19: Difference between / and // in python language.
A: / is Float Division eturns a floating point approximation of the result of a division. For eg : 1/3 = 0.333333333
// is Integer division returns the floor of the division. For eg : 1//3 = 0
Q20: Input a number n using C .
A:scanf("%d",&n);
Q21: A macro can execute faster than a function.Is this statement true or false?
A: TRUE, Because in function, much of time is used to take control from function call to called function and much of time is spent in this process,
Whereas in macro expression are directly replaced in the source code.
Q22: The prototype of a function can be used to perform what on function
A: It is used to perform type checking on function calls.
Q23: Which library function can convert an integer/long to a string?
A:In java,we can use:
Integer.toString(variable)
Q24: What is "JVM" in java programming language?
A: "JVM" stands for java virtual machine.Java virtual machine is an abstract machine and is a part of the JRE(Java Runtime Enviroment).It enables a computer to run java programs as well as programs written in any other languages.In other programming languages,the compiler produces a machine code for a particular system but in java JVM converts java byte code into machine language.
Q25: Is Python the Future of Programming?
Ans: Python will be the language of the future. Testers will have to upgrade their skills and learn these languages to tame the AI and ML tools.
The python language has managed to exceed other languages.
Thus, it has an extensive set of prospects that can be taken care of, in upcoming years. There are various companies that are majorly dependent on python language developers to boost user experience.
Q26 : Write pseudo codes for following: a.Binary Search , b.Bubble Sort, c. Pallindrome number.
Ans : a. Binary Search
int a[n],low,mid,high,key; //a[n] is array of length n
low=0;
high=n-1;
while(low + high)/2;
{
mid=(low + high)/2;
if(a[mid]==key) //key is element to search
{
printf("element %d is found at %d position:",key,mid+1);
exit(o);
}
else if(a[mid]>key)
high=mid-1;
else
low=mid+1;
}
print("UNSUCCESSFULL SEARCH\n");
return 0;
}
b.Bubble Sort
int i,j,a[n],temp;
for(i=0;i<n;i++) // number of passes
{
for(j=0;j<n-i-1;j++) //comparision
{
if(a[j] > a[j+1]) //swap
{
temp = a[j];
a[j] = a[j+1];
a[j+1] = temp;
}
}
//the array is sorted
c. Pallindrome number
int n,rev=0,num,remainder; // rev is for reversing the number
scanf("%d",&num); //enter the number
n=num;
while(num !=0)
{
remainder = num %10;
num=num/10;
rev= rev*10 + remainder; //reversing the number
}
if(rev==n) //comparing the reversed number to the original number
//if rev is equal to n the number is pallindrome
Q27 : How to print the A-ABA-ABCBA-ABCDCBA Pattern in Python?
Ans : row = int(input("Enter The Number of Row: "))
alphabet = 65
i = 0
while(i < row):
j = row - 1
while(j>i):
print(" ", end="")
j -= 1
k = 0
while(k <= i):
print(chr(alphabet + k), end="")
k += 1
l = i-1
while(l >= 0 ):
print(chr(alphabet + l), end="")
l -= 1
print()
i += 1
Q28: Writing a code for Binary Search in C++?
Ans: #include <stdio.h>
int binarySearch(int arr[], int l, int r, int x)
{
while (l <= r) {
int m = l + (r - l) / 2;
if (arr[m] == x)
return m;
if (arr[m] < x)
l = m + 1;
else
r = m - 1;
}
return -1;
}
int main(void)
{
int n,i;
printf("Enter the size of array\n");
scanf("%d",&n);
int arr[n];
printf("Enter the sorted array\n");
for(i=0;i<n;i++)
{
scanf("%d",&arr[i]);
}
int x;
printf("Enter the element to be searched\n");
scanf("%d",&x);
int result = binarySearch(arr, 0, n - 1, x);
(result == -1) ? printf("Element is not present"
" in array")
: printf("Element is present at "
"index %d",result);
return 0;
}
Q29: Writing a program to print multiples of 2 in Python?
Ans: #Python program to print all multiples of 2 till 20
# Using range with three parameters
for i in range(2,21,2):
print(i, end =" ")
print()
// Adding practical test questions that nobody asked :p
Q30: Python library to analyze data= Pandas
Q31: Weka full form: Waikato Environment for Knowledge Analysis
Q32: Numpy full form: Numerical Python
Q34: 3 types of ML: Supervised, unsupervised and reinforcement ML
Q35: How to open , read and write file in python (File Handling)?
Ans: for opening :
rd_file = open("file.txt") #just copy paste the file address where it is located file->properties->location
for reading :
print(rd_file.read())
for writing :
rd_file = open("file.txt")
rd_file.write("Hey, I am enjoying this !! " , a) #a,append to the file, means not erase any data if file holds some
rd_file.close() #don't forget to close the file to perform other operations