WGU D335: INTRODUCTION TO
PROGRAMMING IN PYTHON
QUESTIONS ND ANSWERS WITH
COMPLETE SOLUTIONS 100%
CORRECT RATED A+
1. How does Python handle variable types compared to languages like C++ or
Java? ✔✔ Python uses dynamic typing, which means you don't have to declare a
variable's type (like int or string) explicitly; the interpreter determines the type
based on the value you assign to it at runtime.
2. What is the difference between a list and a tuple in Python? ✔✔ The main
difference is mutability: lists are mutable, meaning you can change or add items
after they are created, while tuples are immutable and cannot be altered once
defined.
3. In Python, what is the purpose of "indentation" and why is it strictly
enforced? ✔✔ Indentation is used to define the scope of code blocks, such as
loops, functions, and if-statements; unlike other languages that use curly braces,
Python relies on whitespace to determine which lines of code belong together.
4. What does the "floor division" operator (//) do in a calculation? ✔✔ The
floor division operator divides two numbers and rounds the result down to the
nearest whole integer, effectively discarding any fractional or decimal remainder.
22.1 Lab: Convert to Seconds
, Write a program that reads in hours, minutes, and seconds as input, and outputs the
time in seconds only.
22.2 Lab: Convert from Seconds
People find it easier to read time in hours, minutes, and seconds rather than just
seconds.
Write a program that reads in seconds as input and outputs the time in hours,
minutes, and seconds.
22.3 Lab: Pizza Party
PROGRAMMING IN PYTHON
QUESTIONS ND ANSWERS WITH
COMPLETE SOLUTIONS 100%
CORRECT RATED A+
1. How does Python handle variable types compared to languages like C++ or
Java? ✔✔ Python uses dynamic typing, which means you don't have to declare a
variable's type (like int or string) explicitly; the interpreter determines the type
based on the value you assign to it at runtime.
2. What is the difference between a list and a tuple in Python? ✔✔ The main
difference is mutability: lists are mutable, meaning you can change or add items
after they are created, while tuples are immutable and cannot be altered once
defined.
3. In Python, what is the purpose of "indentation" and why is it strictly
enforced? ✔✔ Indentation is used to define the scope of code blocks, such as
loops, functions, and if-statements; unlike other languages that use curly braces,
Python relies on whitespace to determine which lines of code belong together.
4. What does the "floor division" operator (//) do in a calculation? ✔✔ The
floor division operator divides two numbers and rounds the result down to the
nearest whole integer, effectively discarding any fractional or decimal remainder.
22.1 Lab: Convert to Seconds
, Write a program that reads in hours, minutes, and seconds as input, and outputs the
time in seconds only.
22.2 Lab: Convert from Seconds
People find it easier to read time in hours, minutes, and seconds rather than just
seconds.
Write a program that reads in seconds as input and outputs the time in hours,
minutes, and seconds.
22.3 Lab: Pizza Party