0% found this document useful (0 votes)
64 views40 pages

CS 1101 - AY2022-T2 - Discussion Unit 1

University of the people Assignment

Uploaded by

Lect urer
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 (0 votes)
64 views40 pages

CS 1101 - AY2022-T2 - Discussion Unit 1

University of the people Assignment

Uploaded by

Lect urer
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/ 40

1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1

CS 1101 Programming Fundamentals - AY2022-T2


Dashboard / My courses /
CS 1101 - AY2022-T2 / 11 November - 17 November /
Discussion Forum Unit 1 /
Discussion Unit 1

 Search forums

Discussion Forum Unit 1


Discussion Unit 1

Settings

Display replies in nested form

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. 

>>> print 'Hello, World!'

>>> 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

Re: Discussion Unit 1


by Fouad Tarabay - Thursday, 11 November 2021, 4:57 AM

output 1:

File "", line 1

print 'Hello, World'

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:

File "", line 1

print(01)

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

explanation : leading zeros is not permitted in my python version

output 5 : 1.5

explanation:computes (2/3) and then the program computes 1/(2/3) and gives the output in decimal.
125 words

Permalink Show parent

Re: Discussion Unit 1


by Luke Henderson - Thursday, 11 November 2021, 5:33 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Fouad Tarabay - Monday, 15 November 2021, 7:41 AM

Thank you Luke,

It was my first discussion so I will try to do a better one next time.


19 words

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Friday, 12 November 2021, 4:34 AM

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

Re: Discussion Unit 1


https://my.uopeople.edu/mod/forum/discuss.php?d=640854 2/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1

by Wilmer Portillo - Friday, 12 November 2021, 9:07 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Leameo Gilah - Monday, 15 November 2021, 2:53 AM

Hi Fouad, your explanations are not too bad but will be more awesome

if you just add a little bit of clarity.

I look forward to reading your future posts,thank you.


31 words

Permalink Show parent

Re: Discussion Unit 1


by Mayowa Ogunyale - Tuesday, 16 November 2021, 3:00 PM

Hi Fouad,

This well explained as requested. I had similar result.

Keep it up
14 words

Permalink Show parent

Re: Discussion Unit 1


by Hamidou Diallo - Wednesday, 17 November 2021, 5:20 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Crystal Noralez - Wednesday, 17 November 2021, 11:25 PM

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

Permalink Show parent


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

Input: print 'Hello, World!'

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

As in standard PEMDAS(Parentheses – Exponents – Multiplication – Division – Addition - Subtraction) mathematical procedure


whatever we place in parentheses is calculated first(Haelle, 2013). therefore 2/3 = 0.6666666666666666 and
1/0.6666666666666666 = 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?

Slate. Retrieved from https://slate.com/technology/2013/03/facebook-math-problem-why-pemdas-doesnt-always-give-a-


clear-answer.html

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

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Friday, 12 November 2021, 4:27 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Siphumelelise Ntshwenyese - Friday, 12 November 2021, 8:21 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Lenlie Quirk - Friday, 12 November 2021, 12:37 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Stephen Chuks - Sunday, 14 November 2021, 2:54 AM

Your post is clear and shows a solid understanding of the python programming language.
14 words

Permalink Show parent

Re: Discussion Unit 1


by Leameo Gilah - Monday, 15 November 2021, 3:18 AM

Hi Luke, Nice explanation.

you did extremely well by citing the sources.

I learned a lot from your way of assignment presentation.

nice work, keep it up. 


27 words

Permalink Show parent

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

Re: Discussion Unit 1


by Newton Sudi - Monday, 15 November 2021, 4:57 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Fouad Tarabay - Monday, 15 November 2021, 7:31 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Michaela Jedlickova - Tuesday, 16 November 2021, 4:35 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Mayowa Ogunyale - Tuesday, 16 November 2021, 3:00 PM

Hi Luke,

Well written explanation and citation.

Great Work!
9 words

Permalink Show parent

Re: Discussion Unit 1


by Hamidou Diallo - Wednesday, 17 November 2021, 5:29 PM

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

Permalink Show parent

Re: Discussion Unit 1



by Crystal Noralez - Wednesday, 17 November 2021, 11:28 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Friday, 12 November 2021, 4:12 AM

                        Unit 1 discussion forum

    Q1.

>>> print 'Hello, World!'


File "<stdin>", line 1

  
print 'Hello, World!'

  
^^^^^^^^^^^^^^^^^^^^^

SyntaxError: Missing parentheses in


call to 'print'. Did you mean print(...)?

                     Explanation

        The statement


is wrong as there should be parentheses before and after the argument. This is
because there are no
parentheses, the print statement could not find the
argument. "In Python 2, the print statement is slightly different; it is
not a
function, so it doesn’t use parentheses" (Downey, 2015, p. 3). The
newer version of Python (version 3 and above) considered
the print statement as
a function (Downey, 2015, p. 3); Therefore, the parentheses are a must and the
correct statement should
be as follows.

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

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:-

     Here we are using a function called


type() to know what the data type of the given data is. “The name of the
function is
type” (Downey, 2015, p. 17). The interpreter would compute the
value of  ½, which is equal to 0.5 as per
the previous question.
Hence, the interpreter would compute this statement:
type(0.5), giving off the result as 'float'. I would like to restate again here
that the interpreter would not read ½  as
a single value (fraction) but as a division of two integers.

   Q4.

>>> 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:-

      For Python 3, leading zeros are


accepted for zeros and decimal numbers only. For example, (1) 00000000000 and
(2)
000015.6. Python 3 would read the first example as 0 and the second one as
15.6. After researching leading zeros in Python, I
found out that Python 2
accepted leading zero (the first zero acts as a flag for octal integers) (Navone, 2019, para. 5).
As for
Python 3, the new version reads 0o or 0O (zero followed by a lowercase 'o' or
uppercase 'O') as a flag for octal integers. This
made octal integers much
clearer and easier to differentiate from the others.

    Q5.

>>> 1/(2/3)

1.5

>>>

                   Explanation:-

    In mathematical conventions, the order of evaluation depends


on the order of operations. The convention uses the order of
operations
abbreviated as PEMDAS to mean Parenthesis, Exponent, Multiplication,
Division, Addition, and Subtraction. Python
follows Mathematical convention
(Downey, 2015, p. 12). In order to calculate the value given in the statement
above, Python
will first calculate the value in parentheses because it has the
highest priority. 
Reference 

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

2)   Downey, A. (02492). Think Python: How to Think Like a


Computer Scientist (2nd ed., Version 2.2.23). Needham, MA: Green
Tea Press.

525 words
Tags:
Unit 1 Discussion
Unit 1 discussion forum.docx
Permalink Show parent

Re: Discussion Unit 1


by Yahya Al Hussain - Friday, 12 November 2021, 6:27 AM

this is excellent, thank you for the detailed explanation .


10 words

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Saturday, 13 November 2021, 10:42 AM

Thank you, Yahya, for your comments.


6 words

Permalink Show parent

Re: Discussion Unit 1


by Lenlie Quirk - Friday, 12 November 2021, 1:23 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Saturday, 13 November 2021, 10:41 AM

Thank you, Lenlie, for your help full and appreciating comments.
10 words

Permalink Show parent

Re: Discussion Unit 1


by Wilmer Portillo - Friday, 12 November 2021, 9:11 PM

Hi Samrawi, thank you very much for such a detailed discussion! You surely went above and beyond for this discussion. I
got the same output which simply mean we are using python 3 or above interpreter. Great job in citing and referencing!
42 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

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Saturday, 13 November 2021, 10:23 AM

Thank you, Wilmer, for your constructive comments.


7 words

Permalink Show parent

Re: Discussion Unit 1


by Luke Henderson - Saturday, 13 November 2021, 4:04 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Saturday, 13 November 2021, 10:19 AM

Thank you, Luke, for your appreciating comments.


7 words

Permalink Show parent

Re: Discussion Unit 1


by Newton Sudi - Monday, 15 November 2021, 5:03 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Fouad Tarabay - Monday, 15 November 2021, 7:37 AM

hello Samrawi,

Great work, thank you for your detailed explanation.


10 words

Permalink Show parent


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

Permalink Show parent

Re: Discussion Unit 1


by Michaela Jedlickova - Tuesday, 16 November 2021, 4:41 AM

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

Permalink Show parent

Re: Discussion Unit 1

by Simon Njoroge - Tuesday, 16 November 2021, 7:14 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Mayowa Ogunyale - Tuesday, 16 November 2021, 3:02 PM

Hi Yahya,

You have just given me an excellent work done.

Great Job!
13 words

Permalink Show parent

Re: Discussion Unit 1


by Hamidou Diallo - Wednesday, 17 November 2021, 5:35 PM

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

Permalink Show parent

Re: Discussion Unit 1 


by Crystal Noralez - Wednesday, 17 November 2021, 11:31 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Yahya Al Hussain - Friday, 12 November 2021, 6:18 AM

>>> print 'Hello, World!'

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

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.

3* I am using Python and that's why i got the error.


\\

>>>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

Permalink Show parent

Re: Discussion Unit 1


by Siphumelelise Ntshwenyese - Friday, 12 November 2021, 8:18 AM

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

Re: Discussion Unit 1

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

by Wilmer Portillo - Friday, 12 November 2021, 9:14 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Hyun Oh - Monday, 15 November 2021, 11:58 PM

Yahya,

I was able to learn deeper on the third statement about "type" (category). Thanks for your posting!
18 words

Permalink Show parent

Re: Discussion Unit 1


by Yahya Al Hussain - Tuesday, 16 November 2021, 10:27 AM

you're welcome, thanks for the reply


6 words

Permalink Show parent

Re: Discussion Unit 1


by Simon Njoroge - Tuesday, 16 November 2021, 7:10 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Waleed Khalid Saif - Wednesday, 17 November 2021, 1:20 PM

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

Permalink Show parent

Re: Discussion Unit 1 


by Siphumelelise Ntshwenyese - Friday, 12 November 2021, 7:36 AM

>>> print "Hello, World!"

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

File "", line 1

print 'Hello, World!'

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

Just a normal division

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

>>> 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)

File "", line 1

print(01)

01 is not a string, print() only takes in strings as an argument

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

>>> 1/(2/3)

1.5

Bracket division, then 1 divided by results of whatever is in the brackets


101 words

Permalink Show parent

Re: Discussion Unit 1


by Samrawi Berhe - Saturday, 13 November 2021, 10:37 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Stephen Chuks - Sunday, 14 November 2021, 3:10 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Ahmet Yilmazlar - Sunday, 14 November 2021, 8:42 AM

you demonstrated an understanding of the concepts
7 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

Permalink Show parent

Re: Discussion Unit 1


by Simon Njoroge - Tuesday, 16 November 2021, 7:06 AM

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

Permalink Show parent

Discussion Unit 1
by Lenlie Quirk - Friday, 12 November 2021, 8:03 AM

In Python 3, parentheses are a required function of the print command.

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

Permalink Show parent


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

Permalink Show parent

Re: Discussion Unit 1


by Stephen Chuks - Sunday, 14 November 2021, 2:58 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Ahmet Yilmazlar - Sunday, 14 November 2021, 8:43 AM

nice job
2 words

Permalink Show parent

Re: Discussion Unit 1


by Janelle Bianca Cadawas Marcos - Wednesday, 17 November 2021, 8:16 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Waleed Khalid Saif - Wednesday, 17 November 2021, 1:18 PM

Hi Lenlie

You're doing a great job, keep it up, and I wish you the best of luck
18 words

Permalink Show parent

Re: Discussion Unit 1


by Kyotaro Yoshimura - Wednesday, 17 November 2021, 10:54 PM

I think it is well written. You have explained very well. I learned a lot from it.
17 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

Permalink Show parent

Re: Discussion Unit 1


by Stephen Chuks - Friday, 12 November 2021, 9:30 AM

1.

>>>print 'Hello, World!'

Using the Python Interpreter on Windows Command Prompt, The code returned the following sytax error:

>>> print 'Hello World!"

File "", line 1

print 'Hello World!"

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)

File "", line 1

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

Permalink Show parent

Re: Discussion Unit 1


by Lenlie Quirk - Friday, 12 November 2021, 4:57 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Luke Henderson - Saturday, 13 November 2021, 4:14 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Ahmet Yilmazlar - Sunday, 14 November 2021, 8:43 AM

you demonstrated an understanding of the concepts


7 words

Permalink Show parent

Re: Discussion Unit 1


by Leameo Gilah - Monday, 15 November 2021, 2:48 AM

Hello Steven,

Thanks for your explanations, very brief and concise.

Also the colors used in your explanations are awesome.

I looked forward to reading your future posts.



27 words

Permalink Show parent

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

Re: Discussion Unit 1


by Hyun Oh - Tuesday, 16 November 2021, 12:11 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Waleed Khalid Saif - Wednesday, 17 November 2021, 1:17 PM

Hi Stephen

You have done more than great. So that I clarify and interpret the ambiguous symbols
17 words

Permalink Show parent

Re: Discussion Unit 1


by Kyotaro Yoshimura - Wednesday, 17 November 2021, 10:57 PM

It is well written. I think it is good that it is color-coded. It is easy to understand.


18 words

Permalink Show parent

Re: Discussion Unit 1


by Wilmer Portillo - Friday, 12 November 2021, 8:45 PM

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

1. Input: >>> print 'Hello, World!'

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

2. Input: >>> 1/2

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.

3. Input: >>> type(1/2)

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.

4. Input: >>> print(01)

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.

5. Input: >>> 1/(2/3)

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

Permalink Show parent

Re: Discussion Unit 1


by Janelle Bianca Cadawas Marcos - Wednesday, 17 November 2021, 9:14 AM

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

Permalink Show parent

Re: Discussion Unit 1



by Kyotaro Yoshimura - Wednesday, 17 November 2021, 10:58 PM

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

It is well written. Very polite description. I learned a lot from it.


13 words

Permalink Show parent

Re: Discussion Unit 1


by Ahmet Yilmazlar - Saturday, 13 November 2021, 2:56 PM

>>> print 'Hello, World!'

Error: Nissing parentheses in call to 'print'. ('Hello, World!')?

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)

Error: leading zeros in decimal integer literals are not permitted.

>>> 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

Permalink Show parent

Re: Discussion Unit 1


by Janelle Bianca Cadawas Marcos - Sunday, 14 November 2021, 5:04 AM

>>>print 'Hello, World!'

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)

output:  <class 'float'>



The "type()" function outputs the type of value that is in the parentheses (Downey, 2015). "1/2" is a float type because it
contains a decimal point, 1/2 = 0.5.

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

Permalink Show parent

Re: Discussion Unit 1


by Yahya Al Hussain - Sunday, 14 November 2021, 12:33 PM

this was well structured and easy to understand.


8 words

Permalink Show parent

Re: Discussion Unit 1


by Juan Duran Solorzano - Sunday, 14 November 2021, 11:53 PM

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

Permalink Show parent

Re: Discussion Unit 1


by Michaela Jedlickova - Tuesday, 16 November 2021, 4:46 AM

Hi Janelle,

great post! I particularly like your explanation of the fourth statement. Straight to the point! Thanks!
18 words

Permalink Show parent

Re: Discussion Unit 1


by Simon Njoroge - Sunday, 14 November 2021, 8:47 AM

Copy of the output statements

>>> print 'Hello, World!'

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

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

SyntaxError: invalid token

>>> 1/(2/3)

1.5

Explanation

The output of the first entry is as follows

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!')

2. The output for second entry is as follows

>>> 1/2

0.5

It is an arithmetic that means 1 divide by 2

/ (forward slash is used as the arithmetic operator for division.

The output is the correct answer 1 divided by 2 is 0.5

3. The output for the third entry is as follows

>>> type(1/2) This indicates that ½ is an operation that belongs to type of values referred to as float .

4. The output of the third entry is as follows

>>> print(01)

SyntaxError: invalid token

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

>>> print (1)

It would give the output as 1 above

5. The output of the 5th operation is as follows

>>> 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

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

Permalink Show parent

Re: Discussion Unit 1


by Suresh Sharma - Wednesday, 17 November 2021, 11:09 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Rejoice Uahomo - Sunday, 14 November 2021, 10:44 AM

After running the code in python terminal, this are the results 

Print 'Hello, World!' gave a syntax error: missing parentheses. 

1/2 gave 0.5

type(1/2) output class 'float' 

Print(01) gave a syntax error : leading zeros in decimal integer are not permitted 

1/(2/3) gave 1.5

44 words

Permalink Show parent

Re: Discussion Unit 1


by Juan Duran Solorzano - Sunday, 14 November 2021, 11:46 PM

I would like to add some details to your answer,

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

Re: Discussion Unit 1


by Juan Duran Solorzano - Sunday, 14 November 2021, 11:33 AM

>>> print "Hello, World!"

File "<stdin>", line 1

  print "Hello, World!"

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)

File "<stdin>", line 1

  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

Permalink Show parent


https://my.uopeople.edu/mod/forum/discuss.php?d=640854 25/40
1/5/22, 1:45 AM CS 1101 - AY2022-T2: Discussion Unit 1

Re: Discussion Unit 1


by Yahya Al Hussain - Sunday, 14 November 2021, 12:34 PM

great answer
2 words

Permalink Show parent

Re: Discussion Unit 1


by Suresh Sharma - Wednesday, 17 November 2021, 11:05 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Leonidas Papoulakis (Instructor) - Sunday, 14 November 2021, 12:00 PM

Dear students,

great work from all of your in this first week, well done!
14 words

Permalink Show parent

Re: Discussion Unit 1


by Leameo Gilah - Monday, 15 November 2021, 1:58 AM

line 1

print 'Hello, World!'

^^^^^^^^^^^^^^^^^^^^^

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

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

Permalink Show parent

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

Re: Discussion Unit 1


by Newton Sudi - Monday, 15 November 2021, 5:11 AM

Great work, in a brief and understandable form. You did all the questions asked.
14 words

Permalink Show parent

Re: Discussion Unit 1


by Leameo Gilah - Monday, 15 November 2021, 10:16 AM

Thanks dear,
2 words

Permalink Show parent

Re: Discussion Unit 1


by Newton Sudi - Monday, 15 November 2021, 4:29 AM

When running the code functions they resulted in the following outputs:

1. File "", line 1

print 'Hello, World!'

^^^^^^^^^^^^^^^^^^^^^

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

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.

This is defined as a division operator in both versions 2 and 3 of python.

3.
The function type assigns the value and type. 1/2 is a floating-point number belonging to class 'float'.

4. File "", line 1

print(01)

IndentationError: unexpected indent

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

Permalink Show parent



Re: Discussion Unit 1
by Juan Duran Solorzano - Tuesday, 16 November 2021, 7:03 AM

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)

File "", line 1

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

Permalink Show parent

Re: Discussion Unit 1


by Ismail Ahmed - Tuesday, 16 November 2021, 11:13 AM

Hi Newton Sudi

Great work. Thanks for sharing


8 words

Permalink Show parent

Re: Discussion Unit 1


by Suresh Sharma - Wednesday, 17 November 2021, 11:02 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Ismail Ahmed - Monday, 15 November 2021, 6:01 PM

print 'Hello, World!'

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).

Citation: (Downey, 2015, p. 3)

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).

Citation: (Downey, 2015, p. 3)

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

Citation: (Downey, 2015, p. 4)

print(01)

Output: SyntaxError: invalid token

Explanation: leading zeros not allowed in Python. (Downey, 2015).

Citation: (Downey, 2015, p. 8)

1/(2/3)

Output: 1.5

Explanation: performs arithmetic operation of division type. (Downey, 2015).

Citation: (Downey, 2015, p. 3)

Reference:

Downey, A. (2015). Think Python: How to Think Like a Computer Scientist. Needham, Massachusetts: Green Tea Press
188 words

Permalink Show parent

Re: Discussion Unit 1


by Janelle Bianca Cadawas Marcos - Wednesday, 17 November 2021, 9:51 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Hyun Oh - Monday, 15 November 2021, 11:34 PM

1)

>>> print 'Hello, World!'

File "<stdin>", line 1

  print 'Hello, World!'

  ^^^^^^^^^^^^^^^^^^^^^

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

-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)

File "<stdin>", line 1

  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

Permalink Show parent

Re: Discussion Unit 1


by Ismail Ahmed - Tuesday, 16 November 2021, 11:11 AM

Hi Hyun Oh

Good job
5 words

Permalink Show parent

Re: Discussion Unit 1


by Michaela Jedlickova - Tuesday, 16 November 2021, 4:14 AM

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

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

...      

SyntaxError: Missing parentheses in call to 'print'. Did you


mean print(...)?

>>>
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)

SyntaxError: leading zeros in decimal integer literals are


not permitted; use an 0o prefix for octal integers

>>>

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

Re: Discussion Unit 1


by Newton Sudi - Tuesday, 16 November 2021, 5:10 AM

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

Permalink Show parent

Re: Discussion Unit 1


by Ismail Ahmed - Tuesday, 16 November 2021, 11:10 AM

Hi Michaela Jedlickova

Thanks for sharing. Keep up the good work.


11 words

Permalink Show parent

Re: Discussion Unit 1


by Mayowa Ogunyale - Tuesday, 16 November 2021, 7:51 AM

Python 3.9.2 (tags/v3.9.2:1a79785, Feb 19 2021, 13:44:55) [MSC v.1928 64 bit (AMD64)] on win32

Type "help", "copyright", "credits" or "license" for more information.

>>> ('Hello, World!')

'Hello, World!'
>>> print 'Hello, World!

There is slight different in version 2 and 3

>>> 1/2

0.5

Arithmetic operatiors are the same

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

File "", line 1

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

Values and types are the same .

>>> 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

TEXT - Think Python 2e.pdf (uopeople.edu)


112 words

Permalink Show parent

Re: Discussion Unit 1


by Ismail Ahmed - Tuesday, 16 November 2021, 11:09 AM

Hi Mayowa Ogunyale

Great job.
5 words

Permalink Show parent

Re: Discussion Unit 1


by Suresh Sharma - Wednesday, 17 November 2021, 9:24 AM

>>> print 'Hello, World!'

File "", line 1

print 'Hello, World!'

^^^^^^^^^^^^^^^^^^^^^

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

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 -

The operator / performs division:

>>> 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)

File "", line 1

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

Permalink Show parent

Re: Discussion Unit 1


by Aymen Abdella - Wednesday, 17 November 2021, 10:50 AM

My response,

>>> print 'Hello, World!'

SyntaxError: because It is missing parentheses in call to 'print'.

It should be print('Hello, World!').

>>> 1/2

0.5

Python has a built-in calculator package that interprets the formula and produces the output. This is the division result.

>>> type(1/2) This command shows the variable type.

>>> 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

Permalink Show parent

Re: Discussion Unit 1


by Waleed Khalid Saif - Wednesday, 17 November 2021, 12:23 PM

Input:

print("hello world")

1 / 2

type(1 / 2)

print("01")

1/(2/3)

Output:

hello world

01

Process finished with exit code 0


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

Permalink Show parent

Re: Discussion Unit 1


by Peter Odetola - Wednesday, 17 November 2021, 2:49 PM

DISCUSSION UNIT 1: CS 1101 (ODETOLA PETER IFEOLU)

>>>print 'Hello, World!'

Output:

SyntaxError: unexpected indent.

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:

>>> type (42.0)

>>>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.

Word Count = 297

REFERENCE

Downey, A. (2015). Think python: How to Think Like a Computer Scientist (2nd ed.). Green Tea

Press.
293 words

Permalink Show parent

Re: Discussion Unit 1

by Hamidou Diallo - Wednesday, 17 November 2021, 4:59 PM 

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

>>> print 'Hello world!'

File "", line 1

print 'Hello world!'

^^^^^^^^^^^^^^^^^^^^

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

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.

>>> type (1/2)


this third instruction displays on the screen the same result on the textbook when we wonder what type is a value.

>>> print(01)

File "", line 1

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

Permalink Show parent

Re: Discussion Unit 1


by Alperen Akgun - Wednesday, 17 November 2021, 5:10 PM

>>> print 'Hello, World!'

Output:

File "<stdin>", line 1


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

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'>

Explaining: This command displays the class of parameter.

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

Permalink Show parent

Re: Discussion Unit 1


by Crystal Noralez - Wednesday, 17 November 2021, 10:01 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.

>>> print 'Hello, World!'

- interpreter (python) response

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

Statement:

3 print() is a function , there for, the correct syntax would be >>>print ('Hello, World!')

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

- print 'Hello, World!' to show “Hello, World!” (Downey, 2015, p. 3)

>>> 1/2

- interpreter (python) response

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

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)

- interpreter (python) response Statement:

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)

- interpreter (python) response

1.5

Statement:

A division result was displayed.

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

Permalink Show parent

Re: Discussion Unit 1


by Kyotaro Yoshimura - Wednesday, 17 November 2021, 10:32 PM

>>> print 'Hello, World!'

File "", line 1

print 'Hello, World!'

^^^^^^^^^^^^^^^^^^^^^

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

>>> 1/2

0.5

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

File "", line 1

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

Permalink Show parent

Re: Discussion Unit 1


by Victoria Jones - Wednesday, 17 November 2021, 11:42 PM

print 'Hello, World!'

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

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

Permalink Show parent

UoPeople Clock (GMT-5)

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.

◄ Learning Guide Unit 1

Jump to...

Learning Journal Unit 1 ►

Disclaimer Regarding Use of Course Material  - Terms of Use


University of the People is a 501(c)(3) not for profit organization. Contributions are tax deductible to the extent permitted by law.
Copyright © University of the People 2021. All rights reserved.

You are logged in as Stephen Chuks (Log out)


Reset user tour on this page
 www.uopeople.edu










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

You might also like