Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

CS 1101 Programming Fundamentals - AY2022-T1
Dashboard
My courses
CS 1101 - AY2022-T1
30 September - 6 October
Learning Guide Unit 5

Learning Guide Unit 5
Learning Guide Unit 5

Programming Assignment
This assignment is based on Exercise 7.1 from your textbook.

Part 1

Encapsulate the following Python code from Section 7.5 in a function named my_sqrt that takes a as a parameter, chooses a starting value for x, and returns an estimate of the square root of a.

while True:
y = (x + a/x) / 2.0
if y == x:
break
x = y
for i in displayList:
    print(i[0])
    #loop through displayList
    for i in range(0,len(displayList)):
        #Test if the fist item in the current sub-list contains the text "Price Level
        #Tip: Remeber that each sub-list is a (displayList). So you have
        #       to access its items via displayList followed by TWO indexes.
        ......
            #Extract the second item from the currnet sub-list into variable called priceLevel
        priceLevel = ...
        #Test if priceLevel is between previousPrice and currentPrice OR
        #        priceLevel == previousPrice OR
        #        priceLevel == currentPrice
        if....

        :
            #Sound the alarm. Pass in the frequency and duration.
            if self.__currentPrice > self.__previousPrice:
                frequency = 800
                duration = 700
            else:
                frequency = 400
                duration = 700
            winsound.Beep(frequency, duration)

            #Print the text 'Alarm' with a green background color, so that the user
            #can go back and check when the alarm was sounded.
            ...





4. Negative Fusion


As I've said before, there are three types of numbers; the positive, the zero, and the negative ones. Today, we shall pay attention only to the negative ones now. Make a loop that will accept random decimal/float numbers. When the user inputs 0, the loop will terminate and then output the sum of all negative numbers inputted in 3 decimal places.


Let's code this.


Input

Multiple lines containing a decimal.


2. 4434

-1.3433

-2.444

6.432



Output

A line containing a decimal with three decimal places.


-3.787


3. The Last 'Zeroes'


How many zeroes are there after the last non-zero digit of a million? A trillion? To easily identify that, let us make a program to count and print the number of zeroes after the last non-zero digit on a number. For example, in 20400, there are 2 zeroes after the last non-zero digit of the number, 4.


Are you up for this challenge?


Input

A line containing an integer.


20400


Output

A line containing an integer.


2


2. Phonics


Did you know that the first letters in the alphabet that a child learns are the vowels? Well, since they're the first letters that we learned as babies, then they must be easy to identify, right? So, let's make a code that will identify all vowels in a string and print out how many they are!


Let's go!


Input

A line containing a string.


CodeChum


Output

A line containing an integer.


3


1. FizzBuzz 2.0


Remember the game of FizzBuzz from the last time? Well, I thought of some changes in the game, and also with the help of loops as well. Firstly, you'll be asking for a random integer and then loop from 1 until that integer. Then, implement these conditions in the game:

• print "Fizz" if the number is divisible by 3.

• print "Buzz" if the number is divisible by 5.

• print "FizzBuzz" if the number is divisible by both 3 and 5.

• print the number itself if none of the above conditions are met.


Input

A line containing an integer.


15


Output

Multiple lines containing a string or an integer.


1

2

Fizz

4

Buzz

Fizz

7

8

Fizz

Buzz

11

Fizz

13

14

FizzBuzz


Given X="ABCDEFGHIJKLMNOPQRSTUVWXYZ", X[8:16:2] is?



a) IKMO


b) IKMOQ


c) HJLNP


d) Error



This problem is related to the virtual learning environment application discussed in one theory session and a few practicals. In this problem, you are tasked with creating and updating learner profiles, a particular type of user. As well, given a learner profile, we would like to retrieve the learning materials in the form of topics. Note that the learning materials for a given course will differ from one learner profile to another. For example, for a course "Distributed Systems and Applications", the learning materials for a learner with a weak background in "Programming" compared o another learner profile with a stronger background in programming.

Your task is to:

1. Provide a description in OpenAPI of the API that allows for communication between a client and a service for the functionalities discussed above;

2. Implement a corresponding client and a service. 



Output should include: 


  • This assignment uses 1 loop
  • It will require that you use escape characters like \n.
  • Please note that the sales tax in PA is 6%
  • Make sure that the program does not ask for price again once a user decides to checkout.



Amazon Shopping Cart

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

What is your name? Bob

Welcome to Amazon, Bob!


What item would you like to purchase? Type Checkout to stop shopping.

Playstation

Please enter the item price:

$299.99

What item would you like to purchase? Type Checkout to stop shopping.

Airpods

Please enter the item price:

$199.99

What item would you like to purchase? Type Checkout to stop shopping.

hat

Please enter the item price:

$18.99

What item would you like to purchase? Type Checkout to stop shopping.

Checkout


Congratulations, Bob! 

Your total is: $518.97

Your total with sales tax is: $550.1082




Word Count

Given a sentence S, write a program to print the frequency of each word in S. The output order should correspond with the word's input order of appearance.


LATEST TUTORIALS
APPROVED BY CLIENTS