Posts

10 Blockchain Smart Contract Interview Questions

Image
Here are the top ten interview questions on Blockchain smart contracts. Here you will know about smart-contract, what language and IDE you need to develop. Useful for interviews as well. 1. What is a Smart Contract? A  smart contract  is an executable code on the blockchain intended to digitally facilitate, verify, validate, and enforce the rules and regulations of an application. Smart contracts allow the performance of credible transactions without third parties . These transactions are trackable and irreversible. 2. Where the smart Contract code resides? The smart contract is deployed in a sandbox environment and identified by a 160-bit account address like any other participants on the blockchain network. It executes on the virtual machine (VM) on the blockchain node and is identified by an account number. 3. Smart Contract is it API? Yes, it is like a class. It has methods. These are useful to process transactions in the Blockchain framework. 4. What are the six functions of Sma

How to Explain String Immutability in Python Correctly

Image
Strings in Python are immutable. That means you can't change the string. So you can use strings in many places of your project securely. How to Test a String is Immutable It's very simple. In Python shell, assign a string to a variable of your choice. Here my choice is myString. Assigned to 'ABCD'. >>> myString = 'ABCD' >>>myString [0] = 'Z' It gives an error. Since you have tried to replace 'A' with 'Z'. It's because the string is immutable. Unlock Key Points This is the ultimate interview question When they ask String is immutable, you need to say 'Yes' Show them the example that I showed above Here are the Hidden Benefits of Strings Immutable It saves a lot of time in fixing and unchanging the storage requirement times. This directly results in high performance. String objects can be reused, as they are safely stored without getting changed. Strings in Python are considered as elemental as numbers. None of

Python: Here are 3 Brilliant Methods to Execute

Image
You can run python commands in three methods. Those are at CLI, Python interface, and as a Script. How to Run Script at CLI? The script extension should be .py. Here is an example xyz.py. When the script is ready, the next step is to run it. How to run it from CLI?  Here is a command to run at CLI. Suppose you have installed Python in Linux OS. Then you need to give: $ python -m xyz.py Here, m means module. That means you are running a script with Python code. How to Run Commands at Script? The Other way, you can execute Python statements directly at CLI. Here's a command for your quick reference. $ python -c "print('Hello world')" Here, the print statement displays " Hello World " on the screen. How to Run commands at Python Interface? You know that the Python interface needs an operating system - Windows or Linux.  $ Python3 >>> 10 + 20 30 References Python Programming: Using Problem Solving Approach

Python Tuple: Here're 2 Ways to Calculate Sum Easily

Image
Python tuple is nothing but a set of data. It can have an 'n' number of elements. Here, in my example, the tuple has 20 Elements. The below logic helps you to calculate the sum of its 20 Elements easily.  A tuple is simply a set, and it can have both positive and negative Elements. So, don't worry. You can calculate the sum even the tuple has negative numbers. Here are 2 Ways You can calculate Sum Display sum after adding each element Display sum at once   Python Logic: #1 Method - The Print Displays Sum in Vertcle after Adding Each Element my_tuple = (1,20, -30, 50, 10, 11, 6, 7, 22, 88, 10, 20, 565, 121, 211, 5, 2, 18, 20, 21) sum = 0 for index in my_tuple:             sum = sum+ index          print("sum of elements:", sum) Note*** Here the print statement is within the For Loop. You May Also Like: How to Use For Loop  in Python Complete Tutorial Python Logic: #2 Method - The Print Displays Total Sum at once my_tuple = (1,20, -30, 50, 10, 11, 6, 7, 22, 88, 10

Python Dictionary: How to Make Subset Easily

Image
Here's an easy method to make a subset of a  Dictionary in Python. You already know that Dictionary has a format of Key, Value and enclosed in curling bracket. Below are ideas with sample logic and how it works. It is useful for your projects and interviews too. Here is a Dictionary my_first_dict = { 'HP' : 100 'IBM': 200 'NTT' : 300 'ABC' : 400 'GDF' : 500 } I want to make a subset. The values are greater than 100 and less than 400. How can you achieve this? Don't worry you can do this easily. I am sharing logic with you. Here is subset Logic: You Can do it Using Dictionary Comprehension Syntax: sub_set = { key:value for key, value in my_first_dict.items() value >100 and value <400} Result References Python Programming: Using Problem Solving Approach

Python Class: Here is Useful Reason to Pass Self

Image
Here is the top reason to pass the 'self' argument in the Python class function. You already know that the python class has two things. One is function and the other one is members.  Structure of a Class class <name of the class>:  def <function name>(<arguments>):  ...  <members> For example, the employee class having data members name and age and member functions getdata() and putdata() can be defined as below. Every function in the class must have at least one argument, self . The data members are accessed via the self object as they belong to the class and not just the function. Likewise, the putdata() function displays the values of the data members. Notes on Python Class A class definition has functions but can also have other members. The attribute of an object is a data attribute, and the function that belongs to an object is the method. Sample Python Class class employee:  def getdata(self):  self.name=input('Enter name\t:')  self.age=in

Python Abstract Classes to Learn Quickly

Image
Here's the best example of how to understand the abstract classes of python quickly. An abstract class means it is a skeleton. You cannot instantiate abstract classes. For Example: The abstract class name is 'dog' o = dog() It gives an error. Since the ' dog' is an abstract class. I am sharing with you a clear understanding of abstract class. So that you can tell confidently about these classes. The syntax for Abstract Class from abc , import ABC , abstractmethod  class <class name>(ABC): @abstractmethod  def <method name>():  #abstract class definition Python Abstract Class Explanation from abc import ABC, abstractmethod class AbsBaseClass(ABC): def __init__(self): print("Abstract class") @abstractmethod def abMeth(self): pass def conMeth(self): print("I'm a concrete method") class Derived(AbsBaseClass): def abMeth(self): print("I'm redefined") o=Derived() o.abMeth() o.conMeth() References Star Python Certification