- Setting up Python environment on windows
- Writing your first Python 3 Program
- Defining Functions in Python 3
- Using Modules in Python
- Lists in Python
- While loop in Python
- Defining a class in Python
- Working with files in Python
Useful WordPress settings
WordPress can be customised using number of settings.These are useful in different scenarios ,so it is useful to know about some of the important settings.
The dashboard provides number of useful actions.Some of the tasks which can be performed from the dashboard are:
- Create/Edit posts
- Create/Edit pages
- View Comments
- Change themes
- Add / Update plugins
- View users
- Manage WordPress settings
- Backup WordPress
If you login to the WordPress then you can view the dashboard:
One important part of the dashboard is the settings section.You can modify the different WordPress settings from here such as:
General settings These include settings such as URL,Tagline,Admin email address,Timezone.
Writing settings These include settings like Default post category
Reading Settings These include some useful settings such as
- Home page screen
- Maximum number of posts at a time
- Feed setting
The WP Settings plugin will help you view lots of useful settings in a single location.
Python interview questions and answers
What are the key features of Python?
Python is a object-oriented,open source programming language
It runs on different platforms like Windows, Linux,Macintosh etc.
It is easy to read as it has a clean syntax
It can be integrated with different languages such as Java,C,C++,C#.
function
A function is used to modularize application.Instead of defining application in a single module,application code is defined in different functions.
This helps to keep the application easier to maintain.After you have defined a function you can call it by using its name.
What is a function.How do you define a function?
You can define a function using the def keyword:
def FunctionName(): statements
to call the function you use:
FunctionName()
you can also define and pass parameters to the function:
def FunctionName(param1): statement block
Write to a file in python?
Python provides several functions for working with files.One of the most important functions is open.To open a file for reading:
f = open("file name")
or
f = open("file name",mode)
So to open a file for reading mode should be “r”:
f = open("fileName.txt","r")
if you want to append to an existing file:
f = open("fileName.txt","a+")
f.write("Append Data" )
Pass in python?
Sometimes when defining a class you don’t want to implement some of the methods.As you can not write any method without any statement so you can use pass
statement:
class ClassName(object): def method1(self): pass def method2(self): pass
Exception handling in Python?
You use the try and except keywords.If the code in try block throws any exception then it is handled by the matching except block.
try:
statement block
except exception1:
print("exception 1")
except exception2:
print("exception 2")
except exception3:
print("exception 3")
What is PEP 8?
It is a set of coding conventions for the Python code and defines things such as method names,variable names,exception names etc.
Explain the ternary operator in Python?
It specifies a boolean expression and returns one of the two values based on the value of the boolean expression
Following is a ternary operator which returns the value y.
x,y=1,2
num = x if x < y else y
What is the key difference between a list and the tuple?
Bothe list and tuple are containers of items but list is mutable while tuple is immutable
How does Python handle the memory management?
Memory management in Python is handled using Python memory manager.The Python memory manager consists of different components for different aspects of memory maangement such as:
- sharing
- segmentation
- preallocation
- caching
The user has no control over Python heap as it is performed by the the interpreter.
What is the “self” keyword in Python?
Self is a variable used in a class method which refers to the current instance of the class.
In the following example we are setting a variable called num in SimpleClass as 2.
class SimpleClass(object): num = 1 def set_num(self): self.num=2
What is NumPy?
- NumPy is a package for scientific computing with Python.It has features such as:
N-dimensional array - linear algebra, Fourier transform, and random number capabilities
Explain help() and dir() functions in Python?
- help() function provides information related to modules, keywords, attributes, etc.
- dir() returnd a list of attributes of the object.
Developing Windows IoT apps using Python in Visual Studio
You can develop windows IoT Core app in Python in Visual Studio.To develop app in visual studio 2017 first you need to add the Python IoT Support feature in Visual Studio
Install the Cpython for UWP from the following link
After it is installed you can create a new project in Visual Studio and Select Python –> IoT Core project template
Now we need to install Visual C++ Compiler from the below link:
install the packages from the Python environment node:
Now you can develop python apps in Visual Studio.
Following is a simple Python app:
import RPi.GPIO as GPIO
import time
GPIO.setmode(GPIO.BCM)
GPIO.setup(16, GPIO.IN)
if GPIO.input(16) == False: # you can also use 1/0 instead of true/false
print('I am pressing the button')
time.sleep(0.2)
Creating a simple Windows IoT App
Select C#–> Windows Universal template
In the next screen select target version.We will select past version since that is more stable:
In the new project select the reference node and right click
In the references window select Windows IoT Extensions for the UWP
After you add the reference ,it is visible in the references tab:
By default MainPage.xaml is added in the project.We can UI elements to the page from the toolbox(Ctrl+Alt+X).Select View–>Toolbox to select the toolbox:
We will add a textblock and button on the Page.
In the button click we will add simple logic to check if GPIO controller is present in the device.
private void Button_Click(object sender, RoutedEventArgs e)
{
var gpio = GpioController.GetDefault();
if (gpio == null)
{
txtGPIOStatus.Text = "There is no GPIO controller on this device.";
return;
}
else
{
txtGPIOStatus.Text = "There is GPIO controller in the device,you can use the GPIO pins. ";
}
}
Now you are ready to deploy your application to the remote IoT device.In the drop down select Remote Machine.
Right click the project and select deploy to deploy your application:













