Docker Question and Ans Part3

Q1. What can you tag your Docker Image ?

Answer: docker tag “ImageID” “Repository”:tag

List = ["a","i",20]
Tuples = ("a","i",20)

Q2. What are key features of Python.

Answer: Python is interpreted language, that means it doesn’t required to be compiled.( We can also say as which is not a machine level code before runtime) It can be used in Various Automation areas and AI technologies. It is easier to understand and write Language. Latest Version is 3

Q3. Give Examples of some famous modules in Python?

Answer: os, json, sys, math, random, math

Q4. What are local and global variables in Python ?

Answer: Local Variables are declared inside the function and scope is inside function only . Global Variable is the variable whose scope is for entire program.

Q5. What are functions in Python ?

Answer: This is a block of code which is only executed when called. You can declare using syntax def fun1() and you call it as func1()

Q6. What is __init__ ?

Answer: This is a method which automatically allocate memory when object or instance is created. All the Classes have __init__method.

Q7. What is Lambda function in Python and give us an example ?

Answer: This is also known as anonymous function which takes any number of parameter but is written in just a single statement.

square = lambda num: num ** 2

Q8. What is self in Python?

Answer: self is an instance or object of a class. This is used with __init__ function and is explicitly included as first parameter.

Q9. How can you Randomize the list in Python ?

Answer: from random import shuffle

from random import shuffle
list = ["a" , "b" , "c" ,"d", "e"] 
shuffle(list)
print(list)

Q10.What does *args and *Kargs mean ?

Answer: We use these *args when we are not sure about the number of arguments we need to pass in a function. Similarly * Kargs are keyword arguments where we dont know how many will be required (They are in dictionary formats)

Q11. Does Python Supports OOPs concept?

Answer: Yes , Python does support OOPs concept by creating classes and objects . Backends determines where state is stored or loaded from. By default we have local backend but we can give remote backed such as S3

Q12. Name some Python Libraries ?

Answer: Python libraries are collection of Python Packages . For Example Pandas, Numpy.

Q13. What are various ways to import the modules in python

Answer:

import math

import math as mathes ( Alias name )

from flask import Flask

Q14. What is Flask?

Answer: A Framework is Code library which makes life of developer easy by reusing the code , extensions for operation to build a reliable , scalable and maintainable web apps. There are different Python Web frameworks such as FLASK , TORNADO, PYRAMID and DJANGO .

Q15. How can we open a file in Python?

Answer: with open(“myfile.txt”, “r”) as newfile:

Q16. How can you see statistics of file located in directory?

Answer:

import os

os.stat(“file_name”) # These stats include st_mode, the file type and permissions, and st_atime, the time the item was last accessed.

Q17. How do you define method and URL Bindings in Python Flask?

Answer: @app.route(“/login”, methods = [“POST”])

Q18. How does Python Flask gets executed in Python ?

Answer:

if __name__ == ‘__main__’

app.run(debug = True)

Q19. Which built in function evaluates expression and return Boolean result ?

Answer: can .

Q20. How can you make Python Script executable in Unix ?

Answer: Define the Path of Python interpretor #/usr/local/bin/python & make script executable chmod +x abc.py and then run python abc.py