Test Paper 1
Test Paper 1
GIT:
1) Write a command to revert a commit that has already been pushed and made public.
Answer-1 : git revert <commit-id>
We can get commit id from git log.
3) Suppose one of your teammates accidentally deleted a branch and pushed the changes to the
central git repo. There are no other git repos, and none of your teammates had a local copy. How
would you recover this branch? Write the steps of commands.
Answer-3 git reflog delete-branch-name
Git checkout -b <new-branch> <commit-id-deleted>
Git add .
Git commit -m “”
Git push origin master
5) What is a merge conflict in git and how can it be resolved? Write the appropriate commands.
Answer-5 : merge conflict is conflict occur because of changes in a file where one of the branch contents
got modified.
It can be resolved while keeping the desired content and removing the unwanted one.
File get open like >>> and <<<<. Keep the desired changes.
git add <filename>
git commit -m “commit message”
git push origin master
git merge or can share the PR who has merge access.
PYTHON:
6) Write a function named 'format_number' that takes a non-negative number as its only parameter.
Your function should convert the number to a string and add commas as a thousand separators. For
example, calling format_number(1000000) should return "1,000,000".
Answer6-
n=Int(“input number”)
String(n)
If n>0
def format_number(num):
if num<0:
print(“error”)
else:
num1=str(num)
temp_list=[]
temp_list2=[]
for I in range(len(num1)):
temp_list.append(i)
for j in range(0,len(temp_list),-3):
temp_list2.insert(i,”,”)
return temp_list2
7) Write a function in Python to parse a string such that it accepts a parameter- an encoded string. This
encoded string will contain a first name, last name, and an id. You can separate the values in the
string by any number of zeros. The id will not contain any zeros. The function should return a Python
dictionary with the first name, last name, and id values. For example, if the input would be
"John000Doe000123".
Then the function should return: { "first_name": "John", "last_name": "Doe", "id": "123" }
Answer-7 : Input_string="John000Doe000123"
def parse_string(input_string):
print (input_string)
temp_list=[]
list_out=input_string.split(0) [john,,,]
for i in range(len(list_out)):
if i !=’’:
temp_list.append()
return {“first_name” : temp_list[0], “last_name”: temp_list[1], “id”: temp_list[-1]}
JENKINS:
a) Check the official website to check the perquisites and follow the instruction.
c) Install the Jenkins using yum or apt-get depends on linux flavor or can be install using binary.
Multiple Choice Questions
a) git new
b) git create
c) git start
d) git init
a) Configuration files
b) Source code
c) Project documentation
4. How do you view the differences between the working directory and the last commit?
a) git view
b) git diff
c) git changes
d) git compare
Answer-4: b) git diff
5. Which variable contains the directory which contains logs, jobs, users and other configurations
of jenkins?
a) HOME_JENKINS
b) HOME
c) JENKINS
d) JENKINS_HOME
Answer-5 : d) JENKINS_HOME
a) stage { }
b) pipeline { }
c) node { }
d) step { }
answer-7 : b-pipeline{}
a) dlroW olleH
b) Hello Worl
c) d
d) Error
Answer-8: a) dlroW olleH – also depends on python interpretor using print() in python3
L = ['a','b','c','d']
print("".join(L))
a) Error
b) None
c) abcd
d) [‘a’,’b’,’c’,’d’]
Answer-9: c-abcd
10. Suppose list1 is [3, 4, 5, 20, 5, 25, 1, 3], what is list1 after list1.pop(1)?
def
self._radius = radius
@property
def radius(self):
return self._radius
@radius.setter
self._radius = value
Which of the following statements about the Circle class are true? (Select all that apply.)