Tag Archives: Python

Announcing General Availability of PyCharm 5 with new Blocking Feature

Announcing General Availability of PyCharm 5 with new Blocking Feature

Hurray, PyCharm 5 just released, the new major version of our intelligent IDE for Python, web and scientific development! It is one of the updates of our desktop products that comprise the brand new JetBrains Toolbox.


PyCharm 5 is available as a full-fledged Professional Edition for Python and Web development, or as a free and open-source Community Edition for pure Python and scientific development.

PyCharm 5 brings an outstanding lineup of new features, including full Python 3.5 support, Docker integration, Thread Concurrency Visualization, code insight for Django ORM methods, Conda integration, and IPython Notebook v4 support, just to name a few.

The highlights of this version include: Continue reading Announcing General Availability of PyCharm 5 with new Blocking Feature

Sets and Frozensets

Introduction

Graphical Depiction of Sets as Circles The philosopher Wittgenstein didn’t like the set theory and complained mathematics is “ridden through and through with the pernicious idioms of set theory,” He dismissed the set theory as “utter nonsense”, as being “laughable” and “wrong”. His criticism appeared years after the death of the German mathematician Georg Cantor, the founder of the set theory.

Cantor defined a set at the beginning of his “Beiträge zur Begründung der transfiniten Mengenlehre”:
“A set is a gathering together into a whole of definite, distinct objects of our perception and of our thought – which are called elements of the set.” Nowadays, we can say in “plain” English: A set is a well defined collection of objects.

The elements or members of a set can be anything: numbers, characters, words, names, letters of the alphabet, even other sets, and so on. Sets are usually denoted with capital letters. This is not the exact mathematical definition, but it is good enough for the following. Continue reading Sets and Frozensets

Dictionaries

Introduction

We have already become acquainted with lists in the previous chapter. In this chapter of our online Python course we will present the dictionaries and the operators and methods on dictionaries. Python programs or scripts without lists and dictionaries are nearly inconceivable. Like lists dictionaries can easily be changed, can be shrunk and grown ad libitum at run time. They shrink and grow without the necessity of making copies. Dictionaries can be contained in lists and vice versa. But what’s the difference between lists and dictionaries? Lists are ordered sets of objects, whereas dictionaries are unordered sets. But the main difference is that items in dictionaries are accessed via keys and not via their position. A dictionary is an associative array (also known as hashes). Any key of the dictionary is associated (or mapped) to a value. The values of a dictionary can be any Python data type. So dictionaries are unordered key-value-pairs.

Dictionary don’t support the sequence operation of the sequence data types like strings, tuples and lists. Dictionaries belong to the built-in mapping type. They are the sole representative of this kind!

At the end of this chapter, we will show how a dictionary can be turned into one list, containing (key,value)-tuples or two lists, i.e. one with the keys and one with the values. This transformation can be done reversely as well. Continue reading Dictionaries

print

Introduction

There are hardly any computer programs and of course hardly any Python programs, which don’t communicate with the outside world. Above a ll a program has to deliver its result in some way. One form of output goes to the standard output by using the print statement in Python. 1

>>> print "Hello User"
Hello User
>>> answer = 42
>>> print "The answer is: " + str(antwort)
The answer is: 42
>>> 

It’s possible to put the arguments inside of parentheses: Continue reading print

Conditional Statements

Some decisions are inevitable

inevitable decisions Under certain conditions some decisions are sometimes in normal life inevitable, as we can can see in our photo. It’s the same for every program, which has to solve some useful problem. There is hardly a way to program without having branches in the flow of code.

In programming and scripting languages, conditional statements or conditional constructs are used to perform different computations or actions depending on whether a condition evaluates to true or false. (Please note that true and false are always written as True and False in Python.)

The condition usually uses comparisons and arithmetic expressions with variables. These expressions are evaluated to the Boolean values True or False. The statements for the decision taking are called conditional statements, alternatively they are also known as conditional expressions or conditional constructs.

The if-then construct (sometimes called if-then-else) is common across many programming languages, but the syntax varies from language to language. Continue reading Conditional Statements

Input from Keyboard

Input via keyboard There are hardly any programs without any input. Input can come in various ways, for example from a database, another computer, mouse clicks and movements or from the internet. Yet, in most cases the input stems from the keyboard. For this purpose, Python provides the function input(). input has an optional parameter, which is the prompt string.

If the input function is called, the program flow will be stopped until the user has given an input and has ended the input with the return key. The text of the optional parameter, i.e. the prompt, will be printed on the screen.

The input of the user will be interpreted. If the user e.g. puts in an integer value, the input function returns this integer value. If the user on the other hand inputs a list, the function will return a list.

Let’s have a look at the following example:

name = input("What's your name? ")
print("Nice to meet you " + name + "!")
age = input("Your age? ")
print("So, you are are already " + str(age) + " years old, " + name + "!")

We save the program as “input_test.py” and run it: Continue reading Input from Keyboard