Write short note on following:
a) How to create One-dimensional array?
b) How to identify datatype for numpy array?
Multiply 8 with 4, and print the result.
a. Display this to the console:
Bananas: $0.50 each
Strawberries: $.75 each
b. Ask the user what they want to purchase. They will type an 'b' for bananas or an 's' for strawberries.
c. Your program will then ask for the number of bananas or strawberries they wish to purchase (depending on which they selected). The number of bananas cannot exceed 20 and the number of strawberries cannot exceed 10. If the user input exceeds these maximums your program should exit.
d. Your program should then print a report to the console like the following:
Item Qty Price Total
--------------------------
Bananas 4 $0.50 $2.00
Tax(15%): $0.30
Total Cost: $2.30
e. Ask the user for the amount tendered (the amount of money given for the payment). If the amount tendered is over $100 tell the user that there isn't enough change for such an amount and exit.
f. Finally, your program should print another report to the console like the following:
Amount tendered: $10
Change: $7.70
Thank you for shopping with SAI!
by CodeChum Admin
To give you more of a challenge with a number's digits, let's try counting how many of a certain digit is present on a given number.
Let's start coding!
Instructions:
Input
A line containing two integers separated by a space.
2·124218Output
A line containing an integer.
2by CodeChum Admin
Looping a number and taking away each digit of it is so much fun, but I wanted to try out a much more complex task: getting the largest digit among them all.
Think you can handle the job?
Instructions:
Input
A line containing an integer.
214Output
A line containing an integer.
4by CodeChum Admin
Manipulating values from a series of numbers is fun, but let's try exploring the use of loops a little more.
How about printing out each digit of a number starting from its rightmost digit, going to its leftmost digit?
Instructions:
Input
A line containing an integer.
214Output
Multiple lines containing an integer.
4
1
2by CodeChum Admin
Looping numbers is fun, but it's even more exciting when we combine complex tasks to it, just like looping through a series of numbers and performing a series of code only to special numbers, like odd ones! And today, we're going to do just that.
Are you ready?
Instructions:
Input
A line containing an integer.
10Output
Multiple lines containing an integer.
9
7
5
3
1Write a fruitful function sum_to(n) that returns the sum of all integer numbers up to and
including n. So sum_to(10) would be 1+2+3. . . +10 which would return the value 55.
I want very simple code because I am a student.
Write a program that reads a string and returns a table of the letters of the alphabet in
alphabetical order which occur in the string together with the number of times each letter
occurs. Case should be ignored. A sample output of the program when the user enters the data
“ThiS is String with Upper and lower case Letters”, would look this this:
a 2
c 1
d 1
e 5
g 1
h 2
I 4
l 2
n 2
o 1
p 2
r 4
s 5
t 5
u 1
w 2
I want a very simple code for students.
The great circle distance is the distance between two points on the surface of a sphere.
Let (x1, y1) and (x2, y2) be the geographical latitude and longitude of two points.
The great circle distance between the two points can be computed using the following formula:
d = radius * arccos(sin(x1) * sin(x2) + cos(x1) * cos(x2) * cos(y1 - y2))
Write a program that prompts the user to enter the latitude and longitude of two points on the earth in degrees and displays its great circle distance.
The average earth radius is 6,371.01 km.
The angles as given in the formula are all in degrees.
Use negative values
for south and east degrees, positive values for north and west degrees.
Do all you can to make your program structure when running, conform with the sample run given below:
Enter point 1 (latitude and longitude) in degrees:
39.55, -116.25
Enter point 2 (latitude and longitude) in degrees:
41.5, 87.37
The distance between the two points is 10691.79183231593 km