By the end of this chapter you will be able to:
- Create variables and assign values in Python.
- Identify common data types such as text, numbers, and booleans.
- Use input to collect simple information from a user.
- Convert between text and numbers when needed.
- Write a short program that stores and displays basic information.
Key topics: Variables as named containers, Strings, integers, floats, and booleans, Using input for user interaction, Type conversion with int and str, Naming variables clearly
Suggested time this week: 2 hours video/demo, 1.5 hours guided practice, 1 hour exercise, 1 hour lab, 0.5 hour quiz and review
A common beginner frustration is writing a program that works once but cannot adapt to new information. This lesson shows how variables and input make a Python program reusable. Instead of hardcoding every detail, the program can ask the user for information and then respond based on what it receives.
Consider a fictional hospital admin tool that asks for the name of a department and the number of pending appointments. The tool can then store those values and display a summary. This kind of pattern is used in many software engineering tasks because it allows one program to work with many different records.
The mechanics begin with input. Python can pause and wait for the user to type a response. That response is stored in a variable. If the response needs to be used as a number, the programmer converts it. For beginners, it helps to practice one variable at a time. First ask for text, then ask for a number, then print both values back to the screen.
Another important idea is readability. In a team setting, code should be easy to scan. That means spacing, naming, and simple structure matter. A beginner does not need advanced formatting rules, but they should aim for code that another person could understand without guessing. This is a core software engineering habit.
A good practice is to test with fictional values. For example, type “Radiology” for the department and “12” for the appointment count. Then change the values and run it again. This helps learners understand that the program is not tied to one answer. It is a flexible script that works with new input each time.
If a number conversion fails, the learner should inspect the input carefully. Did they type a letter? Did they include spaces? Did they forget to convert the value before using it in math? These small checks build problem-solving confidence.
By the end of this lesson, the learner should be able to create a small interactive script that stores and reuses information. That is a major step from static output to useful software behavior.