-
Notifications
You must be signed in to change notification settings - Fork 133
/
Copy pathQuestions.txt
418 lines (317 loc) · 14.1 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
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
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
# This will not only boost your conviction but also will be helpful to answer them quickly. The questions will mainly cover subjects like arrays, string, linked list, and so on.
For every beginner, it is easy to start reading programming books and gaining theoretical knowledge. But what’s the next?
No one has become the programmer by reading the books. You should actually do the programming.
Q #1) How can you reverse a string?
#include <stdio.h>
#include <string.h>
int main()
{
char str[40];
printf (" \n Enter a string to be reversed: ");
scanf ("%s", str);
printf (" \n After the reverse of a string: %s ", strrev(str));
return 0;
}
Q #2) What is a palindrome string?
- A string is said to be palindrome if it reads the same backward as forward.
Q #3) How to calculate the number of vowels and consonants in a string?
#include <string.h>
int main()
{
char s[1000];
int i,vowels=0,consonants=0;
printf("Enter the string : ");
gets(s);
for(i=0;s[i];i++)
{
if((s[i]>=65 && s[i]<=90)|| (s[i]>=97 && s[i]<=122))
{
if(s[i]=='a'|| s[i]=='e'||s[i]=='i'||s[i]=='o'||s[i]=='u'||s[i]=='A'||s[i]=='E'||s[i]=='I'||s[i]=='O' ||s[i]=='U')
vowels++;
else
consonants++;
}
}
printf("vowels = %d\n",vowels);
printf("consonants = %d\n",consonants);
return 0;
}
Q #4) Print all the elements in the Fibonacci number series.
This program can be implemented using a loop or recursion technique.
Q #5) Write a program to calculate Circle Area using radius.
#include <stdio.h>
int main()
{
int circle_radius;
float PI_VALUE=3.14, circle_area, circle_circumf;
printf("\nEnter radius of circle: ");
scanf("%d",&circle_radius);
circle_area = PI_VALUE * circle_radius * circle_radius;
printf("\nArea of circle is: %f",circle_area);
return(0);
}
Q #6) Write a program that will read a float type value from the keyboard and print the following output.
1) the smallest integer which is not less than the number
2) given number
3) the largest integer which is not greater than the number
#include <stdio.h>
int main()
{
float n;
printf("enter the float value\n");
scanf("%f",&n);
printf("the smallest integer which is not less than the number is %d\n",(int)(n)+1);
printf("given number is %f",n);
printf("the largest integer which is not greater than the number is %d",(int)(n));
}
Q #7) Write a program to find the sum of all integers greater than 150 and less than 290 that are divisible by 3?
sum = 0
for i in range(151, 289):
if i % 3 == 0:
sum += i
Q #8) Write a program to convert given the number of days into months and days. (For the sake of simplicity, Assume that each month contains 30 days?
#include <stdio.h>
int main(){
int n;
printf("enter the number of days");
scanf("%d",&n);
printf("no. of months is %d\n",n/30);
printf("no. of days is %d",n%30);
return 0;
}
Q #9) Print the Triangle as follow, using for loops. 1 2 3 4 5 6 7 8 9 10 … N?
Q #10) Take the students Mark as User input and check the range of Mark. (Java) ?
Programming is a skill best acquired by Practice and Example rather than from Books.
------------------------------------------------------------------
Q36: Write a code to print daimond pattern in any langauge.
Ans:
// Code to print diamond pattern in C langauge
#include <stdio.h>
int main()
{
int n, c, k;
printf("Enter number of rows\n");
scanf("%d", &n);
for (k = 1; k <= n; k++)
{
for (c = 1; c <= n-k; c++)
printf(" ");
for (c = 1; c <= 2*k-1; c++)
printf("*");
printf("\n");
}
for (k = 1; k <= n - 1; k++)
{
for (c = 1; c <= k; c++)
printf(" ");
for (c = 1 ; c <= 2*(n-k)-1; c++)
printf("*");
printf("\n");
}
return 0;
}
------------------------------EOC---------------------------
// I am commiting for first time
System.out.println(" I am commiting for first time")
Q37: What is a database?
Ans:
A database is just an organized collection of data stored and accessed electronically. Small databases can be stored on a file system, while large databases are hosted on computer clusters or cloud storage.
Q38: What’s the difference between HTML, HTML5, CSS and CSS3?
Q39: What is the difference between front-end and back-end development?
Q40: What is an API?