# An Introduction to Python and LaTeX (draft) by Pramode C.E

By Pramode C.E

Read Online or Download An Introduction to Python and LaTeX (draft) PDF

Similar programming: programming languages books

Professional Oracle 8i Application Programming with Java, PL SQL and XML

Oracle company has broadened its improvement platform, integrating open criteria similar to Java and XML into the center of the Oracle 8i database. This prolonged programming surroundings maintains to use the features of scalability, reliability and potency of the world's so much winning info administration software program, yet even as it presents new demanding situations and possibilities to programmers.

Extra resources for An Introduction to Python and LaTeX (draft)

Example text

Only if the line “return a” is indented deeper than the line “if (a>b):” will Python assume that the “return a” is part of the body of the if statement. Getting the indentation levels wrong is a common mistake made by beginners! 4. 5 Exercises 1. Define a function is_odd which checks whether a number is odd or not. 2. Define a function maximum which returns the maximum of three numbers (Hint: you might first define a function which will find out maximum of two numbers and use that to write a function which will return maximum of three numbers).

What is an Associative Array? 01 >>> a = [10, 11, 14, 13, 17, 24, 78] >>> for k in a: ... if ((k % 2) == 1): ... print k ... >>> The general form of a for loop is: for variable_name in sequence: body In the above case, the variable_name is k and the sequence is the list a; the body of the for loop is an if statement. This is the way the for loop works: the statements in the body get executed as many times as there are elements in the given sequence. In our example, the body gets executed seven times.

In all other cases, a while loop is the natural choice. 46 Chapter 10. Strings, Tuples and Associative Arrays CHAPTER ELEVEN PROGRAMMING WITH CLASSES AND OBJECTS Besides writing correct code, a programmer has to make sure that he writes clear, readable code; code which others can read, understand and modify easily. One way to do this is by structuring the program as a collection of small functions. In this chapter, we examine another powerful technique for achieving the same goal. Note: We are going to examine ideas which are a bit more complicated than what we have seen so far ...