1. Binary Hexadecimal Converter App
Description:
Example Output:
Welcome to the Binary/Hexadecimal Converter App
Compute binary and hexadecimal values up to the following decimal number: 12
Generating lists....complete!
Using slices, we will now show a portion of each list.
What decimal number would you like to start at: 4
What decimal number would you like to stop at: 7
Decimal values from 4 to 7:
4
5
6
7
Binary values from 4 to 7:
0b100
0b101
0b110
0b111
Hexadecimal values from 4 to 7:
0x4
0x5
0x6
0x7
Press Enter to see all values from 1 to 12.
Decimal --- Binary --- Hecadecimal
1----0b1----0x1
2----0b10----0x2
3----0b11----0x3
4----0b100----0x4
5----0b101----0x5
6----0b110----0x6
7----0b111----0x7
8----0b1000----0x8
9----0b1001----0x9
10----0b1010----0xa
11----0b1011----0xb
12----0b1100----0xc
Example Output:
Welcome to the Binary/Hexadecimal Converter App
Compute binary and hexadecimal values up to the following decimal number: 12
Generating lists....complete!
Using slices, we will now show a portion of each list.
What decimal number would you like to start at: 4
What decimal number would you like to stop at: 7
Decimal values from 4 to 7:
4
5
6
7
Binary values from 4 to 7:
0b100
0b101
0b110
0b111
Hexadecimal values from 4 to 7:
0x4
0x5
0x6
0x7
Press Enter to see all values from 1 to 12.
Decimal --- Binary --- Hecadecimal
1----0b1----0x1
2----0b10----0x2
3----0b11----0x3
4----0b100----0x4
5----0b101----0x5
6----0b110----0x6
7----0b111----0x7
8----0b1000----0x8
9----0b1001----0x9
10----0b1010----0xa
11----0b1011----0xb
12----0b1100----0xc1. Binary Hexadecimal Converter App
Assume a text file “Test.txt” is already created. Using this file, write a function to create three
files “LOWER.TXT” which contains all the lowercase vowels and “UPPER.TXT” which contains all
the uppercase vowels and “DIGIT.TXT” which contains all digits
The first line will contain a message prompt to input the first number.
The second line will contain a message prompt to input the second number.
The third line will contain a message prompt to input the third number.
The last line will contain the largest among the three numbers.
Enter·the·first·number:·1
Enter·the·second·number:·2
Enter·the·third·number:·3
The·largest·number·is·3
# Function: Display the Bitcoin price in the menu item – to assist the user when setting price levels
def updateMenuPrice(self):
# Get the latest Bitcoin info (as a Tick object) from getBitMexPrice(). Name it tickObj.
tickObj = self.getBitMexPrice()
# Update the currentPrice property with the Bitcoin price in tickObj.
. . .
# Create a variable called currentPriceLabel consisting of the text 'Current Price: ' followed # by currentPrice.
# Add currentPriceLabel and currentPrice as two separate items to a new list (the sub-List).
# Append the sub-List to displayList.
. . .
# Sort displayList using the SECOND item (price) in its sub-lists
. . .
# For each sub-List in displayList, print only the label (first item) in the sub-List
. . .
#replace ellipsis with applicable code
# Create displayList
displayList = []
# Loop through the prices in levelsList.
# During each loop:
# - Create a variable called priceLevelLabel consisting of the text 'Price Level: '
followed by the price.
# - Add priceLevelLabel and the price as two separate items to a new list (the sub-List).
# - Append the sub-List to displayList. for price in self.levelsList:
. . .
# Create a variable called previousPriceLabel consisting of the text 'Previous Price: ' followed
# by previousPrice. # Add previousPriceLabel and previousPrice as two separate items to a new list (the sub-List). # Append the sub-List to displayList.
. . .
# replace ellipsis with applicable code
#During the first loop of this method, previousPrice will still be 0 here,
# because it was set to currentPrice above, which also was 0 before we updated
# It above via getBitmexPrice().
# So when we reach this point during the first loop, previousPrice will be 0
# currentPrice would have just been updated via getBitmexPrice().
# we dont want to create the impression but that the price shot up from 0 to
# currentPrice.
# Therefore, if previousPrice == 0.0, it must be set equal to currentPrice here.
...
# replace the ellipsis with applicable code
# Once this method has been called, it uses a Timer to execute every 2 seconds
def monitorLevels(self):
# Create timer to call this method every 2 seconds
threading.Timer(2.0, self.monitorLevels).start()
# Since we will obtain the latest current price from the exchange,
# store the existing value of currentPrice in previousPrice
self.previousPrice = self.currentPrice
# Similar to updateMenuPrice(), call the getBitMexPrice() method to get
# a Ticker object containing the latest Bitcoin information. Then store
# the Bitcoin price in currentPrice
. . .
# replace ellipsis with applicable code
Given an integer N as a starting number and K as input, write a program to print a number pyramid of K rows as shown below.
In the example, the given starting number is
10, and the number of rows in the pyramid is 5.So, the output should be
10
11 12
13 14 15
16 17 18 19
20 21 22 23 24