Write a Python program that takes a number and prints how many digits are in that number.
[Consider the input number to be an INTEGER.]
[You are not allowed to use len() function]
Example: If the user gives 9876, your program should print 4.
Write a Python code that will read 5 numbers from the user. Your program should print the first number, the sum of the first 2 numbers, the sum of the first 3 numbers, and so on up to the sum of 5 numbers.
==========================================================
Sample Input 1:
1
2
3
4
5
Sample Output 1:
1
3
6
10
15
Write a Python program that asks the user for a quantity, then takes that many numbers as input and prints the maximum, minimum and average of those numbers.
[Please note that you CANNOT use max, min built-in functions]
[Also, you DO NOT need to use lists for this task]
==========================================================
Example: If the user enters 5 as an input for quantity and the enters the 5 numbers, 10, 4, -1, -100, and 1.
The output of your program should be: “Maximum 10”, “Minimum -100”, “Average is -17.2” as shown below.
Input:
5
10
4
-1
-100
1
Output:
Maximum 10
Minimum -100
Average is -17.2
# Various Icecream flavors
menu_item1 = "Chocolate"
menu_item2 = "Vanilla"
menu_item3 = "Strawberry"
order = input("\nWhich flavors would you like on your icecream today?\n\n" +
"\n".join([menu_item1, menu_item2, menu_item3]) + "\n\n")
# Convert input to list of flavors.
order = order.lower().split()
plural = "s" if len(order) > 1 else " "
union = " and " if len(order) > 1 else " "
print("\nYou have selected " + ", " .join(order[:-1]) + union + order[-1] + " flavor" + plural)
Question: How do I fix the Extra space for 1 flavor of choice and duplicated words and comma's for 2 or more flavors of choice?
My Output: "You have selected Chocolate flavor"
My Output: "You have selected Chocolate, and and Vanilla flavors"
My Output: "You have selected Chocolate, , Vanilla, and and Strawberry flavors"
bulb states pattern
bulb states pattern program contain input is a single line containing a positive integer n representing the number of rooms in the building and the output should contain n lines , each line containing the state of the bulb in the room numbered from 1 to n in the form of 0 and 1.
example:
input 1 :- 5
output 1 :-
0 1 0 1 0
0 1 0 1 0
0 1 0 1 0
0 1 0 1 0
0 1 0 1 0
String Concatenation
string concatenation program contains first line of input contains the string a, second line of input contains the string b, third line of input contains the string c and fourth line of input contains the string t
for example, we have input 1:- a=mari , b=to, c=zzo, and t=1321.
concatenate these in the order a+c+b+a and print the resulting string: marizzotomari as the output 1.
input 2 :- a= nano, b=of, c=rano, and t= 2131
output 2 :-ofnanoranonano
program to print the diamond using 2*n-1 rows
input:5
outpu:
. . . . 0 . . . .
. . . 0 0 0 . . .
. . 0 0 0 0 0 . .
. 0 0 0 0 0 0 0 .
0 0 0 0 0 0 0 0 0
. 0 0 0 0 0 0 0 .
. . 0 0 0 0 0 . .
. . . 0 0 0 . . .
. . . . 0 . . . .
i want the output should be like this. i did not got the desired output by using the code which you have sent.
Write a Python code of a program that asks the user to enter ten numbers and then display the total and the average of ONLY the odd numbers among those ten numbers.
[Please do not use list for this task]
==========================================================
Sample Input 1:
1
2
3
4
5
6
7
8
9
10
Sample Output 1: The total of the odd numbers is 25 and their average is 5.0
Explanation: The total is 1 + 3 + 5 + 7 + 9 = 25 and the average is 25/5 = 5.0
Ask the user to enter a Number, N
Display the summation of multiples of 7 up to that number (from 1 to N inclusive)
Write a Python program that takes a number from the user and prints its digits from left to right.
[Consider the input number to be an INTEGER. You are not allowed to use String indexing for solving this task]
=========================================================================
Example: if the user gives 32768, then print 3, 2, 7, 6, 8