FIN551: Given a 2-digit whole Number, n, display the Message Valid if n Contains the Digit 1: Python Programming Assignment, SUSS, Singapore

University Singapore University of Social Science (SUSS)
Subject FIN551: Python Programming

(a) Write statements for the following tasks:

(i) Given a 2-digit whole number, n, display the message Valid if n contains the digit 1. For example, 10, 11 and 31 are valid but 33, 34 and 35 are not. Do not convert n into a string.

(ii) Given that string s has exactly 3 characters. Display the message Group A if characters in the first, middle and last positions are the same. For example, if s is ‘222’, display Group A. Display message Group B if the first and last characters are the same but the middle character is different. For example, if s is ‘232’, display Group B. Display message Group C if the first and last characters are not the same. For example, if s is ‘223’ or ‘213’, display Group C.

(iii) Given a list of numbers, nList such as [1, 3, 2]. If the sum of digits in the even position is even, display the message Sum of digits in even positions is even. Otherwise, display the message Sum of digits in even positions is odd. Do not use loop/repetition structure. Instead, use the slice operator and the built-in function sum.

(b) Given a string, s that contains a sequence of digits.

(i) Write a code segment that picks each digit in the string in reverse order, reduces each digit by 1 and displays the resulting number on separate lines. The code segment should produce the output for a given string ‘1204’: 3

-1
1
0

(ii) Write a code segment that prints the message True if the sum of each pair of adjacent digits does not exceed 12. Print the message False otherwise. For illustration, suppose the string s has 5 digits: d0d1d2d3d4. If d0 + d1, d1 + d2, d2 + d3, d3 + d4 do not exceed 12, the code segment prints True. Thus, for the string ‘48531’, the code segment prints the message False because the sum of pair of adjacent digits 85, or 8+5 exceeds 12.

Buy Custom Answer of This Assessment & Raise Your Grades

Get Help By Expert

Are you searching for someone to do my assignment? then don't stress at Singapore Assignment Help we have proficient suss assignment experts who have an amazing capability to design outstanding solutions on FIN551: Python Programming Assignment. Our experts work 24*7 hours to provide all assignment answers before the deadline.

Answer

Looking for Plagiarism free Answers for your college/ university Assignments.

Ask Your Homework Today!

We have over 1000 academic writers ready and waiting to help you achieve academic success