Homework 5: An Interview Coding Challenge Question
Objective: Using a For Loop
This homework question comes to us from a group of current and former CCSF students who meet semi-regularly on Saturdays. You can come find out when our next meeting is by finding a fellow student (see more work from Take Five here).
Write a program which reverses a number (see sample output) using a for loop and arithmetic operators available in python:
Rules
- Your program should ask the user for a number and use only arithmetic operators made available in python
- Your program should only have one for loop
- Your program cannot use python's "reverse" or the list split functions
- Your program should use just one for loop, logical and arithmetic operators only
- You may find the operators (**, //, %) helpful
- You may find len(str(var)) helpful to find the number of digits in an integer
- You may work with a fellow student but please place who you collaborated with or who helped you in a comment at the top of your program.
- The Python source code should be in a .py file (.py) and uploaded to Canvas
Here is some sample output:
[grwoo@hills cs110a_sp19]$ python hw05.py
Please enter in a number (for example 12345) and I will reverse it: 12345
54321
[grwoo@hills cs110a_sp19]$ python hw05.py
Please enter in a number (for example 12345) and I will reverse it: 2345678
8765432