This tutorial will show how to use variables from one Python file in another. The first step in using another Python file is to use the built in keyword import . Import is used to import Python libraries modules. Here is a List of useful keywords
When using import , the file being imported will be executed when the Python file importing it is ran.
For this example, there are two Python Files the first file is named Main.py and the file being imported is named Second.py
import Second #printing X var from Second print(Second.X)
In the Main.py file the Second file will be imported. Then the X variable from the will be printed out.
X= 5 try: # If X is Greater than 5 if X> 3: print("Greater Value") # X less than five else: print("Nope") # finally: print("Run Complete")
The Second file consist of a try statement that checks if the X variable is greater than 3.
Note: the finally will always run.
Greater Value Running 5
Android Studio Loading Animation Between Activities
Progress Dialog is dialog showing a progress indicator and an optional text message or view. The methods of Progress Dialog being used in this tutorial are: ProgressDialog.setTitle() – Used to set title of dialog box ProgressDialog.setMessage() – Used to set dialog message being displayed ProgressDialog.setProgressStyle() – Choose the style of indicator ProgressDialog.dismiss() – Dismiss the…
Android Studio Tutorial SeekBar
SeekBar is an extension of ProgressBar that adds a draggable thumb. The user can touch thumb and drag left or right to set the current progress level or various other task. In this example, the seekbar will be used to display a percentage. As the user moves the SeekBar left to right the percentage value…
Python Ethereum Block Chain Interaction with Web3
This tutorial will show how to interact with the Ethereum blockchain using Python. To start, the Python library Web3 will need to be installed. The Web3 library allows you to interact with a local or remote Ethereum node, using a HTTP or IPC connection. Using Web3 you will be able to create smart contracts on…
The chr() function returns a character that represents the specified unicode. Syntax chr(i) The chr() method takes only one integer as argument.The range may vary from 0 to 1,1141,111(0x10FFFF in base 16).The chr() method returns a character whose unicode point is num, an integer.If an integer is passed that is outside the range then the method returns…
The callable() method checks if a object is callable. Callable objects are True if object is callable and False if object is not callable. Syntax & Parameters callable(object) The callable() method takes one argument, an object and returns one of the two values: returns True, if the object appears to be callable.returns False, if the…
bytes() returns an immutable bytes object, made up of a sequence of integers in the range 0 <=x < 256. The returned bytes sequence is immutable. A mutable bytes sequence can be used instead by calling is bytearry() . Syntax bytes(]]) bytes() takes three optional parameters: source – initialize the array of bytes. Can be String…