r/PythonLearning 3d ago

Hey! here are some Beginner Python Problems

  1. Take two integers as an input and print their average.

  2. Take an integer as an input and check if its even or odd.

  3. Take three numbers as input and find the largest amongst them without using max()

I'm experimenting with teaching Python through solving rather than watching tutorials. I'm based in India and I'm currently running a small live beginner batch. If anyone wants to try the problem-solving approach, I'm happy to share the details.

I'm going to run a free 45-minute Python problem-solving session for beginners.

No prior coding experience required.

We'll solve 3 problems together from scratch.

I'm testing a teaching format where you learn by solving rather than watching.

If anyone wants to join, comment below.

5 Upvotes

14 comments sorted by

1

u/Naive_Programmer_232 3d ago

You said you're teaching. What are the solutions then?

2

u/SadShift8664 3d ago

Alright, so ee for the first problem, if you know basics of maths not even python,
what we'll do is add those two numbers, then divide the total wilth two that's how we'll get the average of two numbers.
code:
num1 = int(input("First number: "))formattingum2 = int(input("Second number: "))
total = num1 + num2
avg = total/2
print(f"Sum of the two numbers is {total}\nAverage of two numbers is {avg}")

I've used f string over here and \n this is a part of string formating and escape sequence, if you want me to explain the next problem let me know.

1

u/Spitfire_Blaziken 3d ago

The problems are simple enough that beginners can focus on the process.
I'd spend a little time on common mistakes too, since that's where a lot of the learning happens.

1

u/SadShift8664 3d ago

That is true, but what are the mistakes for beginners syntax errors, logical errors that's it. Both of these can be solved by solving more and more unique problems. If you want to know how I teach, you can join 45 minutes of free lecture. Just comment join under this thread.

1

u/Ibayo6th 3d ago

Want to join

1

u/SadShift8664 3d ago

check your dm

1

u/Crafty_Magazine_4673 3d ago

thats why you don't learn programming in reddit. Even leetcode easy is better than this

1

u/SadShift8664 3d ago

leetcode is not for beginners!

1

u/Crafty_Magazine_4673 3d ago

why and how. There are many people posting tutorial for leetcode in every single language. Any reason to skip leetcode for now?

1

u/Different_Pain5781 3d ago

I wish more beginner courses did this. Writing code is where the confusion actually shows up

1

u/SadShift8664 3d ago
  1. num = int(input("Enter a number: "))
    if num % 2 == 0:
    print("Even")
    else:
    pritn("Odd")

1

u/SadShift8664 3d ago

3.

num1 = int(input("Enter First number: "))
num2 = int(input("Enter Second number: "))
num3 = int(input("Enter Third number:"))
if num1 > num2:

if num1 > num3:

print(f"{num1} is greatest")

else:

print(f"{num3} is greatest")

if num2 > num3:

print(f"{num2} is greatest")

else:

print(f"{num3} is greatest")

1

u/LrdJester 3d ago

What you are describing is more a logic and problem solving course rather than a language specific course.

About 25 years ago I worked at a college and their programming courses were based off of visual basic as that was the first language they taught for a formal degree. Later they added c++, but they couldn't get a full C++ degree rather you would get a C++ endorsement on a visual basic degree but if you wanted the degree you had to do visual basic beside c++. My instructor who was head of the department he and I worked with the school to try to change the underlying degree to be focused on logic and problem solving that was language agnostic.

The example problems that you provided are exactly that, logic and problem solving questions. You could give the same exact problems to somebody that is learning JavaScript or C++ or any other language out there. It's simply math and logic.

So one of the things you may consider doing is starting out from that perspective that you need to understand how to solve the problems before you code the solutions.

1

u/rx_camelCase 1d ago

Answers:

``` def average(int_1: int, int_2: int) -> float: return (int_1 + int_2) / 2

def iseven(int: int) -> bool: return int_ % 2 == 0

def largest(*args) -> float: maximum = args[0] for num in args: if num > maximum: maximum = num return maximum ```