The transaction file is working great too

When you open up the transactions . txt file, you see this inside:

The next 16 characters are the Credit card number.

The f irst 7 character . are the price.

The descriptions follow. (Note the extra padding due to the "%|6s" format specifier.)

The next 16 characters are the Credit card number.

Both of the records, created by each of the POS programs, are now correctly formatted. That's because both programs are sharing the same piece of code to save the transactions.

So modules are sort of like containers for functions, right?

A" It's true that most modules are used to store a collection of related functions. However, it is perfectly acceptable to put any code in a module, which is then executed whenever the module is imported into your program.

Looks like you saved the day.

ijieretgre no

- Dumb Questions

Q/ So when I use import, it's as if I typed the code in the module directly into my program?

A" Yes, that's a good way to think about it. Using a shared module saves you from having to type (or cut'n'paste) all that code yourself. Just import it and it's there.

Do I have to use modules?

A.: No, but the benefit of putting shareable code into a module starts to pay off the second you use that module in another program. Sharing code with modules is good programming practice.

price break

Was this article helpful?

0 0

Post a comment