To accomplish this without using a loop,
we can use math on a string.
Example:
print("apple" * 8)
Output:
appleappleappleappleappleappleappleapple
In this example,
the multiplication by 8 actually creates 8 copies of the string.
So that's the type of logic we want to apply to our problem.
<span>def powersOfTwo(number):
if number >= 0:
return print("*" * 2**number)
else:
<span>return
Hmm I can't make indentations in this box,
so it's doesn't format correctly.
Hopefully you get the idea though.
We're taking the string containing an asterisk and copying it 2^(number) times.
Beyond that you will need to call the function below.
Test it with some different values.
powersOfTwo(4) should print 2^4 asterisks: ****************</span></span>
Answer:
Data is stored in tables, where each row is an item in a collection, and each column represents a particular attribute of the items. Well-designed relational databases conventionally follow third normal form (3NF), in which no data is duplicated in the system. ... With a homogenous data set, it is highly space efficient
Answer:
The solution code is written in Python 3:
- num = 11
-
- while(num <=88):
- firstDigit = num // 10
- secondDigit = num % 10
-
- if(firstDigit == secondDigit):
- print(num)
-
- num += 1
Explanation:
Firstly, create a variable, num, to hold the starting value, 11 (Line 1)
Create a while loop and set the loop condition to continue the loop while num smaller or equal to 88 (Line 3).
Within the loop, we can use // to perform the floor division and get the first digit of the num. We use modulo operator % to get the second digit of the num. (Line 4 - 5)
If the firstDigit is equal to secondDigit, print the number (Line 7 -8). Lastly, increment the num by one and proceed to next iteration (Line 10).