0% found this document useful (0 votes)
18 views76 pages

New Coder Certification

The document contains a series of programming questions and tasks across various languages including Python, C++, Java, and JavaScript. It covers topics such as code optimization, script creation, class usage, error explanation, and data manipulation. Each question requires specific coding solutions or explanations related to programming concepts and practices.

Uploaded by

bevansamcy65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
18 views76 pages

New Coder Certification

The document contains a series of programming questions and tasks across various languages including Python, C++, Java, and JavaScript. It covers topics such as code optimization, script creation, class usage, error explanation, and data manipulation. Each question requires specific coding solutions or explanations related to programming concepts and practices.

Uploaded by

bevansamcy65
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

CS CERTIFICATION ANSWERS

Python
Qn1. Try to optimize the following code:
Qn2. Create a Bash script that allows the reading of the content of a .txt file and print each line.
Qn3. Write me a simple program explaining how classes work in C++
Qn4. Write a program in Java that concatenates a given string. Give me the code without comments or
docstrings.
Qn5. Write a function in python that prints a matrix in a spiral.
Qn6. refactor this c code snippet, don't use bool, and keep cls
Qn7. Please answer the following question. Question title: indexing an element from a volatile struct doesn't
work in C++.
I have this code:
Qn8 How can I filter a list of coordinates using Python list comprehension?
Qn9 I need a program in C++ that converts a binary number into a hexadecimal number. Allow an input entry
for the binary
number. Add comments to all the code.
Qn.10 Explain to me why I get this error message:
Exception in thread "main" java.lang.ArrayIndexOutOfBoundsException: Index 5 out of bounds for
length 5 at
ArrayClass.main(test2.java:4)When I tried to run the following code:
Qn11 how can i include 'en_core_web_lg' in a python script in a way, that makes it possible for 'pyinstaller' to
create an ",exe'
Qn12 What is the output in Python? Explain.Please answer the following question. Question title: indexing an
element from a volatile struct doesn't work in C++ Question
body: I have this code: typedef struct { int test; } SensorData_t; volatile SensorData_t
sensorData[10]; SensorData_t
getNextSensorData(int i) { SensorData_t data = sensorData[i]; return data; } int main(int argc, char **
argv) { } It compiles withgcc version 8.3, but not with g++. Error message: main.c: In function
'SensorData_t getNextSensorData(int)': main.c:8:34: error.no matching function for call to
'SensorData_t(volatile SensorData_t&)' SensorData_t data = sensorDatali]: ^ main.c:3:3: note:
candidate: "constexpr SensorData_t:SensorData_t(const SensorData_t&)" <near match> }
SensorData_t; ^main.c:3:3: note: conversion of argument 1 would be ill-formed: main.c:8:34: error:
binding reference of type 'constSensorData_t&' to 'volatile SensorData_t' discards qualifiers
SensorData_t data = sensorData[i];note: candidate: 'constexpr SensorData_t ::
SensorData_t(SensorData_t&&)" <near match> } SensorData_t; NNmain.c:3:3: note: conversion of
argument 1 would be ill-formed: main.c:8:34: error: cannot bind rvalue reference of
type'SensorData_t&&' to Ivalue of type 'volatile SensorData_t' SensorData_t data = sensorData[il:
I'm not sure if I need to addvolatile as well for the data variable and the return type, shouldn't be
needed because it is copied. But I do access thesensorData array from an interrupt as well (on an
embedded system), so I think I need volatile for the top level variablesensorData.NNNA
main.c:3:3:The output will be the same in both scenarios:
Qn13 Write a program in Java to compute the sum of two numbers that sum up to a given number K
Qn14 Write a JS/react component for showing a button that opens a popup and says "Hello, How are you?"
Qn15 Explain this code. Go step by step, explaining each line in detail:
Qn16. How do I use the `requests' package in Python to hit an endpoint and retry if there are failures?To
accomplish this, you can use the Session object provided by the 'requests' package. Here's a basic example:
Qn17 Please answer the following question. Question title: indexing an element from a volatile struct doesn't
work in C++ Question
body: I have this code: typedef struct ( int test; } SensorData_t; volatile SensorData_t
sensorData[10]; SensorData_tgetNextSensorData(int i) { SensorData_t data = sensorData[i]; return
data; } int main(int argc, char ** argv) { } It compiles withgcc version 8.3, but not with g++. Error
message: main.c: In function 'SensorData_t getNextSensorData(int)': main.c:8:34: error:no matching
function for call to 'SensorData_t(volatile SensorData_t&)' SensorData_t data = sensorData[i]: ^
main.c:3:3: note:candidate: "constexpr SensorData_t:SensorData_t(const SensorData_t&)" <near
match> } SensorData_t; NNmain.c:3:3: note: conversion of argument 1 would be ill-formed:
main.c:8:34: error: binding reference of type 'constSensorData_t&' to 'volatile SensorData_t discards
qualifiers SensorData_t data = sensorData[i]; N

note: candidate: 'constexpr SensorData_t :: SensorData_t(SensorData_t&&)" <near match> }


SensorData_t; ^Nmain.c:3:3: note: conversion of argument 1 would be ill-formed: main.c:8:34: error:
cannot bind rvalue reference of type'SensorData_t&&' to Ivalue of type 'volatile SensorData_t'
SensorData_t data = sensorData[i]: I'm not sure if I need to add

volatile as well for the data variable and the return type, shouldn't be needed because it is copied.
But I do access thesensorData array from an interrupt as well (on an embedded system), so I think I
need volatile for the top level variablesensorData.NNNA
qn18. What does the .find() method in Js do?
Qn19 I have a timeseriesdataframe and want to drop the last period of data for all items, how do I do this?
Qn20 Can you write a code in C++ that removes all the whitespace from a given string? Write the program
using classes andcomment on each part of the code.
Qn21 Write a generator to yield the Fibonacci numbers in Python.
22. I'm trying to initialize a list of points in python where the y coordinate is double the x
coordinate and the x coordinate is increasing from 0 to 5.
Please tell me what I'm doing wrong:
23. Why don't I need a try/catch here:

You might also like