Please help me with this question.

Joined
Mar 26, 2022
Messages
1
Reaction score
0
Complete the code to take the input as an integer and output a square of "*" characters.
An input can be taken by using the following line.
Val = int(input())


For example, if the input is 2 and 5 respectively:



For example:

InputResult
2**
**
5*****
*****
*****
*****
*****
 
Joined
Mar 3, 2021
Messages
240
Reaction score
30
I'd rather have walked you to the answer, but... it's nothing. Next time, try showing what you've tried, what you don't understand, etc. Learning how to get the answer is better than just having the answer.

Python:
print((val*"*"+"\n")*val)
 
Joined
May 12, 2022
Messages
1
Reaction score
0
Complete the code to take the input as an integer and output a square of "*" characters.
An input can be taken by using the following line.
Val = int(input())


For example, if the input is 2 and 5 respectively:



For example:

InputResult
2**
**
5*****
*****
*****
*****
*****

Hey, Try this

val = int(input())
for x in range (0, val):
for y in range (val):
print('*',end='')
print()
 
Joined
May 30, 2022
Messages
3
Reaction score
0
side = int(input())
i = 0

while(i < side):
j = 0
while(j < side):
j = j + 1
print('*', end = '')
i = i + 1
print('')
 
Joined
May 30, 2022
Messages
3
Reaction score
0
Complete the code to find if a given number is a prime number? The program will take a positive integer greater than 1 as input and indicate if it is a prime number by saying "prime", and if it is not a prime number saying "not a prime". Note there are 3 places in the given code that you need to fix for this code to work properly and give the expected output.

i = int(input())
j = 2
while (j <= (i/j)):
if not(i%j):
print("not a prime")
break
j = j + 1
if (j > i/j):
print ("prime")
 
Joined
May 30, 2022
Messages
3
Reaction score
0
Modify the following code snippet to add two numbers.

answer:
def get_input():

# ------------------------------------

a = input("Enter number one: ")
b = input("Enter number two: ")

# ------------------------------------

sum = int(a) + int(b)
print (sum)

TestInputResult
get_input()12
23
Enter number one: 12
Enter number two: 23
35
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Staff online

Members online

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top