Addons Calculator Cmdline Designer Formats Howtos Regexp Shell Start Tutorial Git Tutorial Tcl Videos
Python Tutorial
Hello World:
# hello.py print "Hello, World!"
Variables and Data Types:
# variables.py name = "John" age = 25 height = 1.75 is_student = True print "Name:", name print "Age:", age print "Height:", height print "Is Student:", is_student
User Input:
# user_input.py name = raw_input("Enter your name: ") print "Hello, " + name + "!"
Conditional Statements:
# if_statement.py num = input("Enter a number: ") if num % 2 == 0: print num, "is even." else: print num, "is odd."
Loops:
# while_loop.py count = 0 while count < 5: print "Count:", count count += 1
# for_loop.py for i in range(5): print "Iteration:", i
Functions:
# functions.py def greet(name): return "Hello, " + name + "!" print greet("Alice")
Lists and Dictionaries:
# lists_and_dicts.py my_list = [1, 2, 3, 4, 5] my_dict = {'a': 10, 'b': 20, 'c': 30} print "List:", my_list print "Dictionary:", my_dict
File Handling:
# file_handling.py with open("example.txt", "w") as file: file.write("Hello, Python 2.7!") with open("example.txt", "r") as file: content = file.read() print "File Content:", content