• Skip to primary navigation
  • Skip to main content

DebKR

To the Stars

  • About
  • Blog
  • Contact

raw_input

Building a Tagging Engine in Python using Dictionaries

Building a Tagging Engine in Python using Dictionaries

01/05/2016 By debkr

tagging-engineI started playing around building a Tagging Engine in Python using Lists but now I’ve studied a bit more – particularly Dictionaries – I want to see how I can perfect what I was working on. Here are a couple of key things I added/changed in this program over the version I was working on earlier.

1. Using a dictionary instead of lists for faster counting and simpler recall. This is straight forward, using the get method as taught by Dr. Chuck (see Coding 101 part 7 for more details).

words = dict()
for word in wordlist :
____if word in excluded : continue
____words[word] = words.get(word,0) + 1

[Read more…] about Building a Tagging Engine in Python using Dictionaries

Filed Under: Blog, Personalised Training Plan, Programming, Programming Projects Tagged With: ==, count, descending, dictionary, iteration, len(), length, list, loop, order, print, program, range, raw_input, user, variable, working directory

Coding 101 (part 3)

Coding 101 (part 3)

04/04/2016 By debkr

This post follows on from my earlier posts Coding 101 (part 1) and (part 2), and is my responses and learnings from the highly-recommended Python programming book and course by Charles Severance (see References below).

Functions:
Functions are sections of code (a sequence of executable steps) which we want to be able to use and re-use at many points in our program. It may be that we want to read and process a whole range of data over and over (but the process done to all the data is the same) or maybe there are a number of inputs required from the user which all need to be processed the same way. Rather than rewriting the same lines of code again and again in our program, we can give that section of code a name (known as ‘defining the function’). We can then ‘call’ that named function, that is, ask Python to execute the defined sequence of steps, at any future point within our program, and as many times as we want. (In other programming languages this same functionality may be referred to as sub-programs or sub-routines.) [Read more…] about Coding 101 (part 3)

Filed Under: Blog, Personalised Training Plan, Programming Tagged With: ==, argument, break, code, coding101, condition, construct, continue, data, define, function, input, items(), iteration, largest, list, loop, parameter, program, python, raw_input, reserved words, return, sequence, smallest, string, type, value, variable

Copyright © 2016–2025 · Powered by WordPress On Genesis Framework · Log in

  • Writing
  • Developing
  • Consulting