0% found this document useful (1 vote)
1K views54 pages

CS 1101 - AY2020-T5 - Discussion Forum Unit-1

The student ran some simple Python code statements and provided explanations for the outputs. The outputs indicated the student was using Python 3 rather than Python 2 based on needing parentheses for print statements and other syntax differences. The student received positive feedback praising the detailed explanations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
1K views54 pages

CS 1101 - AY2020-T5 - Discussion Forum Unit-1

The student ran some simple Python code statements and provided explanations for the outputs. The outputs indicated the student was using Python 3 rather than Python 2 based on needing parentheses for print statements and other syntax differences. The student received positive feedback praising the detailed explanations.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 54

Here is our first discussion scenario:

Programming languages like Python are formal languages with strict syntax rules. But those rules
can change over time with newer versions of the programming language. Your textbook covers
Python 3, but you may only have access to Python 2. 

Download and install a working Python environment, preferably Python 3, or get an account with the
Virtual Computer Lab or PythonAnywhere. Refer to the Software Requirements/Installation section
of the course syllabus for details.

Type the statements below into your Python interpreter. For each statement, copy the output into
your Discussion Assignment and explain the output. Compare it with any similar examples in the
textbook, and describe what it means about your version of Python. 

>>> print 'Hello, World!'


>>> 1/2

/
>>> type(1/2)
>>> type(1/2)
>>> print(01)
>>> 1/(2/3) 

When you reply to your peers’ submissions, compare their results with yours.

Cheers,

148 words

Permalink

Re: Discussion Forum Unit-1


by Mathew Ojo - Friday, 19 June 2020, 1:50 AM

>>> print 'Hello, World!'


SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?

The statement above means that the print value requires the inclusion of parentheses to make
it a function in the statement.

>>> 1/2
0.5
The output 0.5 indicates that its a floating-point number.

>>> type(1/2) Class in the output indicate the category of the value which is float as in floating-
point number.

>>> print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

The statement above means that having a leading zero in integer statement in python is not
allowed.

>>> 1/(2/3)
1.5
The output 1.5 indicates that its a floating-point number.

From the example print('Hello, World!') in chapter 1 under section 1.3 the first program in Think
Python by (Downey 2015), and getting the same output in the interpreter as the example given
it means that I use the version of Python 3. 
161 words
/
Permalink Show parent

Re: Discussion Forum Unit-1


by Virgil Vega - Friday, 19 June 2020, 3:33 AM

Awesome! You were able to show that you're using Python 3 instead of Python 2.

Weren't you supposed to explain the output though, instead of just saying what it was?
30 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Saturday, 20 June 2020, 6:17 AM

Good work
Explicit, but try explaining in more detailed manner

Good reference
Try better next time
16 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Saturday, 20 June 2020, 5:27 PM

Hi

you have answered all the questions correcly which is great, but i think you needed to add
more explanation into the answeres
23 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Mark Tanyous - Sunday, 21 June 2020, 4:32 AM

You did great about your summary and talk about the output of every statement but you
forgot to explain the output instead of saying what it was?
But you did great good job.
33 words

Permalink Show parent



/
Re: Discussion Forum Unit-1
by Dhaval Patel - Monday, 22 June 2020, 11:10 PM

I have same answer, as I am also using python 3.

11 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Leul Gebremichaele - Tuesday, 23 June 2020, 6:32 AM

it is very clear
4 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Preyesh Hirachan - Thursday, 25 June 2020, 9:12 AM

Good job,
It would be better if the explaination was more seperated.
Lets go Python!
15 words

Permalink Show parent

Simple Tests
by Virgil Vega - Friday, 19 June 2020, 3:21 AM

The assignment was to run some simple lines of code and explain the output.

The first line of code and its output was this:

>>> print 'Hello, World!'


File "<stdin>", line 1
print 'Hello, World!'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, Worl
d!')?

"File "<stdin>", line 1" Points to something in the first line of code. 

The "print 'Hello, World!'" and the "^" underneath the first quotation mark point to a specific
character. 

Finally, the "SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, 
World!')?" Shows that there was an error in that specific line of code at that specific character. It /
gives a "SyntaxError", tells you what it was expecting or what it's probably missing (A
parentheses), and gives a suggestion as to what you might have meant.

All of this happened because this line of code was run on Python 3, instead of Python 2. In
Python 3 "print" is a function, and requires the correct syntax of a function (Parentheses after
it's name).  "In Python 2, the print statement is slightly different; it is not a function, so it doesn’t
use parentheses." (Downey, A. (2016). Think Python.) If this line of code was run on Python 2,
the result would be: "Hello, World!"

The second line of code and its output was:

>>> 1/2
0.5

Python took the first integer, the operator, and the second integer, and translated it into "0.5".

The third line of code and its output was:

>>> type(1/2)
<class 'float'>

"type()" Is a function that asks Python what type of value is inside of the parentheses. In this
case "1/2" was inside of the parentheses. "1/2" isn't a single value, it's two values that need to
be simplified, so python does that, and simplifies it into "0.5", a "floating-point number"
(Downey, A. (2016). Think Python.). "0.5", the result of "1/2", is a floating-point number, and so
Python returns "<class 'float'>." "class" is "the type of value", and "float" is a shortened form of
"floating-point number."

The fourth line of code and its output was:

>>> print(01)
File "<stdin>", line 1
print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o
prefix for octal integers

As stated before, Python points to a specific character in a specific line of code ("1"), gives an
error ("SyntaxError"), and tells you what the error is ("leading zeros in decimal integer literals
are not permitted"). This time it doesn't give you a suggestion though, instead it tells you to type
"0o" at the beginning, the correct syntax for starting an integer with 0.

The last line of code and its output was:



/
>>> 1/(2/3)
1.5

Python follows the order of operations, meaning that it divided 2 and 3 first, then divided 1 by
the result.

I performed some simple tests, and explained the outputs. Because of certain outputs, I am
able to state that I am using Python 3, and not Python 2.

497 words

Permalink Show parent

Re: Simple Tests


by Mathew Ojo - Friday, 19 June 2020, 3:43 AM

Excellent! Your explanations are very insightful and relevant to the questions. I grade you
10 (A).
16 words

Permalink Show parent

Re: Simple Tests


by Tofunmi Adegoke - Saturday, 20 June 2020, 6:15 AM

Really good work


Keep up
Excellent! 10
Well explained Nice one
11 words

Permalink Show parent

Re: Simple Tests


by Adrian Davies - Saturday, 20 June 2020, 5:29 PM

hi

i really like your work it is very well put together with great explanations
15 words

Permalink Show parent

Re: Simple Tests 


by Lex Yuditskiy - Saturday, 20 June 2020, 7:12 PM /
Nice! Very detailed answer!
4 words

Permalink Show parent

Re: Simple Tests


by Mark Tanyous - Sunday, 21 June 2020, 4:35 AM

Excellent
Your explanations is great you explain every statement in a good way also helped me to
understand everything
I graded you 10
Very good Virgil
26 words

Permalink Show parent

Re: Simple Tests


by Chuan Wei Chai - Sunday, 21 June 2020, 4:11 PM

A detailed and informative assignment. Explained how Phyton parse the statement step by
step.
14 words

Permalink Show parent

Re: Simple Tests


by Amanda Feliu - Monday, 22 June 2020, 7:19 AM

I very much like the explanations here and the detailed manner of it all. Also very readable!
The differentiation of Python 2 and 3, is very well welcomed. 10/10. I do like the ease that
you were able to explain the floating number, type, and value. Excellent!
48 words

Permalink Show parent

Re: Simple Tests


by Cesar Castro - Monday, 22 June 2020, 8:25 AM

Your answer was very clear and very well explained. I loved the way you formatted your
text, which makes the reading pretty easy for us. Nice job!
27 words

Permalink Show parent



/
Re: Simple Tests
by Leul Gebremichaele - Tuesday, 23 June 2020, 6:33 AM

You did explain


very well
5 words

Permalink Show parent

Re: Simple Tests


by Deborah Adewumi - Wednesday, 24 June 2020, 7:04 PM

Detailed answer. Easy to comprehend. Nice job.


7 words

Permalink Show parent

Re: Simple Tests


by Faiza Sheikh - Wednesday, 24 June 2020, 8:02 PM

excellent insight, you have organized the assignment in perfect form.


comparing your work with mine i think you explained more than what i capable of writing
26 words

Permalink Show parent

Re: Simple Tests


by Preyesh Hirachan - Thursday, 25 June 2020, 9:14 AM

Very detailed explaination . The presentation is also so easy to understand and very
detailed!
It makes learning python interesting.
Good Job!
21 words

Permalink Show parent

Re: Simple Tests


by Sahar Alhammadi - Thursday, 25 June 2020, 11:57 AM

Hello Virgil
You have done very good work, easy and understood explanation. Each statement you
have run are totally correct and clear enough. Again you have done an excellent work.
Good luck

/
Greetings
33 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Austin Nkomeshya - Saturday, 20 June 2020, 12:18 AM

Python 3.8.3

>>> print'hello, world!'


SyntaxError: invalid syntax
>>> 1/2
0.5
>>> type(1/2) >>> print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers
>>> 1/(2/3)
1.5
37 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Saturday, 20 June 2020, 6:13 AM

Not finished
Nice explanation, but not detailed enough
37 words is not so good for explaning the assignment
Try better next time
22 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Saturday, 20 June 2020, 5:34 PM

hi

you need to add more explanations to your answers in the print 'hello world' why did you
get the error? what can you do to solve it. go have a read of what people have posted and
how they have answered the questions and come back next week with a great reply
53 words

Permalink Show parent /
Re: Discussion Forum Unit-1
by Mathew Ojo - Saturday, 20 June 2020, 10:28 PM

Incomplete, you need to explain in detail and attempt all questions as stated.
13 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Mark Tanyous - Sunday, 21 June 2020, 4:39 AM

Austin
You didn't finish the assignment and you did not do what was required.
You can try again it's very easy.
21 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Cesar Castro - Monday, 22 June 2020, 8:35 AM

Hey Austin,

You should have explained a little more about every command line you executed and the
syntax errors that you came up with some of them. It was also expected to see a
comparison of the Python version you used with others.
43 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Leul Gebremichaele - Tuesday, 23 June 2020, 6:34 AM

Not in depth make it more detailed


7 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Roger Hoffman - Thursday, 25 June 2020, 2:26 AM

Leading zeros is confusion for Python unless it is string.


10 words

Permalink Show parent
/
Re: Discussion Forum Unit-1
by Preyesh Hirachan - Thursday, 25 June 2020, 9:48 AM

Hi Austin,
You have all the exact syntax as you were asked to do. However, detailed explaination
would be very helpful for people to understand. Lets make learning python easy by giving
details to begineer like me.
Good Job
39 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Sahar Alhammadi - Thursday, 25 June 2020, 12:00 PM

Hello Austin

You have not done your task yet, you need also to provide clear explanation or feedback of
your work.
Greetings
22 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Saturday, 20 June 2020, 5:41 AM

File "", line 1


print'Hello,World!'
^
SyntaxError: invalid syntax
>>>

Explanation:In python 3, parentheses(brackets) is needed to indicate that "print" is a


function.Here,there is no parentheses so, print without parentheses preceeding it is an an
invalid syntax
39 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Saturday, 20 June 2020, 6:01 AM

>>> print 'Hello, World!'


/
O t t
Output:
File "", line 1
print'Hello,World!'

^
SyntaxError: invalid syntax
>>>

Explanation:In python 3, parentheses(brackets) is needed to indicate that "print" is a


function.Here,there is no parentheses so, print without parentheses preceeding it is an an
invalid syntax

>>> 1/2
Output: 0.5
0.5 which is the result is displayed because, the right operator (/),which denotes division is used
rightly.

>>>type (1/2)
Output:<class 'float'>
>>>
1/2 is a value of the type "floating point number"
Which is denoted with <class 'float'>,values that are fractions or decimal numbers are generally
of the type" floating point number"
>>>Print(01)
Output:File "<stdin>", line 1
  print(01)
         ^
SyntaxError: invalid token
>>>
In normal mathematics, 01 essentially mean 1, but in programming,it is completely different.
(Reference : Think python)
In the interpreter,1 is a token,01 is not,it is not part of the syntax or structure of the
programming language interpreter by my program interpreter

>>> 1/(2/3) 
1.5
Since the operator ,/ which is division sign in maths is used correctly,the interpreter displays it
correctly.1/(2/3) is the inversely of 2/3 equals 3/2 which is 1.5.

What I learnt
Correct applications of operators leads to programs without bugs
202 words

Permalink Show parent 


/
Re: Discussion Forum Unit-1
by Dhaval Patel - Monday, 22 June 2020, 11:15 PM

Nice work in explaining the outputs with great detail, keep up the good work.

14 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Wednesday, 24 June 2020, 1:11 AM

Thanks
1 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Iman Khaireddin - Wednesday, 24 June 2020, 8:47 AM

Your explanation is very good , it is clear and detailed.

Wish you the best 

14 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Deborah Adewumi - Wednesday, 24 June 2020, 7:06 PM

Nice job. A very clear explanation. Keep it up.


9 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Faiza Sheikh - Wednesday, 24 June 2020, 8:06 PM

great work with explaining it is clear. though i wasn't able to provide explanation of of the
last one because i didn't understand.
23 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Sahar Alhammadi - Thursday, 25 June 2020, 12:02 PM

/
Hello Tofunmi

You have done your task very good and provided them with clear explanation. Wish you
good luck and more progress.

Greetings
23 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Saturday, 20 June 2020, 6:01 AM

>>> print 'Hello, World!'


Output:
File "", line 1
print'Hello,World!'
^
SyntaxError: invalid syntax
>>>

Explanation:In python 3, parentheses(brackets) is needed to indicate that "print" is a


function.Here,there is no parentheses so, print without parentheses preceeding it is an an
invalid syntax

>>> 1/2
Output: 0.5
0.5 which is the result is displayed because, the right operator (/),which denotes division is used
rightly.

>>>type (1/2)
Output:<class 'float'>
>>>
1/2 is a value of the type "floating point number"
Which is denoted with <class 'float'>,values that are fractions or decimal numbers are generally
of the type" floating point number"
>>>Print(01)
Output:File "<stdin>", line 1
  print(01)
         ^
SyntaxError: invalid token
>>>
In normal mathematics, 01 essentially mean 1, but in programming,it is completely different. 
(Reference : Think python) /
In the interpreter,1 is a token,01 is not,it is not part of the syntax or structure of the
programming language interpreter by my program interpreter

>>> 1/(2/3) 
1.5
Since the operator ,/ which is division sign in maths is used correctly,the interpreter displays it
correctly.1/(2/3) is the inversely of 2/3 equals 3/2 which is 1.5.

What I learnt
Correct applications of operators leads to programs without bugs
202 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Mathew Ojo - Saturday, 20 June 2020, 10:41 PM

Good, but your explanation is not well detailed. The last question states that we should
explain what the results mean to our version of Python which could either be Python 2 or
Python 3 based on the output you get from the interpreter. B (8)
45 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Sunday, 21 June 2020, 5:57 AM

Ok thanks
Wanted to add it but time wasn't enough to edit
Thanks!
13 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Amanda Feliu - Monday, 22 June 2020, 7:21 AM

I do think you did a good job, but I agree with Mathew that it would need a bit
more explanation. Other than that, good job and I look forward to your next
forum discussion post. :)
36 words

Permalink Show parent


Re: Discussion Forum Unit-1 /
by Tofunmi Adegoke - Monday, 22 June 2020, 11:44 PM

Thank you

2 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Roger Hoffman - Thursday, 25 June 2020, 2:27 AM

From what I understand, the latest version of Python doesn’t not need parenthesis.
13 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Saturday, 20 June 2020, 5:02 PM

Discussion Forum Unit 1


Type the statements below into your Python interpreter. For each statement, copy the output
into your Discussion Assignment and explain the output. Compare it with any similar examples
in the textbook, and describe what it means about your version of Python.

Statment 1

>>> print 'Hello, World!'

File "<stdin>", line 1

print 'Hello, World!'

SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?

This print statement print 'Hello, World!' produced a syntax error because the python version
used is 3.8 and the correct syntax would need parentheses and would be formatted like this
print ('Hello, World!'). If we run this statement in the python 3.8 interpreter, we will get this
result.

>>> print('Hello, World!')

Hello, World!

Statement 2

>>> 1/2 
0.5 /
This statement uses an operator, an operator is normally a mathematical function, the operator
used in this example is the division operator / and if you divide 1 by 2 is the result is equal to
0.5.

other examples of operators are as follows:

>>> 40 + 2

42

This statement uses the addition operator.

>>> 43 – 1

42

This statement uses the subtraction operator.

>>> 6 * 7

42

This statement uses the multiplication operator.

Statement 3

>>> type(1/2)

<class 'float'>

This statement returns the type of value, the value of the expression 1 / 2 is a float because the
result of the mathematical operation is 0.5. A float is defined as a number that has a fractional
part.

we can also find other class values using, the type () function and can be seen below:

type(1)
<class 'int'>

The type of value is as an integer.

type('string')

<class 'str'>

returns type of value as a string.

Statement 4

>>> print(01)

File "<stdin>", line 1



print(01)
/
^

SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

This print statement produced an error because in python an integer cannot start with a
leading zero, nor can it be a variable because variables cannot start with a numeric character. If
we need to print 01 we could output the value as a string and use print ('01').

print('01')

01

Statement 5

>>> 1/(2/3)

1.5

This statement performs a computation on the expression 1/(2/3). The interpreter will follow
the standard order of operations BODMAS and will perform the division first (2 / 3) because the
parentheses has to be calculated first, the next step in in the calculation is to divide 1 /
0.6666666666666666 which is equal to 1.5.

Reference:

Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tea Press. This
book is licensed under Creative Commons Attribution-NonCommercial 3.0 Unported (CC BY-NC
3.0).

450 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Lex Yuditskiy - Saturday, 20 June 2020, 7:13 PM

Excellent. 10/10
3 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Mathew Ojo - Saturday, 20 June 2020, 10:47 PM

Insightful and well detailed. 10/10 /
6 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Chuan Wei Chai - Sunday, 21 June 2020, 4:08 PM

Very detailed explanation with extra examples shown as well. Great effort and work!
13 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Virgil Vega - Monday, 22 June 2020, 5:14 AM

Awesome! You could also just ask it to print(0o1), but I'll bet you already knew that. I love
how you tried the 'Hello, World' statement in Python 2 and Python 3!
32 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Amanda Feliu - Monday, 22 June 2020, 7:09 AM

This is a very clear and concise! I personally love that there's a lot of explanation. It's very
user friendly if someone was looking at this with fresh eyes.
29 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Tuesday, 23 June 2020, 4:17 AM

thanks i am glad you liked it


7 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Abdulbasit Rubeiyya - Wednesday, 24 June 2020, 6:25 PM

that was so insightful, and very detailed explanation, keep up with the good work
14 words

Permalink Show parent



/
Re: Discussion Forum Unit-1
by Faiza Sheikh - Wednesday, 24 June 2020, 8:10 PM

i like how you explained everything in details. i didn't provide explanation of the last one
cause i didn't understand though i had feeling it was like this.

it seems you are familiar with programming. excellent


36 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Roger Hoffman - Thursday, 25 June 2020, 2:28 AM

I also tried both single and double quotes to parse text and they both worked.
15 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Birikty Hagos - Thursday, 25 June 2020, 2:37 AM

Hi Adrian

You did great explaining and looks great.


9 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Preyesh Hirachan - Thursday, 25 June 2020, 9:52 AM

Hi Adrian,
Foremost thanks for the detailed explaination . It is very helpful for begineer like me to
understand aout some basic python. I also liked the presentation .The reference that you
have included makes it more perfect.. Way to go. Good luck for the course .
45 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Lex Yuditskiy - Saturday, 20 June 2020, 7:00 PM

>>> print 'Hello, World!'



SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')? /
Sy ta o : ss g pa e t eses ca to p t. d you ea p t( e o, o d! )?
Command "print" use with parentheses
>>>print('Hello, World!') this command correct

>>> 1/2
0.5
The operator " / " performs division
It's a similar command like >>>6*7

>>> type(1/2) By command type(x) we can determine class of sign in parentheses


Same command demand int and str class, for example
>>> type(2) give us result "int"

>>> print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers
We received Syntax Error because if we use integer numbers, must write it without 0 in start
>>>print(1) give us 1

>>> 1/(2/3)
1.5
Similar mathematical calculation. Before calculating in parentheses.
Another example from the book of compound calculation>>> 6**2 + 6 witches give us 42
138 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Chuan Wei Chai - Sunday, 21 June 2020, 4:21 PM

Well explained with solution given for statement with syntax error. Would be even better
to include explanation on differences between Python 2 and 3 for the first statement as
Python 2 is able to take the print statement without parentheses.
40 words

Permalink Show parent

Re: Discussion Forum Unit-1


by John Kovarik - Monday, 22 June 2020, 8:37 AM

Nice use of examples Lex!



/
5 words
5 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Roger Hoffman - Saturday, 20 June 2020, 10:38 PM

blob:https://www.icloud.com/79f2497f-2436-42f2-bfea-03178a9ff58d
6 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Roger Hoffman - Saturday, 20 June 2020, 11:01 PM

I’m running Python 3.8.0 in PythonAnywhere:

print ‘Hello, World!’

result: File "", line 1


print 'Hello, World!'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?

Obviously, it needs parenthesis to parse text.

1/2:

result: 0.5

Python has taken a fraction and converted it into decimal format.

type(1/2):
meaning after it parsed 1/2, Python determined it is a floating number or a decimal number.

print (01):

File "", line 1


SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

It has thrown a syntax error. Python does not allow for leading zeros for numerical data.

1/2/3: 
/
0.16666666666666666

It has taken 2, divided it by 1, and then divided 3 by the result. I’m assuming that is the

remainder. As you can see, fractional data entered literally would cause less than accurate
results as Python uses decimals only. It would be best to convert fractional data into decimal
before using it for calculations.
169 words

Permalink Show parent

Re: Discussion Forum Unit-1


by John Kovarik - Monday, 22 June 2020, 8:44 AM

Good concise answers!


I believe the last one was actually >>> 1/(2/3)
which would divide 1 by 2/3rds returning 1.5
22 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Cesar Castro - Sunday, 21 June 2020, 3:31 AM

PyDev console: starting.


Python 3.8.0 (default, Oct 28 2019, 16:14:01)
[GCC 8.3.0] on linux
------------------------------------------------------------------------------------------------------------------------------------------
--------
1) This command-line attempts to use the print statement to display the message "Hello,
World!" on the screen. The code has a syntax error because on Python 3 we need to wrap the
statement with parenthesis for the code to work properly.

>>> print 'Hello world!'

  File "<input>", line 1

    print 'Hello world!'

     ^

SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello world!')?

------------------------------------------------------------------------------------------------------------------------------------------
--------

2) This input represents an arithmetic operation, where the "/ "operator performs a division. 1
divided by 2, equals 0.5.

>>> 1/2

/
0.5

------------------------------------------------------------------------------------------------------------------------------------------
--------
3)  On Python 3 numbers that start with 0 are not accepted as valid numbers. We solve this
issue by wrapping 01 with brackets.

>>> print(01)

  File "<input>", line 1

SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o
prefix for octal integers

------------------------------------------------------------------------------------------------------------------------------------------
--------

4)  The input represents an arithmetic expression, in which the result is 1.5.

>>> 1/(2/3)

1.5

164 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Virgil Vega - Monday, 22 June 2020, 5:21 AM

I love the color coding! You didn't quite "describe what it means about your version of
Python" though.
18 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Amanda Feliu - Monday, 22 June 2020, 7:24 AM

The color coding is excellent. I do appreciate that, and it's readability. I did have the same
issue that I did not exactly provide what the version of Python meant, but this good.
33 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Mark Tanyous - Sunday, 21 June 2020, 4:19 AM

The first statement /
>>> print “Hello , World”
The output

File "", line 1


print "Hello, World"
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello, World")?
The output means there is something wrong in the structure of the statement, and told me that
I forgot to put parentheses, also help me rewrite the statement correctly.

The second statement

>>> 1/2
The output
0.5
This means that Python interpreter van used as a calculator too because we type 1/2 the result
is 0.5, also if we write 2+2 the results will be 4.

The third statement


>>> type(1/2)
The output
The type statement show us the type of the statement we did like, if we write type(2) this means
that the type of the statement and the result is belong to integers and integers means a
category of value, also the output here means a means a category of value.
The fourth statement
>>>print(01)
The output
File "", line 1
print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

This means that the zero cannot be used with decimal integer literals

The fifth statement

1/(2/3)

The output
1.5

/
This is a calculation because python interpreter can be used as a calculator.
217 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Dhaval Patel - Monday, 22 June 2020, 11:17 PM

Great job in explaining the output results, I have similar answer as I am also using python
3. Keep up the good work.

23 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Chuan Wei Chai - Sunday, 21 June 2020, 3:50 PM

Note: Orange highlight is input and blue highlight is output.

1) 

>>>print ‘Hello, World!’

File "<stdin>", line 1

print ‘Hello, World!’           


              ^

SyntaxError: Missing parentheses in call to 'print'. Did you mean print(‘Hello, World!’)?

>>> print('Hello, World!')

Hello, World

Explanation :

print ‘Hello, World!’ is a correct input statement for Python 2 but not for Python 3. Hence,
Python 3 displays an syntax error message when I type in the command as the missing
parentheses. So I updated the print statement with opening and closing parentheses : >>>
print('Hello, World!') to allow Python to compute the statement. Print statement display the
values in its parentheses Hello, World! In the output line

2)

>>> 1/2

0.5

Explanation :

Input 1/2 into Python then it will compute the input as 1 divided by 2 as / is a division operator

/
symbol in Python Hence the output value is 0 5 which is a float type value by default
symbol in Python. Hence, the output value is 0.5 which is a float type value by default.

3)

>>> type(1/2)

<class 'float'>

Explanation :

Type statement allow python to indicate the type of value in it, whether it is integer, string or
floating-point number type. 1/2 is categorized as floating-point number in Python.

4)

>>>print(01)

File "<stdin>", line 1

   print(01)

          ^

SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

Explanation:

Python is not able to take leading zeros in decimal integer. To display leading zero integer with
2 digits such as 01 at output, we can use the following code :

>>> print(f"{1:02d}")

01

5)

>>> 1/(2/3)

1.5

Explanation :

/ is the divide operator. By default, value in the bracket which is 2/3 will be computed first. So 2
is divided by 3. Then Python divide 1 over 2/3 to obtain the final output of 1.5.

292 words

Permalink Show parent

Re: Discussion Forum Unit-1



by Cesar Castro - Monday, 22 June 2020, 10:23 AM /
y y J

Hello Chai,

Your response provided a very insightful and clear explanation of the topic. You answered
all the questions correctly. You just forgot to tell us the exact version of Python and the IDE
you are using. Great job overall!
40 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Chuan Wei Chai - Monday, 22 June 2020, 5:08 PM

Thanks Cesar for your input. Will take note of the instruction in details next time.  :)
15 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Lex Yuditskiy - Monday, 22 June 2020, 8:19 PM

Nice explanation.
2 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Henry Dakat - Wednesday, 24 June 2020, 5:21 AM

Hi Chai,
I like how you detailed and highlight your post, good job.
13 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Deborah Adewumi - Wednesday, 24 June 2020, 7:11 PM

Your response is very Insightful and understandable.


7 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Abdulbasit Rubeiyya - Sunday, 21 June 2020, 8:06 PM 
/
For print 'Hello, World!' I got SyntaxError: Missing parentheses in call to 'print'. Did you
mean print('Hello, World!')?
19 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Tuesday, 23 June 2020, 4:23 AM

think you need to add some more content


8 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Birikty Hagos - Sunday, 21 June 2020, 11:04 PM

Here is my answer to the above qustion.

Statement >>> print 'hello, world'


Output File "", line 1
print 'hello, world'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean
print('hello, world')?

Explanation: It shows error due to missing parentheses. Because print displays the result on the
screen. The parentheses indicate that print is a function. Without parenthesis the output shows
an error.

Here is statement with parenthesis. The outcome shows hello, world with out error.
Statement >>> print ('hello, world'!)
Output hello, world!

Explanation: When hello world is placed in parenthesis (‘hello, world!’) the output changed to
hello, world!

Statement: >>> 1/2


Output: 0.5

Explanation: The function is fraction Input equal to Decimal 0.5

Statement: >>> type(1/2)


Output:

/
Explanation: Because type is defined as class.

Statement: >>> print(01)


Output: File "", line 1
print (01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers
Explanation: Number starting with o is not permitted. It needs to be changed to fraction.

Statement: >>> print(1/10)


Output: 0.1
Explanation: When 01 changed to decimal, the output changed to 0.1

Statement >>> 1/(2/3)


Output: 1.5
Explanation: The statement 1/(2/3) = 1 *3/2 = 1.5
200 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Wednesday, 24 June 2020, 9:18 AM

Nice work
You really did well
However,you probably unknowingly omitted to type the output of the statement

"Statement: >>> type(1/2)


Output:

Explanation: Because type is defined as class."

.... because type is defined as class floating point number should finish the sentence
However, I'll really love you explanations
49 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Birikty Hagos - Wednesday, 24 June 2020, 9:38 AM

Thanks for your suggestions.



/
I will work on it next time
I will work on it next time.
11 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Amanda Feliu - Monday, 22 June 2020, 4:31 AM

>>> print 'Hello, World!'


File "", line 1
print 'Hello, World!'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?
>>> As per the textbook, parenthesis are used to identify that print is a function. The quotation
marks, mark the beginning and the end of the text being displayed.
The correct function should be:
>>> print ('Hello, World!')
Hello, World!

>>> 1/2
0.5
This is preforming division via the Python operators, which has halved 1 into 0.5
>>> type(1/2) Because it is not an integer, any number with a decimal is to be a floating point
number. We are back at 0.5 once again. As another example, if >>>type (2) is used, there is the
different classification for integers. This is also able to be shown by
>>> type (2)
Again, the same difference is seen once more while typing in >>> type (2.0)
>>> print(01)
File "", line 1
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

Leading 0s are not permitted, for this function to work and keep it as an integer - it can be
written as such:
>>> print(1)
1
Or for octal integers
>>> print(0o1)

>>> 1/(2/3)
1.5
This equation is dividing (2/3) first, and then dividing it by 1. If using without the parenthesis as
making it a string, it will end up being >>> 1/2/3
0.16666666666666666 therefor not correctly divided.

/
236 words
236 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Amanda Feliu - Monday, 22 June 2020, 7:11 AM

I wanted to add to this that I was using Python 3.8.1.


13 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Tofunmi Adegoke - Wednesday, 24 June 2020, 9:20 AM

Good explanation
Keep up!
You really did well
Nice

You should have tried talking about you using python 3 and not 2
However,You explained superbly well
25 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Sahar Alhammadi - Monday, 22 June 2020, 6:32 AM

print 'Hello, World!'

Input: print 'Hello, World!'


Output: Hello, World!
The statement above is considered as a print statement. The program in both Python 3 and
Python 2 runs the statement into Hello, World without the parenthesis

To compare it to the example:


Input: >>> print ('hola!')
output: hola!
---------------------------------------------------------------------------------------------------------------------------------
1/2
Input: 1/2
Output: 0

/
The statement above is an arithmetic operation. The program in both Python 3 and Python 2
runs the same statement.

To compare to the example from the textbook:


Input: >>> 43 - 1
output : 42
---------------------------------------------------------------------------------------------------------------------------------
type(1/2)
Input: type(1/2)
Output:<type 'int'>
The statement above is an integer class. The program in both Python 3 and Python 2 runs the
same output.

To compare it to the example from the textbook:

Input: >>> type(2)

output: <class 'int'>

------------------------------------------------------------------------------------------------------------------------------------

>>> print(01)

Input: >>> print(01)

Output: 1

The statement above is considered as a print statement. The program in both Python 3 and
Python 2 runs the same output.

------------------------------------------------------------------------------------------------------------------------------------------

1/(2/3) 

Input: 1/(2/3) 

Output: ZeroDivisionError: integer division or modulo by zero

The above statement runs in both Python 2, 3 into an error, because we do not start a print
statement with numbers. Thus, to debugging the statement it has to be (2/3) without 1/

and the output will be 0.

==============================================================================

212 words 
/
Permalink Show parent

Re: Discussion Forum Unit-1


by John Kovarik - Monday, 22 June 2020, 8:32 AM

Nice Sahar! I really like your comparisons, it helps to see more output examples.

For >>> print 'Hello, World!'


I got a syntax error because python 3 requires parentheses for the print function. ex. >>>
print('Hello, World!') will return Hello, World! without a syntax error.

for >>> 1/2


python 3 returns 0.5, because it is solving for 1 divided by 2.

for >>> type(1/2) in python 3 'float' is returned because the answer to 1 divided by 2 is 0.5,
which is a floating-point.
Your comparison >>> type(2) is correct and returns
>>> print(01)
gives this
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers
You must remove the leading zero or use the "0o" prefix to avoid the error.

>>> 1/(2/3)
1.5
two thirds(2/3) goes in to one, 1.5 times
142 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Sahar Alhammadi - Monday, 22 June 2020, 12:58 PM

Thanks a lot John


I have noticed now through your notes that both programs I have are Python 2 and
that is why most of my runs turn incorrect. I know through reading the syllabus that
Hello, World occurs parenthesis, however it run correctly. Would you send me the link
to download Python 3
Thank you a lot I appreciated it

Greetings 
Sahar
/
63 words

Permalink Show parent

Re: Discussion Forum Unit-1


by John Kovarik - Tuesday, 23 June 2020, 8:40 AM

No problem Sahar!

you can use this address for browser based python 3


https://www.pythonanywhere.com/

or this one to download python 3


https://www.python.org/downloads/
29 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Sahar Alhammadi - Wednesday, 24 June 2020, 3:36 AM

Thanks a lot for your assistance John..


Greetings
Sahar
9 words

Permalink Show parent

Re: Discussion Forum Unit-1


by John Kovarik - Monday, 22 June 2020, 8:02 AM

>>> print 'Hello, World!'


SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?

It returns a syntax error because the parentheses are missing.


In python 3 the “quotation marks in the program mark the beginning and end of the text to be
displayed.” (Downey, 2015, p.3), and the parentheses tell python to return the value contained
inside of them. (Downey, 2015).

>>> 1/2
0.5

The / operator is used for division (Downey, 2015).


Python returned the quotient of 1 divided by 2 which equals 0.5 .

/
>>> type(1/2)

By calling type(), we are asking what kind of value this is between the parentheses, an integer,
floating-point number or a string.
A floating-point number is defined as: “A type that represents numbers with fractional parts”
(Downey, 2015, p.7).
Because the quotient of 1 divided by 2 is 0.5, that is a floating-point number and that is why
class ‘float’ was returned.

>>> print(01)
File "", line 1
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

If you want to return the integer 1 you can’t place a 0 in front of the number, that would be a
syntax error. You can put print(0o1) to avoid that syntax error, or simply remove the zero in
front of the one as print(1).

>>> 1/(2/3)
1.5

The / operator is used to perform division (Downey, 2015, p.3).


1.5 was returned because 1 divided by 2/3rds equals 1.5. I thought about it as, how many times
does 2/3rds go into 1? The answer is 1.5 times.

Downey, A. (2015). Think Python: How to think like a computer scientist. Needham, MA: Green
Tea Press.
285 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Birikty Hagos - Wednesday, 24 June 2020, 9:48 AM

John
Great Job. Your explanation and the result is correct.
10 words

Permalink Show parent



/
Re: Discussion Forum Unit-1
by Henry Dakat - Monday, 22 June 2020, 6:22 PM

Introduction to Unit 1 Discussion Assignment

So, I was curious then I use both of the version python 2 and python 3 for the assignment.


/
>>> print 'Hello, World!'
File "<stdin>", line 1
   print 'Hello, World!'
         ^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?

Thus, the print statement does not have parentheses and because I am using Python 3.

However, in chapter 1 of our reading material I saw a relation and explanation to the print
statement (Downey, 2015). 

The print statement here worked in Python 2 because it's not a function, so it doesn't use
parentheses.

>>> 1/2
0.5

The output shows that the Arithmetic operator performs a division and is similar to >>> 84 / 2
42.0 under chapter 1.4, Arithmetic operators (Downey, 2015). 

>>> type(1/2)
<class 'float'>

The output shows that the value 1/2 is a floating-point number and it is similar to >>> type(42.0)
<class'float'> under chapter 1.5, Values and types (Downey, 2015). 

>>> print(01)
File "<stdin>", line 1
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

The output shows that leading zeros in decimal integer literals are not permitted. It is quite
similar to >>> 1,000,000 under Chapter 1.5 Zeros cannot start a decimal integer

>>> 1/(2/3) (Downey, 2015). 


1.5

The output shows that the Arithmetic operator performs a mathematical calculation and is
similar to >>> 84 / 2 42.0 under chapter 1.4, Arithmetic operators (Downey, 2015). 

Reference

Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tea Press. This
book is licensed under Creative Commons Attribution-NonCommercial 3.0 Unported (CC BY-NC
3.0).

272 words

Permalink Show parent 


/
Re: Discussion Forum Unit-1
by Dhaval Patel - Monday, 22 June 2020, 10:04 PM

>>> print 'Hello, World!'

SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?
We get following error in output because we are missing parentheses (), at the beginning and
end of value ‘Hello, World’
the correct format for the print function is print('Hello, World!').

>>> ½
0.5
½ represents the arithmetic operation of division, 1 divide be 2 which results in an answer of
0.5.

>>> type(1/2) In python we have class of integer,string,float,double…


function type of ½ would result as answer float.

>>> print(01)
This command will result in SyntaxError: invalid token on screen, because in python 3, literal
integer starts with 0, also interpreted as octal need prefix of 0o.
So instead of writing print(o1), should write print(0o01) and it will output as 1, without any
error.

>>> 1/(2/3) 
The answer for this math equation will be 1.5.
as a result of the equation of 1*3/2.
159 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Dhaval Patel - Monday, 22 June 2020, 10:15 PM

I forgot to add that I am using python 3.


10 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Birikty Hagos - Wednesday, 24 June 2020, 9:50 AM

Great job Dhaval. Clean and well organized answer.



8 words /
8 words

Permalink Show parent

Discussion Forum Unit-1


by Leul Gebremichaele - Tuesday, 23 June 2020, 6:12 AM

Print statement
>>> print 'Hello, World!'
Hello, World!
>>> print('My name is Leul')
My name is Leul
This will give as the output of the text written inside the single quotation, the quotation
is the beginning and end of the text.
__________________________________________________________________________________________
Arithmetic operators
>>> 1/2  
0.5
>>> 4/2   
2.0
>>> 
By using the arthmetic operator division (/)  and output the result 
_________________________________________________________________________________
Type of a value
>>> type('2')  checking the type of the value inside the bracket and it is string becuase it
is inside single qutation 
<class 'str'>
>>> type(2)  when we see this one it is a value of int (integer) so numbers dont use
qutation 
<class 'int'>
__________________________________________________________
>>> print(01)      the output is differnet in python version   Python 3, leading zeros are not
allowed on numbers.
SyntaxError: invalid token    ----   version 3 and above
>>> print(01)      when we come to version Python 2 leading number has a meaning for
python which is an octal number and the result will be decimal 
1    ----   version 3 and above    
>>> print(0101)
65
__________________________________________________________________________________
>>> 1/(2/3)     
1.5  This artimatic opersation will result a float number type of 1.5 

___________________________________________________________________________________

i have 2 differnet version on my machine v2.7  and v3.7 i found all the output the same on /
a e d e et e s o o y ac e . a d 3. ou d a t e output t e sa e o
bothe version except the print(01) which i mentioned in the above

212 words

Tags: Discussion Forum Unit-1

Permalink Show parent

Re: Discussion Forum Unit-1


by Leul Gebremichaele - Tuesday, 23 June 2020, 6:36 AM

for the print function, I was tiring to explain what the output looks like in v2 and v3
sorry I didn't mention that the string inside the single quotation need a bracket in
v3
>>> print 'Hello, World!'
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?
50 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Henry Dakat - Wednesday, 24 June 2020, 5:09 AM

Hi Leul,
Good job, on the explanation, your post shows your understanding of the assignment and
also how comfortable you are exploring the app.
24 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Owen James - Tuesday, 23 June 2020, 2:45 PM

Input 1:

>>> print'Hello, World!'

Output:

File "", line 1


print'Hello, World!'
^
SyntaxError: invalid syntax

Description: A syntax error occurred due to an absence of parenthesis around the string code. /
Input 2:

>>> 1/2

Output:

0.5

Description: This code used the arithmetic operator “/” to perform division.

Input 3:

>>> type(1/2)

Output:

Description: This code uses the interpreter to determine what type of value is inputted. In this
case 1/2 would result in 0.5 which is a floating-point number or ‘float’.

Input 4:

>>> print(01)

Output:

File "", line 1


print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers

Description: A syntax error occurred due to a leading zero which violates the syntax rules of this
programming language. To fix, either remove the zero or place a period after the zero
depending on your desired outcome.

Input 5:

>>> 1/(2/3)

/
Output:

1.5

Description: This code uses the arithmetic operator to divide the integer “1” by the solution
within the parenthesis.

Conclusion: All of my inputs provided similar results to the textbook since we were both using
version 3 of python.
189 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Owen James - Tuesday, 23 June 2020, 3:28 PM

My output for input 3 was <class 'float'>. Sorry, I must have deleted it on accident.
16 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Birikty Hagos - Wednesday, 24 June 2020, 10:01 AM

Great work Owen. you explain it well.


7 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Thursday, 25 June 2020, 5:51 AM

well done really easy to read and understand what you were trying to say
14 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Deborah Adewumi - Tuesday, 23 June 2020, 10:49 PM

>>>print 'Hello, World!'

Output: Syntax Error. Parentheses are missing therefore print is not regarded as a function. 
/
Similar: print ('Hello World!')
Similar: print ( Hello, World! )

>>>1/2

Output: 0.5 .A float type value.

Similar: 42.0

>>>type(1\2)

Output: <class 'float' > . type is used to indicate the type a value contains or has.

Similar: 42.0

>>>print(01)

Output: the zero(0) for octal does not work on the upgrade (Python3)

>>>1/(2/3)

Output: 1.5 .Python uses the PEMAS rule for operation.

These results clearly states that python 3 yields accurate results and is free of the bugs that
affected outputs in python 2.

99 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Kenneth Landis - Wednesday, 24 June 2020, 12:32 AM

input: print' Hello World!'


output: Syntax Error: Missing parentheses in call to 'print'. Did you mean print ('Hello World!')?
explanation: Version 3 of Python now requires parentheses, before version 3 the "print"
function was not a valid function

input: 1/2
output: 05.
explanation: python recognizes this as a simple fraction. 1 divided by 2.

input: type(1/2) 
output: explanation: Float() is a function that converts a string to a float value and returns the /
result. If it fails for any invalid input, then an appropriate exception occurs.

input: print (01)


output: Syntax Error: leading zeros in decimal integer literals are not permitted; use an 0o
prefix for octal integers
explanation: Python 3 does not recognize leading zero's and makes any digits with leading
zero's a syntax error

input: 1/(2/3)
output: 1.5
explanation: python 3 computes this as 1.5
142 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Iman Khaireddin - Thursday, 25 June 2020, 5:31 AM

Great work, your explanations were good and clear, keep going.
10 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Paul Rudnitskiy - Thursday, 25 June 2020, 5:49 AM

Dear Kenneth!

Thank you for the work you made. The only thing I want to mention - Float() in the third
case is not a function. It's a class and 0.5 is a class instance.
34 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Faiza Sheikh - Wednesday, 24 June 2020, 2:18 AM


/
Input Output

>>> print 'Hello, World!'   File "<stdin>", line 1

    print 'Hello, World!'

          ^

SyntaxError: Missing parentheses in call to


'print'. Did you mean print('Hello, World!')?

>>> 

The code is missing ( ) that are used in most programming language. Languages requires a
good grasp of grammar. Thus, gives out an “Syntax Error” which means that this language
needs to be written in a certain manner.

Input Output  

>>> 1/2 0.5

the arithmetic problem is easily been solved but the following output is in decimal. If we want,
we can show the output as fraction also

>>> import fractions

>>> print (fractions. Fraction (1/2))

>>>1/2

Input output

>>> type(1/2) <class 'float'>

The 1/2 is a floating -point number.

Type tells what kind of class numbers/letter are like for e.g. o.5 or any number containing
decimals are called floating-point number because there is no fixed number.


/
input output

>>> print(01) File "<stdin>", line 1

    print(01)

           ^

SyntaxError: leading zeros in decimal integer


literals are not permitted; use an 0o prefix for
octal integers

>>> 

This one was pretty confusing for me to understand but after some research I have concluded
that python 3 uses octal numeral system which has a based 8 ^ to convert numbers to its
decimal form. (0, 1, 2, 3, 4, 5, 6, 7) is the range thus base-8. Leading zeros are not allowed in
python 3

But I still don’t get how to solve this. Do we convert it to binary numbers?

input output

>>> 1/(2/3) 1.5

Reference:Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tea
Press. This book is licensed under Creative Commons Attribution-NonCommercial 3.0 Unported
(CC BY-NC 3.0).

280 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Leul Gebremichaele - Wednesday, 24 June 2020, 4:17 AM

I like the way you explain each problem, on the leading number problem in my
understanding python V2 take it as octal number and it will give us decimal conversion
output, but when you come to python 3 leading zero is not acceptable; so you are right
47 words

Permalink Show parent /
Re: Discussion Forum Unit-1
by Faiza Sheikh - Wednesday, 24 June 2020, 7:58 PM

really?

so how do we right it n python 3?


10 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Paul Rudnitskiy - Thursday, 25 June 2020, 5:40 AM

To use octal numbers in Py3 you should use syntax 0o1234 (o is important)
14 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Henry Dakat - Wednesday, 24 June 2020, 5:02 AM

Hi Faiza,
I agree with the first response to your post. You did a good job on the explanations.
19 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Owen James - Thursday, 25 June 2020, 10:23 AM

Very detailed post that really showcased your already apparent knowledge of coding. We
both got the same exact results. Good job on the assignment.
24 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Iman Khaireddin - Wednesday, 24 June 2020, 7:31 AM

1. for the first statement:


>>> print 'Hello, World!'
the output was:
>>> print 'Hello, World!'
^

SyntaxError: invalid syntax /
y y
The reason that it appear was, the function print need for (), and it should be like this: >>>
print('Hello, World!')

2. the second one >>> 1/2


The output was:
>>> 0.5
because the / means distribution
3. >>> type(1/2) when I pasted it in pythonanywhere.com the output was:
code = compile(f.read(), filename.encode("utf8"), "exec")
File "/home/hello.py", line 1
>>> type(1/2)
^
SyntaxError: invalid syntax
but when I wrote it in python the output was and I think it is the right one, if any one can
explain it to me I will be thankful.
4.The output for the function >>> print(01) was:
code = compile(f.read(), filename.encode("utf8"), "exec")
File "/home/hello.py", line 1
>>> print(01)
^
SyntaxError: invalid syntax
I tried to fixed it in this way: print(01) and the output was also error it was:
print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers
Which means it is not allowed to start with zero in integers
The right function was: print(1)
5. The last one >>> 1/(2/3)
the output is 1.5 because it is a division
214 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Iman Khaireddin - Wednesday, 24 June 2020, 9:01 AM

I forgot to mention that I used python 3.

The output for the statement type(1/2) when I pasted it to python was 

<class 'float'>


/
26 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Paul Rudnitskiy - Thursday, 25 June 2020, 5:47 AM

Dear Iman!

Thank you for your effort and explanation.

For 2 - it's a division, not a distribution

For 3 - I think that you have a problem with a symbol. It can be not a division symbol but
something looks alike. For me it is better not to copy but write the code manually - it
preserves you from this kind of errors at least
63 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Thursday, 25 June 2020, 5:50 AM

you done well but i think you needed to explain a bit more
13 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Paul Rudnitskiy - Wednesday, 24 June 2020, 11:47 PM

>>> print 'Hello, World!'


File "<stdin>", line 1
print 'Hello, World!'
^
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, Worl
d!')?

For python3 print is a function which requires a parameter and not an interpreter statement

>>> 1/2
0.5

Python interpreter performs mathematical operations directly in interactive mode so we have a


result of division

/
>>> type(1/2)
<class 'float'>

type() function returns object type (kind of an object which contains methods that can be used
with this kind of object)

>>> print(01)
File "", line 1
print(01)
^
SyntaxError: invalid token

0DDD was the syntax for octal digits in python2. For py3 octal syntax is 0oDDD so 0DDD is
marked as an error to avoid collisions

>>> 1/(2/3)
1.5

It's a fraction represented in decimal form. It can be written as 1/0.6+

Python version: 3.6.9

137 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Chester Jasper - Thursday, 25 June 2020, 5:10 AM

1) >>> print 'Hello, World!'


SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?

The result of this statement is that there is a missing (). If I wrote print (‘Hello, World1’)
The output would be correct.
>>> print ('Hello, World!')
Hello, World!
>>> While in version 2 of Python parentheses aren’t needed because the print statement is not
a function, in this version they are, print is a function.
2) >>> 1/2
0.5

/
>>> This is a arithmetic for division. The operator that is used for division is /. Other operators
are +, -, * and ** which does exponentiation.
3) >>> type(1/2) >>> Every value a program uses is of some type. Some might be string like Hello

World! And others are numbers. Type is a function you use when you don’t know what type of
value you’re using. The most interesting example in this chapter is number 1,000,000 written
with commas.
>>> 1,000,000
(1, 0, 0)
>>> 1000000
1000000
>>> The first one is a sequence of integers separated by a comma. The second one is a simple
integer.

4) >>> print(01)
SyntaxError: invalid token
>>> In Python 3, leading zeros are not allowed on numbers but in Python 2 the leading zero
means that the number is an octal number (base eight), so 04 or 03 would mean 4 and 3 in
octal, respectively, but 08 would be invalid as it is not a valid octal number. Valid print function
for this would be
>>> print(1)
1
>>> For a integer or represent the value as a string
>>> print ('01')
01
>>>
5) >>> 1/(2/3)
1.5
>>> This is just a arithmetic operation that follows simple rules. First 2/3 is divided then 1 gets
divided by the result. >>> 2/3
0.6666666666666666
>>> 1/0.66
1.5151515151515151
>>> The result is rounded to two digits in a float in the first case. In the second case default
result has 16 digits.
310 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Iman Khaireddin - Thursday, 25 June 2020, 5:39 AM

Great job, your explanation was good and clear, keep going.
10 words 
/
Permalink Show parent
Permalink Show parent

Re: Discussion Forum Unit-1


by Paul Rudnitskiy - Thursday, 25 June 2020, 5:43 AM

Dear Chester!

Thank you for your job, everything is clear and true. To be precise - octal numbers are
allowed in Py3 but the syntax was changed. Leading zeroes in numbers are marked as a
mistake to ensure that only new syntax will be used.
44 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Adrian Davies - Thursday, 25 June 2020, 5:46 AM

well done everything explained well


5 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Eduardo Santos - Thursday, 25 June 2020, 5:53 AM

>>> print 'Hello, World!' -> It returned an error because I’m using python 3. If I was using python
2, it would return “Hello, World” on the output.

>>> ½ -> 0.5 - It returned the correct value

>>> type(1/2) -> - It returned the type of result.

>>> print(01) -> Syntax error: Invalid token - It returned an error because this is the wrong way
to print leading zeros in the output.

>>> 1/(2/3) -> 1.5 - It returned the correct result of the operation.
77 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Owen James - Thursday, 25 June 2020, 10:35 AM

I think we were supposed to paste the outputs into our posts but other than that really
nice explanations. Good job also using both programs to see the differences for your self.

/
I'd assume we got the same outputs, but I cant really tell for some of them.
I d assume we got the same outputs, but I cant really tell for some of them.
48 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Preyesh Hirachan - Thursday, 25 June 2020, 8:17 AM

1. >>> print'Helo,World!'
SyntaxError: invalid syntax
There is SyntaxError:invalid syntax because parentheses are missing. Correct format is as
below.
>>> print('Hello,World!')
Hello,World!

2. >>> 1/2
0.5
The operator / performs as divison . So 1/2 is basically 0.5

3. >>> type(1/2)
When we run the syntax , we got the no error . 1/2 is basically 0.5 , so its a float

4. >>> print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for
octal integers
>>> print (1)
1
Its error because there is 0 infront of integer(1)but when we remove 0 it prints

5. >>> 1/(2/3)
1.5

first 2/3 is 0.67 and later 1 divided by 0.67 we get the 1.5 because float is written with . in the
middle
131 words

Permalink Show parent

Re: Discussion Forum Unit-1


by Owen James - Thursday, 25 June 2020, 10:27 AM

Good job not only explaining but also correcting each line of code. We both got the same
results. Nice post. 
20 words
/

You might also like