Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

Homework 2b

Introduction

Overview

This is an individual assessment. It will contribute 2% of your inal marks. The purpose of this  assessment component is to gauge whether you are following the weekly contents of the unit.

This is an assessment, and sta are not permitted to give guidance on your code or how to solve the speciic problem. That is the purpose of the assessment that you are required to perform to achieve the grade.

If you have a question to ask on Ed please search before asking. However, remember that you should not be posting any assessment codes publicly, as this would constitute academic dishonesty. It is

recommended that you complete each of the programming question by the end of the week that it is released.

Late submissions are not accepted unless an approved special consideration is granted.

You are encouraged to ask questions during the Helpdesk and on the Ed discussion board IF you need

clariication on speciic concepts or about the question itself. However, remember that you should not be posting any codes publicly, as this would constitute academic dishonesty.

Homework Format

There may be multiple programming questions that you are expected to complete by the end of the week. You should be able to complete them if you can apply the concepts covered over the week. If you have diculties with them, it is best to review the contents of the week.

The subsequent weeks will require you to build on the concepts from previous weeks. Hence, it is recommended that you keep up with the weekly contents as much as possible.

Marking

Your submission will be marked using an auto-grader that checks the correctness of the program with the given speciication. The marking system will automatically check your code against the

public test cases after your make a submission by pressing the  Mark  button. If you attempt to

deceive the auto-grader or do not answer the questions, 0 marks will be awarded for the question.

The following rules apply to your submission:

· Your submission must be able to compile and run within the Ed environment provided. · Only the iles given in the scafold codes will be started by the auto-marker.

Ensure that you have submitted your codes with the correct ile names. The auto-marker will only start the iles that are speciied in the question.

The Python version that is presently being used on the Ed system:

$  python3  --version  Python  3.11.3

Final Marks for Homework 2

Your inal marks for Homework 1 will be derived from auto-grader test cases for all homework

exercises. Homework 2 consists of Homework 2a (Week 3), Homework 2b (Week 4), Homework 2c (Week 5), and Homework 2d (Week 6). The latest submission made before the due date will be used for the reporting of the marks. Late submissions will be awarded 0 marks.

The inal due date for all questions in Homework 2 is on 10th September 2023, 23:59.

Student Declaration

By submitting this assignment, you declare the following:

I declare that I have read and understood the University of Sydney Student Plagiarism: Coursework Policy and Procedure, and except where specically acknowledged, the work contained in this

assignment/project is my own work and has not been copied from other sources or been previously submitted for award or assessment.

I understand that failure to comply with the Student Plagiarism: Coursework Policy and Procedure can

lead to severe penalties as outlined under Chapter 8 of the University of Sydney By-Law 1999 (as

amended). These penalties maybe imposed in cases where any signicant portion of my submitted work  has been copied without proper acknowledgement from other sources, including published works, the     Internet, existing programs, the work of other students, or work previously submitted for other awards or assessments.

I realise that I maybe asked to identify those portions of the work contributed by me and required to demonstrate my knowledge of the relevant material by answering oral questions or by undertaking

supplementary work, either written or in the laboratory, in order to arrive at the nal assessment mark.

I acknowledge that the School of Computer Science, in assessing this assignment, may reproduce it entirely, may provide a copy to another member of faculty, and/or communicate a copy of this

assignment to a plagiarism checking service or in-house computer program, and that a copy of the

assignment maybe maintained by the service or the School of Computer Science for the purpose of future plagiarism checking.

Counting to 100 (0.25 marks)

Write a while  loop to count from numbers 1 to 100 (inclusive).

Example:

1

2

3

98

99

100

Count-down (0.25 marks)

Write a while  loop to count backwards for numbers 500 to 400 (inclusive).

Example:

500

499

498

401

400

32-repeat (1 mark)

Write a program which reads in a string, and outputs the string 32 times using a loop only if the total number of characters in the string is odd. The program does nothing if it is not. White spaces are

counted as a character.

Example:

Enter  a  string:  hello

hello

hello

[ . . .  hello  30  more  times]


Example:


Enter  a  string:  goodbye

goodbye

goodbye

[ . . .  goodbye  30  more  times]


Example:


Enter  a  string:  he  man


Fizz buzz (0.5 marks)


Write a program that outputs the numbers from 1 to 100 (inclusive), unless:

The number is a multiple of 3, then output  Fizz

The number is a multiple of 5, then output  Buzz

· The number is a multiple of both 3 and 5, then output  FizzBuzz


$  python  fizzbuzz.py

1

2

Fizz

4

Buzz

...


Response Conirmation (1 mark)


You received angry complaints from candidates that the program you have written does not allow

them to change their responses when they make a typo because the auto-marker was too "ecient". Modify the program to inform users that they have entered an invalid response by displaying the

message Invalid  response.  It  must  be  A/B/C/D!  to the terminal and re-prompt user's for

another answer until a valid response is received. The program then auto-marks the responses

received and display the result before moving to the next question. There must be a new line before the next question.

This is a sample input/output for a candidate that failed to answer all questions correctly despite entering valid responses for all questions.


Question  1

Which  of  the  following  Python  statements  will  display  this  message  in  the  terminal?

*********************************

Terminal  output:

I  love  INFO1110

*********************************

Note:  The  labels    and    denote  the  start  and  end  of  the  output  and  should not  appear  on  the  terminal .

A .  print(I  love  INFO1110)

B .  print("I"  "love"  "INFO1110")

C .  print("I  love"  "INFO1110")

D .  print("I  love  INFO1110")

Response  for  Question  1:  #d

You  have  scored  1  mark .


Question  2

The  built-in  function  input  will  return  a  value  of  type:

A .  int

B .  str

C .  float

D .  None

Response  for  Question  2:  #N

Invalid  response .  It  must  be  A/B/C/D!

Response  for  Question  2:  #B?

Invalid  response .  It  must  be  A/B/C/D!

Response  for  Question  2:  #B

You  have  scored  1  mark .


Question  3

This  question  is  based  on  the  program  below:

*********************************

#  Start

name  =  input("What's  your  name?:  ")

#  End

*********************************


After  running  the  program,  you  have  keyed  in  "Bob"  followed  by  the  Enter  key .

What  is  the  value  stored  in  variable  name?

A .  "Bob\n"

B .  "Bob"

C .  "BobEnter"

D .  Bob

Response  for  Question  3:  #a

You  have  scored  0  marks .


Total  Marks:  2  out  of  3


Special sum 1 (1 mark)


Write a program to read 3 integers from the user, and calculate the sum of the integers. However, if one of the values is the same as another of the values, it should not count towards the sum.

You can assume all inputs will be valid.

Example:


Enter  a:  1

Enter  b:  2

Enter  c:  3

The  sum  is  6


Example:


Enter  a:  3

Enter  b:  2

Enter  c:  3

The  sum  is  2


Example:


Enter  a:  3

Enter  b:  3

Enter  c:  3

The  sum  is  0


Special sum 2 (1 mark)


Write a program to read 5 integers from the user, and calculate the sum of the integers. However, if   one of the values is 7, then it does not count towards the sum and the next value entered by the user does not count.

So for example, if b is 7, then both b and c do not count toward the sum.

You can assume all inputs will be valid.


Example:


Enter  a:  1

Enter  b:  2

Enter  c:  3

Enter  d:  4

Enter  e:  5

The  sum  is  15


Example:


Enter  a:  1

Enter  b:  2

Enter  c:  3

Enter  d:  7

Enter  e:  10

The  sum  is  6


Example:


Enter  a:  7

Enter  b:  7

Enter  c:  3

Enter  d:  7

Enter  e:  5

The  sum  is  0



Special Consideration


Special Consideration (University policy)


If your performance on assessments is afected by illness or misadventure you can apply for special consideration. See this page for information on Special Consideration:

http://sydney.edu.au/current_students/special_consideration/

You need to follow proper bureaucratic procedures for your application to be processed swiftly. If you don't, there will be delays in processing your application and in the worst-case scenario, your application is rejected.

Special consideration applications for illness, injury or misadventure must be made within 3 working days of the assessment deadline. See this link for more information on when you need to make the  application: https://www.sydney.edu.au/students/special-consideration/apply.html





Special Consideration Checklist

· Did you select the correct reason for applying special consideration?

The type of exceptional circumstances afect the type of supporting documents required. See the table in this page: https://www.sydney.edu.au/students/special-consideration/eligibility-

documents.html

· Have you selected the correct unit? It should be INFO1110 or COMP9001.

· Have you selected the correct Assessment item? It should be Homework 2.

· Have you selected the correct due date for the Assessment Item?  It should be 10 September 2023.

· Have you attached the relevant supporting document?

These are the common documents for illness and misadventure depending on your exceptional circumstances:

Statutory declaration

Professional practitioner certiicate

professional-practitioner-certiicate.pdf


Student declaration

student-declaration(1).docx