Python Forum
[Basic] Control Flow in Python assignment - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: General (https://python-forum.io/forum-1.html)
+--- Forum: Tutorials (https://python-forum.io/forum-4.html)
+---- Forum: Tutorial Requests and Submissions (https://python-forum.io/forum-21.html)
+---- Thread: [Basic] Control Flow in Python assignment (/thread-32009.html)



Control Flow in Python assignment - alectheprogrammer - Jan-14-2021

Hi, Python Learners! I'm building out assignments to help people learn Python. Here's the latest one on control flow, which includes conceptual questions and coding questions pertaining to functions, if statements, booleans, and loops. Enjoy!

https://open.openclass.ai/resource/assignment-5ff7aa8ad492f5deb5b37e8b?code=P2jn1VwbZ_3z8Q


RE: Control Flow in Python assignment - BashBedlam - Jan-24-2021

I tried the first example. The code I entered produced the correct result when run in my system but produced errors when run in you online interpreter. Here's my code:


# Move this code into a function `is_prime(test_num)`
def is_prime(test_num):
    num = 2
    test_num_is_prime = True
    while num <= float(test_num / 2):
        if test_num % num == 0:
            test_num_is_prime = False
            break
        num += 1
    if test_num_is_prime:
        print("%d is prime" % test_num)
    else:
        print("%d is not prime" % test_num)

# Input handling, do not modify below this line
is_prime(int(input()))