LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 10-07-2019, 07:00 AM   #1
Gyroman
Member
 
Registered: Nov 2014
Location: Australia
Distribution: Mint 19.1 Toshiba Satellite Pro R50-C
Posts: 108
Blog Entries: 5

Rep: Reputation: 1
Python Syntax Error


Very simple Python question

This code comes at the beginning of a program before a while statement

Code:
A = int(input("A ="))
N = int(input("N ="))

PrN = (1/A)*(((N-N/A)/N)
imp = 1/PrN
when run produces
Code:
imp = 1/PrN
  ^ Syntax Error
Why is this a syntax error?
 
Old 10-07-2019, 07:26 AM   #2
Ser Olmy
Senior Member
 
Registered: Jan 2012
Distribution: Slackware
Posts: 3,339

Rep: Reputation: Disabled
Mismatched number of parentheses:
Quote:
Originally Posted by Gyroman View Post
Code:
PrN = (1/A)*(((N-N/A)/N)
imp = 1/PrN
 
1 members found this post helpful.
Old 10-07-2019, 09:32 AM   #3
teckk
LQ Guru
 
Registered: Oct 2004
Distribution: Arch
Posts: 5,137
Blog Entries: 6

Rep: Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826Reputation: 1826
Whole thing is a mess.

Code:
>>> A = 5
>>> N = 2
>>> PrN = ((1/(A))*((N)-((N)/(A)))/(N))
>>> imp = (1/(PrN))
>>> print(imp)
6.249999999999999
 
Old 10-07-2019, 03:39 PM   #4
Gyroman
Member
 
Registered: Nov 2014
Location: Australia
Distribution: Mint 19.1 Toshiba Satellite Pro R50-C
Posts: 108

Original Poster
Blog Entries: 5

Rep: Reputation: 1
Quote:
Originally Posted by teckk View Post
Whole thing is a mess.

Code:
>>> A = 5
>>> N = 2
>>> PrN = ((1/(A))*((N)-((N)/(A)))/(N))
>>> imp = (1/(PrN))
>>> print(imp)
6.249999999999999
Yes it was a mess but brackets around individual variables are unnesessary and confusing..

PrN = (1/A)*((N-N/A)/N)

works fine thank you.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Python Installed; bash command: python base.py. gets syntax error in base.py cre84j Linux - Software 4 01-23-2011 04:46 PM
[python] syntax Error : invalid syntax Python_user Programming 2 09-06-2009 12:52 PM
LXer: Python Python Python (aka Python 3) LXer Syndicated Linux News 0 08-05-2009 08:30 PM
[SOLVED] "Error: syntax before '@' token and Error: syntax at 'OTHER' token" bullrider Programming 2 07-27-2009 08:00 AM
C++ syntax error before :: token HELP, i cant find the syntax error :( qwijibow Programming 2 12-14-2004 06:09 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 06:11 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration