Re: Nested Loop Code Help

2020-01-26 Thread ferzan saglam
On Sunday, January 26, 2020 at 3:26:40 PM UTC, Dan Purgert wrote:
> -BEGIN PGP SIGNED MESSAGE-
> Hash: SHA256
> 
> ferzan saglam wrote:
> > Hello people, I have written the code below which works fine, but it
> > has one small problem. Instead of printing one (x) on the first line,
> > it prints two.
> > I have tried everything in my knowledge, but cannot fix the problem.
> > Thanks for any help in advance.  
> 
> either take the initial "stars = x" out, or increment stars after you
> print it.  Either approach should give you the result you want.
> 
> -BEGIN PGP SIGNATURE-
> 
> iQEzBAEBCAAdFiEEBcqaUD8uEzVNxUrujhHd8xJ5ooEFAl4tr5sACgkQjhHd8xJ5
> ooGt+AgArjEk3CIPLvX36SBhZjnjOCdpTXpvzjZDePgMcAJT3WZTweIVmF+JyV6w
> xS7kSI/pjmReP/BTH6XGdcJiqsyKeOh5C1D5HgCYFNsuXcegCd1j7PvKlQ/3tVFz
> MZUhT46PtWK04Er/Hj4IHUdvP+IRu5HNeUozcWHPlSV9VJmfOd5e94s/cV7Mx5HA
> d1p+GHrhS3VDIqY0MBxm3r9A6ciKjys328YpiUpIRfTIX8uUEYWPhNRr3UcIHLBC
> ilgZUV5evyr5CXFIET5UKEw4QD0eMLy3T6o2VqR5HsrgAgFW95RTWXNA+qWw+spV
> t/grPnMpZ8Cjw5TTbmFYYIrvEyJ+WQ==
> =ern6
> -END PGP SIGNATURE-
> 
> -- 
> |_|O|_| 
> |_|_|O| Github: https://github.com/dpurgert
> |O|O|O| PGP: 05CA 9A50 3F2E 1335 4DC5  4AEE 8E11 DDF3 1279 A281

Thanks for the help Dan, your suggestion worked.
-- 
https://mail.python.org/mailman/listinfo/python-list


Nested Loop Code Help

2020-01-26 Thread ferzan saglam
Hello people, I have written the code below which works fine, but it has one 
small problem. Instead of printing one (x) on the first line, it prints two.
I have tried everything in my knowledge, but cannot fix the problem.
Thanks for any help in advance.  


for x in range ( 0, 10):

  stars = 'x'   
  count = 0 

while count < x:
  stars = stars + 'x'   
  count = count + 1 
  print (stars)



Output I am trying to get Output I am getting
x xx
xxxxx
xxx   
  x
x xx
xxxxx
xxx   
  x
x xx
xx
-- 
https://mail.python.org/mailman/listinfo/python-list


JavaScript Calculator Program

2019-12-07 Thread ferzan saglam
Hi People, I am working on a simple calculator which uses operands (+-*/).
The program allows me to choose an operand and enter the first two values, but 
when it gets to doing the maths, it gives me an error on 
"console.log ("The result is ", res);" under the + operand.
(error code reads: Println is not a function)

Any help will be much appreciated. 
Thanks in advance.

---

console.log ("1. Add numbers"); 

console.log("2. Subtract numbers"); 

console.log("3. Multiply numbers"); 

console.log("4. Divide numbers");   


console.log = prompt("What's your choice?");


var num1 = prompt("Enter the first number ");   

firstnumber = prompt;   

var num2 = prompt("Enter the second number ");  

secondnumber = prompt;  

var choice; 
var res;

if (choice == 1);   
result = (num1 + num2); 

console.log ("The result is ", res);


if (choice == 2);   
result = (num1 - num2); 

console.log ("The result is = ", res);  


if (choice == 3);   
result = (num1 * num2); 

console.log ("The result is = ", res);  


if (choice == 4);   
result = (num1 / num2); 

console.log ("The result is = ", res);

---
-- 
https://mail.python.org/mailman/listinfo/python-list


Restaurant Bill

2019-10-31 Thread ferzan saglam
The code below which I have written should print the result of 43.6 with the 
given values I have included at the end of this question, but for some odd 
reason I get the result of 41.8.



print('Enter the total cost of the meal')   

Total_cost= input() 

print('Enter how much the tip is')  

Tip= input()

print('Enter how many people there are')

People= input() 

Total_cost = (Tip + Total_cost) / People


print('Each person will have to pay')   

print(Total_cost)   

Total_cost = (Total_cost * 9) / 100



I am aiming for the result of 43.6, but somehow get the result of 41.8.
(meal cost: 200) (Tip: 9) (people: 5)
(Total * Percentage Amount / 100)

I seem to be implementing the correct equation, but instead of obtaining the 
result of 43.6, I get the result of 41.8.
-- 
https://mail.python.org/mailman/listinfo/python-list


Restaurant Bill

2019-10-31 Thread ferzan saglam
The code below which I have written should print the result of 43.6 with the 
given values I have included at the end of this question, but for some odd 
reason I get the result of 41.8.



print('Enter the total cost of the meal')   

Total_cost= input() 

print('Enter how much the tip is')  

Tip= input()

print('Enter how many people there are')

People= input() 

Total_cost = (Tip + Total_cost) / People


print('Each person will have to pay')   

print(Total_cost)   

Total_cost = (Total_cost * 9) / 100



I am aiming for the result of 41.8, but somehow get the result of 44.44.
(meal cost: 200) (Tip: 9) (people: 5)
(Equation: Total * Percentage Amount / 100)

I seem to be implementing the correct equation, but instead of 43.6, I am 
getting the result of 41.8?.
-- 
https://mail.python.org/mailman/listinfo/python-list


Restaurant Bill

2019-10-31 Thread ferzan saglam
The code below which I have written should print the result of 43.6 with the 
given values I have included at the end of this question, but for some odd 
reason I get the result of 44.44.


print('Enter the total cost of the meal')   

Total_cost= input() 

print('Enter how much the tip is')  

Tip= input()

print('Enter how many people there are')

People= input() 

Total_cost = (Tip + Total_cost) / People


print('Each person will have to pay')   

print(Total_cost)   

(Total_cost * 9) / 100



I am aiming for the result of 43.6, but somehow get the result of 41.8.
(meal cost: 200) (Tip: 9) (people: 5)

I seem to do the calculation below, but get different results each time.
Total * Percentage Amount / 100
-- 
https://mail.python.org/mailman/listinfo/python-list


Calculations and Variables

2019-10-31 Thread ferzan saglam
The code below which I have written should print the result of 43.6 with the 
given values I have included at the end of this question, but for some odd 
reason I get the result of 44.44.


bill = (input("Enter the total cost of the meal: \n"))  

tip = (input("Enter how much the tip is: \n"))  

split = (input("Enter how many people there are: \n"))  

total = bill + (bill / tip) 

eachPay = total / split 
print("Each person will have to pay %.2f" % eachPay)



I am aiming for the result of 43.6, but somehow get the result of 44.44.
(meal cost: 200) (Tip: 9) (people: 5)

I seem to do the calculation below, but get different results each time.
Total * Percentage Amount / 100
-- 
https://mail.python.org/mailman/listinfo/python-list


Re: How can i stop this Infinite While Loop - Python

2019-10-30 Thread ferzan saglam
On Wednesday, October 30, 2019 at 2:19:32 PM UTC, Matheus Saraiva wrote:
> m 30/10/2019 08:55, ferzan saglam escreveu:
> > total = 0
> > while True:
> >
> >print('Cost of item')
> >item = input()
> >
> >if item != -1:
> >  total += int(item)
> >else:
> >  break
> >
> > print(total)
> The program does not stop because its code does not contain any deals 
> that make the loop stop after 10 rounds. You can simply implement a 
> counter that counts the number of times the loop has passed.
> 
> You also did not convert item to int to make the comparison.
> 
> total = 0
> rounds = 0
> while rounds <= 10:
> 
>    print('Cost of item')
>    item = input()
> 
>    if int(item) > -1:
>      total += int(item)
>      rounds += 1
>    else:
>      break
> 
> print(total)



Thanks, it Works superbly. 
To get the limit of 10 i wanted, i had to make a slight change: 
while rounds <= 9 .
-- 
https://mail.python.org/mailman/listinfo/python-list


How can i stop this Infinite While Loop - Python

2019-10-30 Thread ferzan saglam
I have tried many ways to stop the infinite loop but my program doesn't seem to 
stop after 10 items! It keeps going...!)

---
total = 0   
while True: 

  print('Cost of item')
  item = input()

  if item != -1:
total += int(item)  
  else: 
break   

print(total)
---


The output I am aiming for is for the code to stop asking 'Cost of item' after 
10 inputs or until -1 is typed, but the code repeats itself on an infinite 
loop. I cannot seem to stop the infinite loop.

Thanks for any help in advance.
-- 
https://mail.python.org/mailman/listinfo/python-list


(New to Python) Shopping List Code

2019-10-28 Thread ferzan saglam
How can I stop this code when -1 is typed or at a maximum item count of ten.
At the moment the code seems to be in a infinite loop meaning it keeps on 
asking for an entry until -1 is typed 


total = 0   
while True: 

  print('Cost of item') 

  item = input()

  if item != -1:
total = total + item

  if item == -1:

  break 

print(total)
-- 
https://mail.python.org/mailman/listinfo/python-list