Python Programming Examples

  Updated:February 2, 2018
Strings and Numbers Print (to screen) Lists Loops Conditionals - IF
Get a random number Ranges User Input- Keyboard Functions Dictionaries
Boolean variables File Input & Output Turtle Graphics Sample Programs  
     
  Strings and Numbers Click for Example Programs
  numeric vs string - examples 1 numeric_vs_string_examples_1b.py
  integer vs string - example 1 integer_vs_string_example_2.py
    string_examples_1.py
  Calculations, arithmetic  
  string work  
  Print (to Screen)  
  Print examples 1 print_examples_1.py
 

Print examples 2

print_examples_2.py
 

First examples

first_examples.py
     
  Lists  
  List examples list_examples_1.py
  List examples 2 list_examples_2.py
  list work  
     
  lists inside lists example lists_in_lists_example.py
     
  Loops  
  Loops examples - while loop loops_examples_1.py
  Loops examples 2 - while loop loops_examples_2.py
  for loops for_loop_example_2.py
     
Conditionals - IF  
  conditionals examples 2 conditionals_examples_1.py
     
  Get a random number get_a_random_number
     
  Ranges  
     
  User Input- Keyboard  
  User input - some detail user_input_examples.py
  User input a number

user_input_a_number

  User input a number in a loop

user_input_a_number_inside_a_loop.py

     
  Functions simple_functions.py
     
  Dictionaries dictionary_example_1.py
     
  Boolean variables booleans_example_1.py
     
  File Input & Output  
        write to a file file_write_example_1.py
       read from a file file_read_example_1.py
  File open and read example file_read_example.py
  File write example (create or replace) file_write_example.py
     
  Turtle Graphics  
       line and left turn left_turn_right_turn.py
       random_color turtle_random_color.py
       random color and location turtle_rand_col_loc.py
      Turtle line - length, color, angle, size pen_draw.py
       circle circle_1.py
       spiral spiral_1.py
     
      square 1_square.py
      rectangle 2_rectangle.py
      square w loop 3_square_loop.py
      rectangle w loop 4_rectangle_loop.py
      square w function 5_square_function.py
      rectangel w function 6_rectangle_function.py
      first random line 7_first_random_line.py
      FULL random line program 8_turtle_rand_angle_width_plus.py
     
     Convert displayed values to graphics  
        Show values to use in simple line line_values_1.py
        Use values to draw simple line line_draw_1.py
        Show values for line w/ color & pen size. line_values_2.py
        Use values to draw line w/color and size line_draw_2.py
     
  Sample Programs  
 

sort program - with comments

sort_program.py
 

sort program - w/less comments

sort_program_w_fewer_comments.py
  sort program - shorter sort_list_shorter.py
  Adventure Game - under construction adventure/main_game_3.py