Python vs. Java: Notes for Class Discussions


For class discussion:

Concepts
Sample Python 3.1 programs
Sample Java programs
IDE and introduction Discussion on Python:
using IDLE
Uses indentation for blocks of code
Statement terminator: not needed!
Operator: for concatenation - use +
Operator: for string repetition - use *
Discussion on ** for exponentiation.
Data types review: int, float, string, boolean, etc.
(Note - Python does not provide "char")
Discussion on Java:
using JCreator/NetBeans/Eclipse
Using braces for blocks of code
Statement terminator: semi-colon
Operators: + for concatenation
Use code to implement string repetition
There is no ** operator for exponentiation.
Data types: int, float, double, char, boolean, etc.
 
Hello, World! Hello, world! "hello, world!" in Java
Working with integers integer arithmetic integer arithmetic
Data entry: text data entry data entry: text
Data entry: numbers data entry data entry: numbers
Selection statements: if/else Rolling a virtual die Rolling a virtual die
Selection statements: switch (not available) Rolling a virtual die
Repeetition: while loops Basic while loop Basic while loop
Repetition: for loops Nested for loop Nested for loop
Working with Strings Basic loop for working with a string Basic for loop for working with a String
Repetition: do/while loops (not available) do/while loop: looking for snake eyes!
Writing a method / function Green Eggs and Ham - using a function Green Eggs and Ham - using a void function
Writing a method / function which returns a value Converting temperatures -Fahrenheit & Celsius Converting temperatures -Fahrenheit & Celsius
Using an array / list to roll a virtual die Rolling a virtual die - using a list for totals Rolling a virtual die - using an array for totals

For further reference - from Java to Python: