# 4 Fantastic Beginner Python Programming Challenges to Really Test Your Knowledge

Programming is not all about memorizing syntax and knowing every single function every made at the top of your head. It’s about knowing how to apply a strong base of fundamental knowledge to intricate, complex, logic-based, situations.

Before you get to building apps and advanced software like that, you need to master mind-bending and thought-provoking logic. Logical programs that, after reading them, send you deep in thought and analysis.

The following programs will, for majority of you, do just that. They’ll make you think like you’ve never thought before.

They’re not arduous, but they’re not straightforward or simple either.

Since the purpose of this article is for the reader to try solving these programs themselves, I won’t be giving an in-depth explanation of each solution. Just the solution code at the very end. And remember, a single problem can have many solutions. Mine can look completely different from yours, but in the end, it’s the output that matters. However, it won’t help if you code carelessly. For example, copy and pasting a huge chunk of code whereas a simple for loop can do the job.

# 1. The Star Triangle Pattern

Given an input by the user in the form of a positive integer, the program should print out a triangle-shaped pattern made of the star character (*). The input should be stored in a variable called N. N represents the number of rows in the pattern. The number of stars in each row increases by 2 each time.

For example:

If N = 3

` *`

***

*****

If N = 4

` *`

***

*****

*******

# 2. Sum of Integers in String

Given a sentence or cluster of words, find out if there are any integers inside the string. Print out the total number of integers. If there’s at least 1 integer present, find the sum of all of the integers found and print out the sum.

For example:

If string = “200 plus 500 is equal to”

`2 integers found`

sum: 700

# 3. FizzBuzz

Cycle through every number from 1 to some number that the user provides as input. (only integers) and print each one onscreen. If the number is divisible by 4, then instead of printing the number itself, print “Fizz”. If the number is divisible by 6, then instead of printing the number itself, print “Buzz”. If the number is divisible by both 4 and 6, print “FizzBuzz”. If the number doesn’t satisfy any of these conditions, simply print the number itself.

For example:

If max = 13

The range would be 1 to 13

`1`

2

3

Fizz

5

Buzz

7

Fizz

9

10

11

FizzBuzz

13

**4. Sum of Two**

Create a function called sumOfTwo(a, b, v) with 3 parameters.

**a **is a list of integers, such as [22, 341, 21, 5, 0, -5].

**b** is also a list of integers, just like a.

**v** is a single integer.

The function should check if it is possible to take one number from both list a and b, and add the numbers together to equal the number v.

If there are 2 numbers that can do this, print “True”. Otherwise, print “False”.

For example:

`sumOfTwo([1, 2, 3], [10, 20, 30], 23)`

The output would be “True” because 3+ 20 = 23.

**Possible solutions:**

## 1. The Star Triangle Pattern

`N = int(input("N: "))`

x = 1

for i in range(N, 0, -1): # starting number, ending number, step

numberOfSpaces = i - 1

numberOfStars = N - i + x

print(" " * numberOfSpaces + "*" * numberOfStars)

x = x + 1

## 2. Sum of Numbers in String

`string = "200 plus 500 is equal to"`

stringList = string.split()

digitList = []

numberOfIntegers = 0

for item in stringList:

if item.isdigit():

numberOfIntegers += 1

item = int(item)

digitList.append(item)

sum = sum(digitList)

print(str(numberOfIntegers) + " integers found")

print("sum: " + str(sum))

## 3. FizzBuzz

`max = int(input("Max: "))`

for number in range(1, max+1):

if number % 4 == 0 and number % 6 == 0:

print("FizzBuzz")

elif number % 4 == 0:

print("Fizz")

elif number % 6 == 0:

print("Buzz")

else:

print(number)

## 4. Sum of Two

`def sumOfTwo(a, b, v):`

lenA = len(a)

lenB = len(b)

for itemA in a:

for i in range(lenB):

currentNumberB = b[i]

if v - itemA == currentNumberB:

print("True")

exit()

else:

if a.index(itemA) == lenA:

print("False")

exit()

Happy coding! Stay safe during these times.