Friday, October 4, 2019

Python IDEs and Code Editors - Basic Guide and Top picks

The hugely popular Programming language Python was developed in 1991 to code languages used for several purposes like:

Python IDE and Code editors - basic guide and top picks

  • Back end web and mobile app development
  • Desktop app 
  • Software development
  • To write system scripts

Python is the leader in the coding business because of its easy English syntax, easy to learn framework user-friendly interface. It is used for server web development, software development, and Artificial intelligence. Python works on many platforms and to know Python you should know more about the best Python code editors and IDE’s.

What is IDE and code editor?

IDE's or Integrated development environments are those programs that amalgamate the tools for writing and testing software, websites and mobile-based apps on its platform. They typically include:


  • Source code editor: This is a text editor that is used for editing programming languages.
  • Building tools for automation: To automate the software development process and reduce manual tasks.
  • Debugger: This is a tool that examines codes for errors and also aids to diagnose different problems. 



With IDE, one can also automate the work of developers which results in a significant reduction of manual work and therefore, errors caused due to it. It also facilitates the SDLC (software development life cycle) process further by reducing the time taken for development, testing and debugging.

But, if you have to write only the code, then why use the IDE platform? 

Instead, you can rely on less-resourced intensive code editors which can be written in plain text editors. Code editors are well equipped and have features specific to writing codes which can benefit your SDLC process and amp up the speed with a notable reduction in time, effort and errors.

We have handpicked top 10 python IDE’s and code editors to help you select the most ideal one suited for your project:

Idle –IDE

Idle is the best way to start for beginners. It has by default the installs of the language. Idle is great for beginners because it is light-weight and capable of doing many things. But with more complications, later on, Idle might not be the best fit. It is open source and comes free of cost.

  • User-friendly and best for beginners
  • Presence of smart indentation 
  • Highlights syntax
  • Open-source

Thonny –IDE

Thonny is yet another beginner-friendly python IDE that was developed by the Institute of Computer Science at the University of Tartu in Estonia and aimed at Python beginners. This like Idle is open-source and is free of cost too.

  • Open-source
  • User interface is simple
  • Simplified debugger
  • User logs maintained to keep a tab on the entire coding process

PyCharm – IDE

Mainly for intermediate and advance python users, it is the best extension to your Idle days. Charm comes in a two-tier pricing mode where the first is free of cost limited community version and the second tier is the fully paid professional version.

  • Apt for professional use
  • Error highlighting and suggestion fixing
  • A smart code navigation system
  • Strong debugging

Spyder – IDE

Mainly used by python scientists designed with data science. Its main focus is integrating with python data libraries which makes it a perfect choice for dedicated data science needs. This being Open source is free to explore.

  • Specializes in Data science
  • Python code auto-completion
  • Syntax highlight

Sublime Text – Code editor

Priced at $80 this versatile code editor supports all languages including python. All the needed basic code editing features are offered here which can be extended further with plugins like debugging and Django integration.

  • Fully features and has everything one is looking for
  • GOTO search function
  • Out of box highlighting of syntax

Repl.it (IDE) 

This is a general-purpose IDE that supports python and even lets the developers’ code directly through the browser. It is an open-source format that comes free of cost. With this tool, all the developer needs to write down an efficient python code is to have a system with a good internet connection.

  • Code-error analysis
  • Ability to code through the browser
  • Goes with other plugins

Visual Studio (IDE)

This is a well-packaged IDE that comes from the house of Microsoft. It is also python compatible with the help of PTVS (Python tools visual studio). Good for complicated applications and will cost the exchequer a neat $45 per month.

  • Apt for multiple languages
  • Can add python compatibility with the help of plugins
  • Have great navigation tools and debugging options
  • Has the support for Microsoft

Visual Studio Code – Code Editor

Visual Studio Code is free of cost and can be configured easily with extensions and plugins. This comes with syntax highlighting, debugging and an auto-completion feature called ‘Intellisense'.

  • Syntax highlighting
  • Debugger
  • Rich in feature though lightweight

Vim – Code Editor

This has a pre-installed Mac OS and UNIX OS. It is a basic editor but has the option for plugins and extensions.

  • Open-source
  • Easily configured with python
  • Compatible with plugins for syntax highlighting, code auto-completion and debugging

Atom – Code Editor

Flexible, lightweight and has its features like code auto-completion, adjustable user interface and debugging.

  • Open-source
  • Customized user interface
  • Find and replace the search option

You can choose a suitable Python IDE and Code Editor that helps make your software development process easier without any hassle. Let us know in the comments section if you know some other best code editors or IDEs suitable for easy to use, simple and hassle-free development.

Recommended Articles:

Read More

Monday, September 30, 2019

Python String split() method (With Examples)

split() method is used to break up a bigger string into a smaller list of strings. We need to specify a separator(default separator is a whitespace if not specified) to help in splitting of the string. As a result we get a list where each word is a separate list item. In other words split() is used to split a string into a list.

Syntax

str.split(separator, maxsplit)

Parameters


separator
This is any delimiter which is used to split the string. If it is not provided any whitespace(space, newline etc.) is considered as default.
maxsplit

It is a numeric optional value which specifies how many splits will be performed. If maxsplit is not provided then there is no limit. If maxsplit is not specified or -1(all occurrences), then there is no limit on the number of splits (all possible splits will be made).
Note: When maxsplit is specified, the list will contain the specified number of elements plus one.

Returns

Returns a list of strings which has been split by the specified separator. The split() splits the string at the separator and returns a list of strings.

Below examples shows Python split string by comma, python split string by character and python split string by space.

Example 1

textstring = 'Coding is Fantastic'
# Split() at space 
print(textstring.split()) 
wordstring = 'Coding, is, Fantastic'
# Split() at ',' 
print(wordstring.split(', ')) 
wordstring = 'Coding#is#Fantastic'
# Splitting at '#' 
print(wordstring.split('#')) 
Output


['Coding', 'is', 'Fantastic']
['Coding', 'is', 'Fantastic']
['Coding', 'is', 'Fantastic']

Example 2 


wordstring = 'Apple, Orange, Grapes, Kiwi'
# maxsplit: 0 
print(wordstring.split(', ', 0)) 
# maxsplit: 3 
print(wordstring.split(', ', 3)) 
# maxsplit: 1 
print(wordstring.split(', ', 1)) 
Output

['Apple, Orange, Grapes, Kiwi']
['Apple', 'Orange', 'Grapes', 'Kiwi']
['Apple', 'Orange, Grapes, Kiwi']

Further Read:

Read More

Monday, September 16, 2019

Python String - isdigit() method (With Examples)

isdigit() is an in-built method in python which is used for string manipulations. isdigit() returns True if all characters in the string are digits, else it returns False. This Python String Method does not take any parameters.

Syntax

string.isdigit()

Returns

True - If all the characters in the string are digits.
False - If 1 or more non-digit characters are present in string.

Example 1

# checking for digit using isdigit
str = '987654321'
print(str.isdigit())

str = 'Houseno22'
print(str.isdigit())

Output 
True
False

Example 2

# Checking for superscripts or subscripts with isdigit
str = '550\u2076'
print(str.isdigit())

Output 
True

Note: fractions, roman numerals are not considered digits, hence isdigit() returns False. This method will work with unsigned integers, superscripts or subscripts.

Further Read:

Read More

Thursday, September 12, 2019

Python Concatenate Strings | With Examples

What is concatenation?

Usually in any programming language, string concatenation means to join 2 strings together.  For example, if we have string1 = “Learn” and string2 = “Python”. The concatenation of string1 and string2 will give a result “Learn Python”. The contents of both items are merged by placing them side by side.

In this post we will learn how to do concatenation in python. In python strings are str objects. String objects are immutable.

Concatenation using ‘+’ Operator

This is the quickest way in Python to concatenate strings. You simply need to put ‘+’ in between various string variables and get a combined string as a result.

Example 1:


”Hello” + “ World” + “ !!” 
Output

“Hello World !!”

Note that spaces were included as part of string.

Example 2:


"help” * 5

Output

“helphelphelphelphelp”

This is another unique feature of Python. You can multiply a string and concatenate it as many times as you want.

Example 3:


str1 = “Learn”
str2 = “ Python”
str1 + str2

Output

“Learn Python”


str3 = str1 + str2
Print str3

Output

“Learn Python”

Many programming languages do implicit conversions when you try to concatenation between string and non string data. In Python however you will see a TypeError.

Example 4:


“Learn Python” + 101


Traceback (most recent call last):
  File "<pyshell#1>", line 1, in <module>
    "Learn Python" + 101
TypeError: cannot concatenate 'str' and 'int' objects

Concatenation using .join()

.join() is another useful way to do concatenation in Python. This works well with List which is made up of strings and you want to combine all the strings in this list to give you one big concatenated string result. .join() also takes a “joiner” which should be used in between the strings while joining.

Example 1:


str = ["How" , "Are" , "You"]
‘-’.join(str)

Output

‘How-Are-You’


So now you know how to concatenate strings in Python. There are many other string functions and methods available to do string data manipulations. We will keep on adding such useful information in the future. Bookmark/follow this blog to get the latest updates.

Further Read:

Read More

Saturday, September 7, 2019

Python String Length | Using len() Function

While programming in python we may need to find what is the length of a string?
Real world data validation may need that you add a check for a username of not more than size 30. Python provides a built-in function len() to find a string's length. len() takes string name as parameter and returns it's length.

Syntax


len(s)

s is the string of which we want to find the length.

Returns

len() returns the number of characters in a string. It is an integer value.

Example


s = "codefantastic"
print(len(s))

Output


13

Note: len() built-in function can also be used to find the number of items of an object passed. Not only string, len() function works with tuple, list, range or bytes also. In fact you can pass collection also to count the number of items present in it.

Further read:

Read More

Thursday, September 5, 2019

Python String Methods

String manipulations are an integral part of any programming language. Python is no different. The makers of python have provided a rich collection of built-in string methods to suit almost any kind of string processing. With the help of these python in-built methods you can trim, extract a substring, format, count, etc almost any string.

Below we have listed built-in python methods for strings. By clicking on each string method you can see how they can be used with examples.

 Python String Methods
 Description
casefold()
Python string method returns a casefold copy of string, used for caseless matching.        
capitalize()
Python string method returns a copy of string with first character capitalised and remaining in lowercase.
center()
Python string method returns string centered in a provided width.
count()
Python string method returns the number of occurrences of a substring in a given string.
encode()
Python string method returns encoded version of the given string.
endswith()
Python string method returns True if a string ends with the given suffix. 
expandtabs()
Python string method specifies the amount of space to be replaced with the “\t” symbol in the string.
find()
Python string method returns the lowest index of the substring if it is found in a given string.
format()
Python string method used for multiple substitutions and value formatting.
format_map()
Python string method used to return a dictionary key value.
index()
Python method searches an element in the list and returns its index.
isalnum()
Python string method checks if  all the characters in a string is alphanumeric or not.
Python string built-in method used for string handling.
isascii()
Python string method returns all characters in the string are ASCII or not.
isdecimal()
Python string method checks if all characters in the string are decimal characters.
Python string method determines whether the given character is a digit.
isidentifier()
Python string method checks whether a string is a valid identifier.
islower()
Python string method checks characters in the string are lowercase or not.
isnumeric()
Python string method determines whether all the characters of the string are numeric characters or not.
isprintable()
Python string method checks if all characters in the string are printable or the string is empty.
isspace()
Python string method checks if there are only whitespace characters in the string.
istitle()
Python string method determines if the string is a title cased string
isupper()
Python string method checks the given string is either in uppercase, or not.
join()
Python string method returns a string in which the elements of a sequence have been joined.
ljust()
Returns the string left justified.
lower()
Returns returns the lowercased string.
lstrip()
Python string method returns a copy of the string with leading characters are removed.
maketrans()
This static method returns a translation table usable for translate().
partition()
This method is used for splitting the string.
replace()
replace method is used for string substitution.
rfind()
This python method returns the highest index of the substring if found in given string.
rindex()
Python method returns the highest index of the substring inside the string, if found.
rjust()
This method returns the string right justified.
rpartition()
This method is used for splitting the string.
rsplit()
Python string method returns a list of strings after breaking it in smaller ones.
rstrip()
Python string returns a copy of the string with trailing characters removed.
This method returns a list of strings after breaking the given string by the specified separator.
splitlines()
Python method splits the string based on the lines.
startswith()
Checks if string starts with the given prefix.
strip()
Python string method returns a string with both leading and trailing characters removed.
swapcase()
Python method converts all uppercase characters to lowercase and vice versa.
title()
Converts a given string to titlecased.
translate()
Returns the string where each character has been mapped through the given translation table.
upper()
Returns a string in uppercase.
zfill()
Python string method returns a copy of the string left filled with ASCII '0'.




Read More

Monday, August 19, 2019

Understanding Arrays in C++

Many times while programming you might have come across a problem where you need to make multiple variables of the same datatype in order to store similar data in it. But every time this is not a feasible option. So the concept of Array comes into the picture.

An array is basically a collection of values of the same datatype or you can also understand it as a collection of the same type of variables.

For example, you want to store the marks of one subject of a class having 40 students, then you will have to create 40 different variables like marks1, marks2, marks3… marks40. But this becomes very difficult for management so you can declare an array of size 40 which will allocate a continuous memory of 40 units.




How to declare an array?

Syntax for declaring an array in C++ is:

datatype arrayName[size];

For example:
int marks[5];

This will create an array named marks of size 5 of datatype int.

How to access an array?

Arrays can be accessed using the index. You might wonder what is an index? An index is like a value used to access elements of the array.

Index of an array starts from 0 (zero) to (n-1) where n is the number of elements in the array or size of the array. If you consider the above example array index will be from 0 to (5-1) which is 0 to 4.

If you want to get third value from the array, you can access it by marks[2]. This shows that to access the nth element of the array you will have to use the index as (n-1).

Key point you should remember about the array is that it is a set of continuous memory locations which means if the memory address of marks[0] is 2010 then the memory address of marks[1] will be 2014, marks[2] will be 2018 and so on. It is because the array is of type int and in C++ an integer value occupies 4 bytes so, there is a gap of 4 bytes between each memory location.

How to initialize an array?

After you declare an array next step is to initialize it. There are multiple ways to initialize an array.

You can simply assign the value to the array using the assignment operator(=) and then in curly braces, specify all the elements of the array. For example, int marks[5] = { 90, 91, 86, 45, 90 };
When you initialize an array at the time of declaration and do not specify the size of the array, it will take of size as the number of elements in the initialization.

For example, int marks[] = { 90, 91, 84 };

It will automatically take the size as 3 as there are three elements assigned to the array.

The next method is the traversal method. If you want to take the input of the array through the user, you may use this method. In this method, we with the help of a for loop initialize each and every element with the user inputted value.

For example :


int i = 0;
int marks[5];  // declaration of the array 
for( i=0 ; i<5 ; i++) { cin >> marks[i]; assign the input value to the array }


Here is a program which shows how to take input from user and print an array.

#include <iostream>
using namespace std;

int main()
{
int num[5];   //declaration of the array.
cout << “Enter 5 elements of the array :”;
//Input each and every element of array using traversal method
for(int i = 0; i<5; i++)
{
cin >> num[i];          //assigning the input value to the array
}
cout << “Your array is :”;
for(int i = 0; i<5; i++)
{
cout << “num[i] = ” <<num[i];    //output value of the array element by element
}
return 0;
}
Output of the above code :
Enter 5 elements of the array :1
2
3
4
5

Your array is : num[0] = 1
num[1] = 2
num[2] = 3
num[3] = 4
num[4] = 5

The array discussed above was the single dimension array or 1D array. Simillary, we can have Multi-Dimensional array as well.

Multidimensional Array

Multidimensional array contains multiple dimensions like a 2D array will behave as a table have rows and column but in for of an array. Accessing of the array is still based on the index only.

To declare and initialize an 2D array :

int num[3][3] = { {1, 2, 3}, // Row 1 {4, 5, 6}, // Row 2 {7, 8, 9} }; //Row 3

Here is a program which shows how to input and output a 2D array.

#include <iostream>
using namespace std;
int main()
{
int num[3][3];         //declaration of the array.
cout << "Enter elements of the array :";
//Input each and every element of array using traversal method
for(int i = 0; i<3; i++) 
{
cout << "Enter 3 elements of Row " << i+1 << "\n";
for(int j=0; j<3 ;j++)
cin >> num[i][j]; //assigning the inputted value to the array
}
cout << "Your array is : \n";
for(int i = 0; i<3; i++) 
{
for(int j=0; j<3 ;j++)
cout << "num["<<i <<"][" << j << "] = " <<num[i][j] << "\t"; //output value of the array element by element
cout << "\n";
}
return 0;
}
Output
Enter elements of the array :Enter 3 elements of Row 1
1
2
3

Enter 3 elements of Row 2
4
5
6

Enter 3 elements of Row 3
7
8
9

Your array is :
num[0][0] = 1 num[0][1] = 2 num[0][2] = 3
num[1][0] = 4 num[1][1] = 5 num[1][2] = 6
num[2][0] = 7 num[2][1] = 8 num[2][2] = 9

This was all about the arrays in C++. Hope you enjoyed learning. If you have any queries or suggestions please leave a comment. We will come up with more useful content for you.

Read More