CS 1101 - AY2022-T2 - Discussion Unit 1
CS 1101 - AY2022-T2 - Discussion Unit 1
Search forums
The cut-off date for posting to this forum is reached so you can no longer post to it.
Discussion Unit 1
by Leonidas Papoulakis (Instructor) - Wednesday, 10 November 2021, 7:07 AM
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 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.
>>> 1/2
>>> type(1/2)
>>> print(01)
>>> 1/(2/3)
When you reply to your peers’ submissions, compare their results with yours.
132 words
Permalink
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 1/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World')?
explanation: missing parentheses, my python version requires to put parentheses between the statement to be printed.
output 2: 0.5
explanation: convert fraction to decimal, my python version converts the fraction to decimal
output 3: explanation: Type of the input , my python version gives the type of the input.
output 4:
print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
output 5 : 1.5
explanation:computes (2/3) and then the program computes 1/(2/3) and gives the output in decimal.
125 words
Hi Fouad,
You have stated the output from the interpreter for the given commands and explained the reasons for the output.
A little more explanation could have been given. For example I'm curious to know what python interpreter you used and
you frequently mention "my python version" without mentioning what that version is. This would be useful especially in a
work environment so that others could reproduce exactly the errors in your code. Otherwise a great first post. Look
forward to reading your posts in the future.
87 words
dear Fouad, you have explained why that happened but you didn't give a detailed explanation of how it come, and which
python version you are using. you also don't tell us your sources. You should have included reference and citations.
40 words
Permalink Show parent
Hi Fouad, I got exactly the same outputs! It seem you have a great insight on using the Python interpreter. You could have
used a bit more of explanation but nonetheless, I can understand your explanation for each output. Thank you and great
work.
44 words
Hi Fouad, your explanations are not too bad but will be more awesome
Hi Fouad,
Keep it up
14 words
Hi Fouad,
I think you’re interpreting the results instead of comparing them to the ones in the manual. The instructions were not to
interprate but to compare with examples you've probably shaw in the texbook. However I can see that you understand
why some instructions didn't display the output one wished.
51 words
Hey Tarabay I like the way you broke down the output from the interpreter. It give a clear view of how the we use the
python language.
27 words
Re: Discussion Unit 1
by Luke Henderson - Thursday, 11 November 2021, 8:01 AM
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 3/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
For my python interpreter the IDE I used IDLE Shell version 3.9.4
output: SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?
The first line includes a print statement. The print command in python 2 is not a function therefore this line would be valid in
python 2. However since I am using python 3 this statement is lacking a few vital ingredients, namely the parentheses “( )”
(Downey, 2015). When typed with correct syntax it will output to the command line whatever is placed within the parentheses
whether that be text a.k.a a string or a number variable or the result of a sum etc...
Printing “Hello World” is seen as the very first program anyone should use when learning a new programming language. It was
popularized by computer scientist Brian Kernighan who wrote it in a test program of a programming manual back in
1972(Thompson, 2019).
Input:1/2
Output: 0.5
In this command we ask the interpreter to divide 1 by 2. The forward slash “/” is python syntax
for the % key. All the symbols used for mathematical equations in python are known as “operators”. The output of the sum is
now of the float data type.
Input: type(1/2)
Output:
Here we use the type function which outputs the data type of whatever we put into the parentheses. In this case the result of
the sum is 0.5 which is a decimal number. In Python and many other languages a float is a number with a decimal point or
floating point. In python 2 the output is instead of
Input: print(01)
Output: SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Leading zeros in python3 are considered ambiguous and therefore require a workaround. Depending on what counting
system we are using we could use the suffix 0o for octal, 0b for binary and 0x for hexadecimal. If we do not wish to do any
calculations with the number we could simply surround it with “” making it a string. Leading zeros were acceptable in python2
but python would automatically interpret them as an octal number and output into decimal (Navone, 2019).
Input: 1/ (2/3)
Output: 1.5
References
Downey, A. (2015). Think Python: How to think like a computer scientist. Green Tree Press.
Haelle, T. (2013, March 12). What is the answer to that stupid math problem on facebook?
Navone, E. C. (2019, February 6). Leading Zeros in Python: A Hidden Mystery Revealed. Techmacademy. Retrieved from
https://medium.com/techmacademy/leading-zeros-in-python-a-hidden-mystery-revealed-ee3e3065634d
Thompson, C. (2019 October 16). Why the first code a programmer writes is “Hello, World.”. Future Tense. Retrieved from
https://slate.com/technology/2019/10/hello-world-history-programming.html
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 4/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
476 words
dear Luke Henderson, you have explained it very well. You also have cited both intexts citation and full reference very well.
Keep it up!
24 words
Luke,
This is brilliant, not only have you demonstrated an understanding of the programming concepts, you reminded people
like me that this is a higher education institution, the citation is very important in every response, well done and thank you
for setting an example.
44 words
Hello Luke,
I found your explanations to be very thorough. As we all had the same assignment it is interesting and helpful to us all to
read different methods of explaining a concept. Your descriptions brought several concepts to greater clarity. Thank you
for demonstrating a solid example of APA format. I look forward to future posts.
57 words
Your post is clear and shows a solid understanding of the python programming language.
14 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 5/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Hey Luke! That was a masterpiece explanation. Honestly, when preparing my essay I did not know where to use references
but I've learnt how to, from you. Great work, keep it up.
32 words
Mr luke,
This was amazing,you make me learn more how to did a discussion in the right way by using references, it was so helpful.
Keep going!
27 words
Fantastic and very detailed explanations Luke. You have added many details that I have missed, such as the possibility of
some statements working in Python 2 etc. Thanks!
28 words
Hi Luke,
Great Work!
9 words
Hi Luke you've explained the different cases very well. I have the same output with my python 3. I wished you compared
your results with the similar examples on the textbooks. I can see you understand the output of the different versions,
congratulations for that. Keep up the good work.
50 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 6/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Luke, your broken down and explanation on the python language is very understandable. You seem to have the proper
citation and references. Job well done.
25 words
Q1.
File "<stdin>", line 1
print 'Hello, World!'
^^^^^^^^^^^^^^^^^^^^^
Explanation
Hello, World!
Q2.
>>> 1/2
0.5
Explanation
The interpreter doesn’t read ½ as a fraction,
but it reads as a division of two integers. The division of two integers is
evaluated always to floating points. “Conventional division returns a floating-point
number:” (Downey, 2015, p. 39). Therefore,
if we use the division operator (/) to compute and two integer type
values, the result would always become a float type value.
Q3.
>>> type(1/2)
<class 'float'>
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 7/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
>>>
Explanation:-
Q4.
>>> print(01)
File "<stdin>", line 1
print(01)
^
>>>
Explanation:-
Q5.
>>> 1/(2/3)
1.5
>>>
Explanation:-
1) Navone,
E. C. (2019, February 05). Leading Zeros in Python: A Hidden Mystery Revealed.
Retrieved from
https://medium.com/techmacademy/leading-zeros-in-python-a-hidden-mystery-revealed-ee3e3065634d
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 8/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
525 words
Tags:
Unit 1 Discussion
Unit 1 discussion forum.docx
Permalink Show parent
Hello Samrawi,
I enjoyed your description of the print statement being unable to find the argument. It pointed my attention back to the
goal of thinking like the program. Your differentiation between a fraction and the division of two integers helped bring
clarity to how the program views the initial input. Referring to octal integer prefixes as "flags" created a visual that helped
cement the concept. There were moments when I forgot I was reading a post rather than a tutorial. Pasting the screenshot
in addition to bold typing the exercises was very effective. Inspiring work!
96 words
Thank you, Lenlie, for your help full and appreciating comments.
10 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 9/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Hi Samrawi,
I really appreciated your usage of screenshots in your discussion post, I believe it can capture more than copy and paste,
and may follow your example in my subsequent posts. Out of curiosity I'm wondering whether this color contrast is your
personal preference or the standard color palette of your IDE? I know every programmer has his/her own preference when
it comes to style and IDE setup and I'm curious to see the differences in this in my fellow students. I look forward to your
future work
89 words
Brilliant work Samrawi. I've noted the use of tags, which are creatively placed to show a real programming essay. Quite
helpful and understanding keep up the great work.
28 words
hello Samrawi,
Re: Discussion Unit 1
by Hyun Oh - Tuesday, 16 November 2021, 12:32 AM
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 10/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Samrawi,
I got stuck on the fourth statement to explain the outcome and I too was naive and didn't even make use of Google to
understand and reference the outcome. This is literally one of my first courses at UoPeople and I learned how to fine-tune
my assignments in the future by reading your post. Thanks for the posting!
59 words
Hi Samrawi,
what a fantastic post. You went into so much detail and cleared out a few things for me. I got a bit stuck on the fourth
statement and answered very simply but your post really helped me understand it. Thanks for sharing!
44 words
Your input in this discussion is simply amazing. Very strong input in the discussion. It has shed a lot of light in different
types of inputs that are used in python. I like your explanation more in the area of the leading zeros and the use of
PEMDAS order in calculations. Definitely a very insightful effort. Thanks
57 words
Hi Yahya,
Great Job!
13 words
Hi Samrawi I can see that we have the same outputs so. Unfortunatelly when reading your comment I realise that I miss to
explain the results, I've just compare them to those similar in the textbook. You've done a good job keep it up.
44 words
Berhe
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 11/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Awesome job in your discussion. You went in detail and add a photo to give visual of what others can see. Job well done.
Keep it up.
28 words
1* In the above statement there is an error caused by incorrectly phrasing the command without using the open arches
"command ( function )".
2* although ">>>print 'Hello, World!' " would work in python2 it will not work for python.
>>>1/2
0.5
1* in the above example we use the built in calculator using Arithmetic operators in Python to divide 1 by 2 and as result we
get 0.5 .
\\
>>> type(1/2)
1* in the above statement we ask python to tell us the type (kind or category) of value we have in parenthesis.
2* as result we get the response "" which means the the value is a float and not an integer number 1,2,3,4,5....etc.
3* different types of values include "strings" which look like this 'example', integers "1,2,3,4,5...etc" and floats, floats can look
like this "0.5" or "1/2" or "3.14" or "10/42(2)", boolean "(tue) or ("false") and more.
\\
>>>print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
1* in the example above we got an error for failing to mention the number system type, in python there are a couple, hex
"0x10", octal "0o1", binary "10101" and decimal system "0,1,2,3...etc".
2* in decimal there are no real numbers that have a '0' in front such as '01'.
\\
>>>1/(2/3)
1.5
1* the above is an example of using python to solve a simple math problem and print the result.
270 words
Yahya
I love your response, it's coherent and clean, you demonstrated an understanding of the programming concepts, and the
effort shows, well done.
23 words
Permalink
Show parent
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 12/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Hi Yayha, great discussion and on point. You did no need a long discussion to explain why you got the outputs you got. I
also got the same outputs as I am also using Python 3. This is surely like learning a new language except there is only one
way to get it right and that is following the correct syntax. Thank you very much!
65 words
Yahya,
I was able to learn deeper on the third statement about "type" (category). Thanks for your posting!
18 words
Hi. I like your explanation on the output you got from the entered codes. Thank you for your elaboration on >>>print(01)
it shed more light on the commands. Comparing this to the out put i got for the entries. I got more or less the same as
your answers. However your explanation may differ from mine in one way or the other . However your input is clearly
sheds a lot of light. I like your input on type . Once more thanks a lot.
85 words
Hi Yahya
You are working in a great way, keep it up, in addition, you have explained and clarified more valuable information.
wishing you good luck
26 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 13/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Python3 requires brackets, so it doesn't like it if you use the print method as is and not as print()
================================================================
>>> 1/2
0.5
================================================================
>>> type(1/2)
The type function returns the result type of deciding 1 by 2 which is 0.5 as a floating-point data structure.
================================================================
>>> print(01)
print(01)
================================================================
>>> 1/(2/3)
1.5
Dear Siphumelelise, you have done a great job on most of the explanations. But I have noticed that you have missed
question number 4. it is not a string it is called a leading zero integer. The reseason the interpreter rises error is that,
leading zero integers in python v3 is not an acceptable. So if we want to use such a thing we use 0o or 0O. you can read
about what is leading 0 integers at https://medium.com/techmacademy/leading-zeros-in-python-a-hidden-mystery-
revealed-ee3e3065634d
79 words
Your post is very much in line with the question asked and it shows you actually went through with the exercises but I think
you should have provided a little more details. I got similar results.
36 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 14/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Hello. I appreciate the input you have given to this assignment. It confirms that you clearly understand the output you got
for each and every code that you used in Python. I clearly understand your explanation on every code that you have used.
This clearly sheds light on the meaning and use of the commands. Well done.
57 words
Discussion Unit 1
by Lenlie Quirk - Friday, 12 November 2021, 8:03 AM
SyntaxError: missing parentheses in call to 'print'. Did you mean to print ('Hello, World!')
The necessity of parentheses in print commands indicate a Python 3 program. Parentheses are not a function in Python 2, and
their use would generate a syntax error.
0.5
The / operator symbolizes division, and the quotient is expressed in decimal form. The command did not use parenthesis. >>>
84/2
42.0
The textbook example above used / operator, omitted parentheses in the input, and expressed the quotient in decimal form.
The output defined the value class of the input as a floating-point number. I experimented ways to alter the value class of the
input. Adding quotations changes value type to string.
SyntaxError: leading zeros in decimal integer literals are not permitted; use a 0o prefix for octal integers.
This response indicates that the running program is Python 3, which requires a 0o prefix. According to the Python Developer's
Guide Pep Index, Python 2 uses 0 as a prefix for octal integers.
1.5
The decimal response is indicative of a floating-point number. The input contains an integer numerator with a fraction in the
denominator which requires parentheses in either the denominator, or both numerator and denominator as I discovered, to
arrive at the correct computation. Without parentheses the programs treats numbers as integers and divides linearly. The
textbook example below illustrates how differently from us computer programs can interpret a symbol's meaning.
>>> 1,000,000
(1,0,0)
250 words
Re: Discussion Unit 1
by Siphumelelise Ntshwenyese - Friday, 12 November 2021, 8:16 AM
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 15/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Lenlie,
I love your response, you demonstrated an understanding of the concepts, your descriptions were sufficient even for a
Laman, I'm happy with your response, well done.
27 words
Thanks for your in-depth explanation. Your post shows an understanding of the questions and the python programming
language. And looking through your post, I can see that I got similar results
31 words
nice job
2 words
Hello Lenlie,
I like how you wrote out all your explanations. Although, it would be nice to include the input as well so it's more clear
when you move on to the next prompted input. Adding a reference on the bottom for the book would be great practice
for APA formatting and it's necessary as well. Our outputs are the same for all, as expected. Make sure to add in-line
citations as well next time.
75 words
Hi Lenlie
You're doing a great job, keep it up, and I wish you the best of luck
18 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 16/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
1.
Using the Python Interpreter on Windows Command Prompt, The code returned the following sytax error:
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello World!")?
The reason for the syntax error is missing parentheses() that's usually required when inputing the values after a function call.
However, the case would have been different if I was using Python 2. That's because in python 2, print is just a statement (does
not require parentheses) and not a function.
2.
>>>1/2
Using the Python Interpreter on Windows Command Prompt, this returned the following output:
>>> 1/2
0.5.
The above code is simply telling the computer to divide the number 1 by the number 2 which mathematically gives the result
of 0.5.
3.
>>> type(1/2)
Using the Python Interpreter on Windows Command Prompt, this returned the following output:
>>> type(1/2)
<class 'float'>
The type() function is used to display the data type of any given value.
The above code is simply telling the computer to display the data type of the given value (1/2).
4.
>>>print(01)
Using the Python Interpreter on Windows Command Prompt, this returned the following output:
>>> print(01)
print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers.
As already indicated in the error report, a leading zero in decimal interger literals are not permitted. This happens as a result of
number system/base confusion
5.
>>> 1/(2/3)
Using the Python Interpreter on Windows Command Prompt, this returned the following output:
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 17/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
>>> 1/(2/3)
1.5
Using the mathematical Order of Operation, the above code is telling the computer to divide the number 1 by the result of the
mathematical expression in parentheses.
300 words
Hello Steven,
Thank you for your post. Your explanations used fewer words and were clear, concise and remained on topic. Your
organization and use of color coding of both the syntax errors and successful computations made it easier to compare and
contrast outcomes. I'm interested in reading your further posts.
50 words
Hey Stephen,
It was great to see the color in your discussion post which really makes the debug messages stand out as in the
interpreter. This definitely makes it easier for skim reading and hypothetically if a colleague were reading this as a bug
report it would save them a lot of time.
It's great that you mentioned the interpreter you were using in your post. I wasn't aware it was possible to type python
code within the windows command line, now I'm curious to know how that works. Look forward to your future posts.
95 words
Hello Steven,
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 18/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Stephen,
I totally have missed that there are functions for bold letters and colors for the postings. These are very useful functions
that I can make use of it in the future. I also like your explanations of how concise they are. Thanks for the posting!
46 words
Hi Stephen
You have done more than great. So that I clarify and interpret the ambiguous symbols
17 words
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.
Python is considered to be a formal language as it follows specific rules and syntax, there are no other options to follow but
the “right” way (Downey, 2015). Below are some inputs plugged into python and the output received depending on the input. I
downloaded Python 3.10.0
Output: SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
In this case, I got a Syntax error because python understood that this should be a print statement since it started with the word
print. Since printing values changed from being a distinct statement to an ordinary function, parentheses are needed. This
this
input would have worked correctly if it was plugged into Python 2. We would need to add parentheses in order to prevent
error when using Python 3.
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 19/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Output: 0.5
Pyhton also works like a calculator and can use arithmetic operations. In this case, python understood that we wanted a
division computation and because we plugged in the right value the output was given correctly.
Output: <class 'float'>
In this case, we are telling python that we are unsure on the type our value (1/2) belongs to. The interpreter got that message
and is providing an answer for us, stating that the values we plugged in would come under the floating-point number type.
Output: SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
The print() function prints the message to the screen. In this case we got a syntax error because integer literals starting with 0
are illegal in python because of ambiguity.
Output: 1.5
Like mentioned before, Python also works like a calculator and can use arithmetic operations. In this case, python understood
that we wanted a division computation and because we plugged in the right value the output was given correctly.
References:
Downey, A. (2015). Think Python: How to think like a computer scientist, 2nd Edition. This book is licensed under Creative
Commons Attribution-NonCommercial 3.0 Unported (CC BY-NC 3.0).
393 words
Hey Wilmer,
I like the structure of your response, it's easy to see which question you're responding to. For response 4, I found out that
it is also because 0 also indicates an octal integer (which starts with 0o). It would be nice if you included more in-text
citations for your explanations as well as more examples from the book. Overall, your response is good.
65 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 20/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
The output statement returned a syntax error. This is because, the statement ´´Print´´ is function in Python 3x.
>>> 1/2
0.5
is an arithmetic operation with a correct syntax and token and returned an output of 0.5, which is a floatingftpoint according
to Downey (Downey)2015.
>>> type(1/2) The statement above contains the type function with correct syntax
>>> print(01)
>>> 1/(2/3)
1.5
The above statement returns a value of 1.5 which is a floatingftpoint number in pythonw,it returned an error python 2 did not
recognized. Therefore python 2 interpreted the above expression as 1/0 whic returned a zero divison error
123 words
output: SyntaxError: Missing parentheses in call to 'print'. Did you mean print(...)?
The reason the output became a SyntaxError is because there is no parenthesis, which "indicate that print is a function"
(Downey, 2015) Though the syntax would work in Python 2 because "it is not a function," it just does not work for Python 3
(Downey, 2015).
>>>1/2
output: 0.5
The output is 0.5 because in Python 3, "/" is an operator for division and 1 divided by 2 is 0.5 (Downey, 2015).
>>>type(1/2)
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 21/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
>>>print(01)
output: SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
The output shows SyntaxError because as it said, "leading zeros... are not permitted." It assumes the "01" is an octal integer
that is stated wrong because it was not stated as "0o1." When I tried "print(1)" and "print(0o1)" it outputted "1" properly. This
means "print(01)" is just incorrect syntax in Python 3.
>>>1/(2/3)
output: 1.5
The output is 1.5 because 1 divided by 2/3rds is equal to 1.5. This input uses the basic arithmetic operators included in Python
3.
References:
Downey, Allen B. (2015, December). The way of the program. Think Python (2nd Edition, pp. 1-8). Sebastopol, California:
O'Reilly Media, Inc.
240 words
Great explanation and very substantial answer, it helped me to fully understand the concepts learned. The only thing I
would like to add is whenever use the division "/" symbol always we will have a float number as a result.
40 words
Hi Janelle,
great post! I particularly like your explanation of the fourth statement. Straight to the point! Thanks!
18 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 22/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?
>>> 1/2
0.5
>>> 1/(2/3)
1.5
Explanation
1. SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?
The out put shows that there is an error in the statement. The syntax error indicated indicates that the entry is missing
parentheses in order to print the Hello world , The statement also gives suggestion to correct the error. The suggestion is
print('Hello, World!') as correct entry.
This is indeed in the text book as a print code for Hello World should be print('Hello, World!')
>>> 1/2
0.5
>>> type(1/2) This indicates that ½ is an operation that belongs to type of values referred to as float .
>>> print(01)
This means the operation Print(01) is incorrect. In python the zero before a number is invalid entry and therefore the result is
syntax error.
It should have been entered as
>>> 1/(2/3)
1.5
It is a mathematical operation where priority has been given to the figures within the parenthesis , which are 2 divide by 3) the
operation is carried out first before that of 1 divide by the answer within the parenthesis.
The meaning of versions of python is different types of python depending on the time of release. Each version has particular
elements that are different from the other. The major reason for release of different versions of python is to improve the
versions of python. Each new release has a specific improvement element that quantifies a new release.
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 23/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Reference
Downey, A. (2015). Think Python: How to Think Like a Computer Scientist (2nd ed.). Green Tea Press
390 words
Hi Simon, Nice explanation and example from book with reference. I like the way you explained for #4 that what is the
right way of entering the print (1); I learned from your explanation and example.
36 words
After running the code in python terminal, this are the results
Print(01) gave a syntax error : leading zeros in decimal integer are not permitted
44 words
The first statement, using print function without parenthesis always will return an error as python and I believe most of the
programming languages, will need a set of parenthesis whenever you call a function to be able to pass an argument (data)
for the function to process.
The second statement where you divide 1/2 and python returns a number with a decimal point, is caused by the use of the
'/' character. Always will return a float data type.
In the third statement, ‘type’ processes the argument received inside the parenthesis and returns what data type is. “type”
is another build in a function where this could be very useful to detect what kind of data type are we working with, there
are different data types such as integer, float string and boolean in the computer language.
In the fourth statement where we added a '0' before an integer, python throws an error as when python sees a zero
before, python will think we are referring to a different numeral system as octal, hex, or binary.
186 words
Permalink Show parent
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 24/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
SyntaxError: Missing parentheses in call to 'print'. Did you mean print("Hello, World!")?
The first statement shows that there is a syntax error, ‘print’ is one of the many built-in functions in python, all the functions
need to have parenthesis where we can send arguments to process them. In this example, the string “Hello, World!” is an
argument given to the function to show it into the terminal. So the correct syntax would be print(“Hello, World!”)
>>> 1/2
0.5
In this statement, python returns a float value because for python the “/“ character represents a division of two numbers giving
a number with a decimal point. (float type)
>>> type(1/2)
<class 'float'>
In this statement ‘type’, process the argument received inside the parenthesis and returns what data type is. “type” is another
build in a function where this could be very useful to detect what kind of data type are we working with, there are different
data types such as integer, float string and boolean in programming.
>>> print(01)
print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
This statement is not allowed in python, the reason is that if python sees a ‘0’ before an integer python will try to find a
different numerical system such as binary, octal, or hex.
>>> 1/(2/3)
1.5
In this statement python first, solve the equation inside the parenthesis and then, it will be divided by the number outside of
the brackets.
263 words
great answer
2 words
Hi Juan, Great explanation! It seems you have done additional research in understanding this concept. I am not seeing any
text book example as per the requirement of this assignment. Overall, great in all respect.
35 words
Dear students,
great work from all of your in this first week, well done!
14 words
line 1
^^^^^^^^^^^^^^^^^^^^^
print is a built in function,and whenever we want to use or called a function we should always include parentheses.This is an
invalid code from python 3 point of view,however comparing this code with similar examples in the textbook I can say that this
is a valid python 2 code because python 2 don't treat the print statement as a function so there is no need to include the
parentheses.
2. 0.5
using the / operator produces a decimal number, which we refer to as floating point numbers in python.we use the / operator
if we want to get a fractional number.
3. class 'float'> running this code tells us the type or category of values that we are working with in our program.In this case it
is a floating point number.
4.SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
we get a syntax error which simply means that the structure of our code is not correct, it just like using a wrong on english in
grammar.we're violating the rules that governs our programming language.
5. 1.5
we're performing divisions using the \ operator, hence we get our answer to be a floating point number.
221 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 26/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Great work, in a brief and understandable form. You did all the questions asked.
14 words
Thanks dear,
2 words
When running the code functions they resulted in the following outputs:
^^^^^^^^^^^^^^^^^^^^^
The error was a result of missing pair of parentheses that indicates print as a function in python 3. This simply clarifies that my
installed python interpreter is version 3 since version 2 of python identifies parentheses, not as a function.
2. 0.5
The operator / simply performs a division function and results in the output as a floating-point number.
3.
The function type assigns the value and type. 1/2 is a floating-point number belonging to class 'float'.
print(01)
0 is not identified as an integer in both versions of python. '01' is therefore not identified which results in an indentation error.
5. 1.5
Operator / is identified as a division operator resulting in, 1 divided by (2/3) and as a floating-point number.
177 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 27/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
Great answer, I just want to add in example number 4, you might have added a space before print(01), if there is an extra
space between the start of the line and the print, python will take it as an indent error. If you try to print(01) with no space,
python will throw an error like this:
>>> print(01)
print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
This error happens because in python there are different numeric systems we could use like Hex, Octal, and Binary. So
when python reads a zero before an integer will try to refer to these systems. So that's why we get an error.
124 words
Hi Newton Sudi
Hi Newton, It was easy to understand and follow. Great! I am not seeing any similar example from the text book prescribed
to us. Overall, I like the way you separated each answers and your explanation.
36 words
Output: SyntaxError: Missing parentheses in call to 'print'. Did you mean print('Hello, World!')?
Explanation: this code works fine in Python 2 and gives error in Python 3. Currently I am using Python 3. In order to run code
to print "Hello, World!" statement; then I need to modify the code to as follows; print('Hello, World!'). (Downey, 2015).
1/2
Output: 0.5
Explanation: Performs division operation and the result is displayed. The symbol used to perform division operation is the
forward slash"/". (Downey, 2015).
type(1/2)
Output: float
Explanation: type() is used to get the value type. Whether letters or numbers; enclose it in type() and the interpreter will
automatically display the result of the value type. (Downey, 2015).
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 28/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
print(01)
1/(2/3)
Output: 1.5
Reference:
Downey, A. (2015). Think Python: How to Think Like a Computer Scientist. Needham, Massachusetts: Green Tea Press
188 words
Hi Ismail,
The way you separated all the prompts are well organized and easy to understand. Your use of "Citation: (Downey, 2015,
p.8)" is wrong, there's no use of that in APA style. In-text citation is enough for that. I feel like you can use a bit more in
your explanation. Our outputs are the same, as expected. Overall, on okay response.
62 words
1)
^^^^^^^^^^^^^^^^^^^^^
-The output shows that there is "SyntaxError" which means structure error occurred while using print statement on a command
line and it is suggesting to use parentheses to solve the error.
2)
>>> 1/2
0.5
-The output shows the correct value to 1 divided by 2 using the division operator "/" and the answer is 0.5.
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 29/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
3)
>>> type(1/2)
<class 'float'>
-The output shows the type (or category) is "float" to the value of "1/2". "float" is the type that represents decimal point
numbers and "1/2" is equal to "0.5".
4)
>>> print(01)
print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
-The output shows that there is a structure error as it begins with "SyntaxError" and I quietly don't understand the error
message but I assume that the Python interpreter is assuming that the command is trying to input decimal integer (number)
and "0" at the beginning is not allowed and is suggesting to use "0o" to solve the error.
5)
>>> 1/(2/3)
1.5
-The output simply shows the value of the division on the command line because the Python interpreter can function as a
calculator as well.
227 words
Hi Hyun Oh
Good job
5 words
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 30/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
...
>>>
In
Python 3 the use of parenthesis is needed for the print
function (unlike in Python 2) so the interpreter recognises it as an
error and
the output suggests the use of parenthesis (...) (Downey, 2015).
2. >>>
1/2
...
0.5
>>>
Python
uses operator for arithmetic and the operator
/ is used for division (Downey,
2015). The function 1/2 therefore
divides 1 by 2 and the result is 0.5.
3. >>>
type(1/2)
...
<class 'float'>
>>>
When
we are unsure what type the value is we can ask Python using the function type. In this case, we are asking what type is
1/2 and the interpreter tells us it is floating-point, a number with fractional
parts (Downey, 2015).
4. >>>
print(01)
>>>
Python
does not permit to start an integer with 0.
possible
corrections may include removing the leading zero, using quotation marks to
turn integer into a string etc (Downey,
2015):
>>> print(1)
>>> print('01')
01
>>> print(.01)
0.01
>>>
5. >>>
1/(2/3)
...
1.5
>>>
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 31/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
This
output is an arithmetic operation using / for a division and prioritising
parentheses. 2/3=0.6667 and 1/0.667=1.4993
which is the rounded up result.
References
Downey, A. (2015). Chapter 1 The Way Of The Program. 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).
258 words
Hello Michaela, You did a great job explaining every aspect in a brief and understandable form. I noticed you even
included several examples to clarify your point. Great piece.
29 words
Hi Michaela Jedlickova
Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32
'Hello, World!'
>>> print 'Hello, World!
>>> 1/2
0.5
>>> type(1/2)
>>> print(01)
print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 32/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
>>> print('01')
01
>>> 1/(2/3)
1.5
Downey . A, 2015. Think Python How to Think Like a Computer Scientist 2nd Edition, Version 2.2.23
Hi Mayowa Ogunyale
Great job.
5 words
^^^^^^^^^^^^^^^^^^^^^
Explanation: The parentheses are missing in and it indicates that print is a function. As per the book, Think Python, How to
Think Like a Computer Scientist, 2nd Edition - In Python 2, the print statement is slightly different; it is not a function, so it
doesn’t use parentheses. >>> print 'Hello, World!'
_________________________________________________________________________________
>>> 1/2
0.5
Explanation: This is an arithmetic operator. The ‘/’ indicates division. In the book, the example is given for -
>>> 84 / 2
42.0
__________________________________________________________________________________
>>> type(1/2) Explanation: The interpreter indicates the type of value. This is an example of ‘float’ or floating-point number. In
the book, an example is of
>>> type(42.0)
___________________________________________________________________________________
>>> print(01)
print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Explanation: leading zero with an integer is unacceptable in python 3. Logically it makes sense because when we write an
integer, we do not put zero in front of it.
_____________________________________________________________________________________
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 33/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
>>> 1/(2/3)
1.5
Explanation: This is an arithmetic operation of division. Algebraically, first, the interpreter calculates the value inside the bracket
(2/3), which is 0.67, and then divides by 1.
225 words
My response,
>>> 1/2
0.5
Python has a built-in calculator package that interprets the formula and produces the output. This is the division result.
>>> print(01)
SyntaxError: because leading zeros in decimal integer literals are not permitted anymore in python version 3; we need to use
an 0o prefix because they are octal integers. The above command is allowed in python version 2.
>>> 1/(2/3)
1.5
Dividing 1 on the result of 2/3, which will become .666 and python round it to .5
110 words
Input:
print("hello world")
1 / 2
type(1 / 2)
print("01")
1/(2/3)
Output:
hello world
01
These are the results of what appeared to me above^
I couldn't run because I'm using Python version 3, which needs parentheses to define a variable. I really don't know what the
fundamental differences are in the Python versions, but I'm looking forward to discovering that
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 34/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
67 words
Output:
Output explanation: Using Python 3, the executed print statement without parentheses return output with SyntaxError of
unexpected indent. The reason is that the parentheses () that indicate that print is a function is omitted (Downey, 2015).
>>>1/2
Output: 0.5
Output explanation: The operator / is for computation of division. Therefore, the output 0.5 is correct because the ratio of 1 to
2 gives a float answer of 0.5. In the book titled, “Think Python”, the operator / performs division on >>> 84/2 and give the
output of 42.0
>>>type (1/2)
Output: Output explanation: the word “class” is used in the sense of a category; a type is a category of values within the
parentheses, which in this case is floating-point numbers (float). A float can either be a fraction or a decimal number. Similar
example cited in “Think Python” is given as:
>>>print (01)
Output:
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Output explanation: Leading zeros are not permitted in Python 3. Therefore, the bug in the input above is the leading zero.
Mathematically, the input (01) is correct, but in machine language, it is an illegal token. Python There is a need to specify if we
want to work on machine language calculation by adding 0o prefix for octal integers or get rid of the leading zeros.
>>>1/ (2/3)
Output: 1.5
Output explanation: The denominator is a float. Therefore, the operator / makes the python interpreter to see the data as
fraction.
REFERENCE
Downey, A. (2015). Think python: How to Think Like a Computer Scientist (2nd ed.). Green Tea
Press.
293 words
Hello dear instructor and peers here are the results of my manipulation on python:
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 35/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
^^^^^^^^^^^^^^^^^^^^
The output of this instruction shows an error on the screen, a similar example shown on the text book display the words
betwen the quotes.
>>> 1/2
0.5
This second instruction displays on the screen the same result on the textbook when performing a division.
>>> print(01)
print(01)
This instruction displays an error on the screen when a similar instruction displays the numbers betwen the brackets.
>>> 1/(2/3)
1.5
The last instruction displays the result of an operation like the example shown on the textbook when one applies a division
operation..
156 words
Output:
Explaining: Since the call to 'print' is missing parenthesis print('Hello, World!') should be used instead.
>>> 1/2
Output:
0.5
Explaining: Python comes with a built-in calculator that reads the equation and generates the result. This is the outcome of
the division.
>>> type(1/2)
Output:
<class 'float'>
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 36/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
>>> print(01)
Output:
File "<stdin>", line 1
print(01)
^
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
Explaining: Since leading zeros in decimal integer literals are no longer allowed in Python 3, we must use the 0o prefix to
indicate that they are octal numbers.
>>> 1/(2/3)
Output:
1.5
Explaining: Python comes with a built-in calculator that reads the equation and generates the result. This is the outcome of
the division.
159 words
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.
Statement:
3 print() is a function , there for, the correct syntax would be >>>print ('Hello, World!')
>>> 1/2
0.5
Statement:
“After “Hello, World”, the next step is arithmetic.” There for, this is a division operation executed and the result was in decimal
value (Downey, 2015,3).
- >>> type(1/2)
When written as fraction (1/2) it became a , but when written as a whole number (2) it becomes a (Downey, 2015, p. 4).
- >>> print(01)
- interpreter (python) response
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers.
Statement:
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 37/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
The “SyntaxError“ was shown because of the leading zero (0) which is used to denote number systems. (Downey, 2015, p. 4).
>>> 1/(2/3)
1.5
Statement:
Reference
Downey, A. (2015). Think Python| How to Think Like a Computer Scientist: Vol. Version 2.2.23 (2nd Edition). Green Tea Press.
https://my.uopeople.edu/pluginfile.php/1404469/mod_page/content/3/TEXT%20-%20Think%20Python%202e.pdf
253 words
^^^^^^^^^^^^^^^^^^^^^
>>> 1/2
0.5
print(01)
SyntaxError: leading zeros in decimal integer literals are not permitted; use an 0o prefix for octal integers
>>> 1/(2/3)
1.5
56 words
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 inte
1/(2/3)
1.5gers
According to 1.3 the first language we will learn. It would be considered the print statement print 'Hello, World!' The next
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 38/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
statement would be arithmetic, then it is followed by values and types. I am still working on understanding a brand new
language.
80 words
All activities close on Wednesdays at 11:55 PM, except for Learning Journals/Portfolios which close on Thursdays at 11:55 PM always
following the clock at the top of the page.
Due dates/times displayed in activities will vary with your chosen time zone, however you are still bound to the 11:55 PM GMT-5
deadline.
Jump to...
Resources
UoPeople Library
Orientation Videos
LRC
Syllabus Repository
Honors Lists
Links
About Us
Policies
University Catalog
Support
Student Portal
Faculty
Faculty Portal
CTEL Learning Community
Office 365
Tipalti
Contact us
English (en)
E li h ( )
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 39/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1
English (en)
العربية(ar)
Data retention summary
Get the mobile app
https://my.uopeople.edu/mod/forum/discuss.php?d=640854 40/40