### Thread: Newbie here..and im desperate..

Page 1 of 2 12 Last
1. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0

#### Newbie here..and im desperate..

I was given this algorithm to do in python and I cant even get thru the first part...Im getting a syntax error for the equal sign im using.

I need to write an algorithm that, given an input integer N, prints the following pattern. The first line of the pattern has N stars. The next line has N-1 stars, the next has N-2 stars and so ontill there is only one star to be printed. You may print a star using the command "print". You may print a new line character using command "print NEWLINE". What is the time compexity of this algorithm in Big O notation?
Heres an example pattern for N=5
*****
****
***
**
*

Any help will be greatly appreciated

also, can someone point me in the right direction on this program...

I need to write a program that calculates the total amount of a meal purchased at a restaurant. The program should ask the user to enter the charge for the food, and then calculate the amount of 20% tip, and 8.75 % tax.
2. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Location
U.S A.Z.
Posts
24
Rep Power
0
You might get more help if you post what code you have.
3. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0
Originally Posted by knutrainer
You might get more help if you post what code you have.
it was pseudo code, and then i wass asked to implement it in python
4. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Location
U.S A.Z.
Posts
24
Rep Power
0
You said you were getting a syntax error?
5. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0
Originally Posted by knutrainer
You said you were getting a syntax error?
yes.

for i = N to 1

the equal sign is returning an error
6. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Location
U.S A.Z.
Posts
24
Rep Power
0
for i = N to 1? This isn't even close to correct. I think you need to do your own home work but here I have tried to at least set you on the right path. I put ? marks in so I didnt complete your assignment for you.

Code:
```n = raw_input('Enter number: ')
n = ???(n)
while n ?? 0:
print n ? '*'
n ?? 1```
7. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0
Originally Posted by knutrainer
for i = N to 1? This isn't even close to correct. I think you need to do your own home work but here I have tried to at least set you on the right path. I put ? marks in so I didnt complete your assignment for you.

Code:
```n = raw_input('Enter number: ')
n = ???(n)
while n ?? 0:
print n ? '*'
n ?? 1```
n = ???(n)

Im stumped here. Everything else is ok..
8. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Location
U.S A.Z.
Posts
24
Rep Power
0
If you use raw_input to get a number you have to convert that input to an integer. Variables stored using raw_input are string values. If you try subtract by one from the variable N you would get an error.
9. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0
Originally Posted by knutrainer
If you use raw_input to get a number you have to convert that input to an integer. Variables stored using raw_input are string values. If you try subtract by one from the variable N you would get an error.
wow, you just confused me. I was inputting the number after the parenthesis...
10. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0
i cant get it to work. Thanks though.
11. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Location
U.S A.Z.
Posts
24
Rep Power
0
Ok try to remove the n = ???(n) and see what happens when you run the code.
12. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0
Originally Posted by knutrainer
Ok try to remove the n = ???(n) and see what happens when you run the code.
Nothing. I give up.
13. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Location
U.S A.Z.
Posts
24
Rep Power
0
You get an error. Right? Well you should because n needs to be converted to an integer. How do you convert an str value to an int value?
14. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Dec 2012
Posts
10
Rep Power
0
Originally Posted by knutrainer
for i = N to 1? This isn't even close to correct. I think you need to do your own home work but here I have tried to at least set you on the right path. I put ? marks in so I didnt complete your assignment for you.

Code:
```n = raw_input('Enter number: ')
n = ???(n)
while n ?? 0:
print n ? '*'
n ?? 1```
n = raw_input('Enter number: ')

Do i type this in python as it is exactly with spaces and all?
or do input my own number?
15. No Profile Picture
Registered User
Devshed Newbie (0 - 499 posts)

Join Date
Jun 2005
Location
U.S A.Z.
Posts
24
Rep Power
0
Enter it into python as is. When you do it will then ask you to enter a number. Pick any number you want.
Page 1 of 2 12 Last