Answer:
def typeHistogram(it,n):
d = dict()
for i in it:
n -=1
if n>=0:
if str(type(i).__name__) not in d.keys():
d.setdefault(type(i).__name__,1)
else:
d[str(type(i).__name__)] += 1
else:
break
return list(d.items())
it = iter([1,2,'a','b','c',4,5])
print(typeHistogram(it,7))
Explanation:
- Create a typeHistogram function that has 2 parameters namely "it" and "n" where "it" is an iterator used to represent a sequence of values of different types while "n" is the total number of elements in the sequence.
- Initialize an empty dictionary and loop through the iterator "it".
- Check if n is greater than 0 and current string is not present in the dictionary, then set default type as 1 otherwise increment by 1.
- At the end return the list of items.
- Finally initialize the iterator and display the histogram by calling the typeHistogram.
Answer:-
(10111.001)₂
Explanation:
To convert a decimal number to a binary number we have to constantly divide the decimal number by 2 till the decimal number becomes zero and the binary number is writing the remainders in reverse order of obtaining them on each division.
Hence the binary number is 10111.001
To convert binary to hexa decimal we to make a group 4 binary bits starting from the decimal and moving outwards if the last group is not of 4 then add respective 0's and write the corresponding hexa decimal number.
<u>0001</u> <u>0111</u> . <u>0010</u>
1 7 2
Hence the hexadecimal number is 17.2
Check your trash can, if that doesnt work then I would say its lost.
Python code:
x=121
x += 9
x *= 2
x -= 4
x >>= 2
x -= 121
Answer:
name = input("Enter customer name: ")
quantity = int(input("Enter quantity: "))
size = input("Enter size [large-medium-small]: ")
if size == "large":
sales = (quantity / 12) * 13
if size == "medium":
sales = (quantity / 12) * 11
if size == "small":
sales = (quantity / 12) * 8.6
print(name + " ordered " + str(quantity) + " " + size + " ballons")
print("Total sales is $" + str(sales))
Explanation:
*The code is in Python.
Ask the user to enter name, quantity, and size
Check the size using if structure. Depending on the size, calculate the sales using the given cost for for a dozen.
Print the order information and total sales