- Joined
- Jul 14, 2006
- Messages
- 67
- Trophies
- 0
- Age
- 33
- Location
- Queensland
- Website
- Visit site
- XP
- 216
- Country
so i just started my programming course at uni and i just need help with i question i've been stuck on for about 2 hours now.
i know that there are a lot of bright minds in this community that can program. so this is the first place i came to for help.
-----------------------------
the question is:
Create a procedure called printSquareStar(), using printNString(string, numTimes), that prints the following using printNString.
****
****
****
****
This is a 4x4 square made up of the star (*) character.
-----------------------------
i was given this info if it helps at all, but it shouldn't be anything new to the more veteran programmers.
# Useful Operators: Equals ==
# Increment +=
* Eg. i = i + 1 -> i+=1
You should use the function printNString, that takes a string and a number and prints it n times. Eg:
printNString('a', 5) => 'aaaaa'
Aside: For testing your solutions in IDLE you might like to use the following definition. It is NOT necessary to include this definition in your solution to the problems below.
def printNString(a, n):
print n*a
Note, however, that the above example is unusual. Most of the functions you need to define in these on-line problems do not use print but instead return a value using return.
----------------------------
here's what i wrote:
def printSquareStar():
----def printNString(a, n):
--------i = 0
--------while int(n) != i:
------------print a
------------i = i + 1
----printNString('****', 4)
----------------------------
but i keep getting this error:
Here are the results of your input on the test cases:
****
****
****
****
Test case is:
Your input produces:
the correct result is:
****
****
****
****
wrong - TRY AGAIN
-----------------------------
now i don't know what to do.
please help.
i know that there are a lot of bright minds in this community that can program. so this is the first place i came to for help.
-----------------------------
the question is:
Create a procedure called printSquareStar(), using printNString(string, numTimes), that prints the following using printNString.
****
****
****
****
This is a 4x4 square made up of the star (*) character.
-----------------------------
i was given this info if it helps at all, but it shouldn't be anything new to the more veteran programmers.
# Useful Operators: Equals ==
# Increment +=
* Eg. i = i + 1 -> i+=1
You should use the function printNString, that takes a string and a number and prints it n times. Eg:
printNString('a', 5) => 'aaaaa'
Aside: For testing your solutions in IDLE you might like to use the following definition. It is NOT necessary to include this definition in your solution to the problems below.
def printNString(a, n):
print n*a
Note, however, that the above example is unusual. Most of the functions you need to define in these on-line problems do not use print but instead return a value using return.
----------------------------
here's what i wrote:
def printSquareStar():
----def printNString(a, n):
--------i = 0
--------while int(n) != i:
------------print a
------------i = i + 1
----printNString('****', 4)
----------------------------
but i keep getting this error:
Here are the results of your input on the test cases:
****
****
****
****
Test case is:
Your input produces:
the correct result is:
****
****
****
****
wrong - TRY AGAIN
-----------------------------
now i don't know what to do.
please help.