Answer to Question #194480 in Python for desmond

Question #194480

1. Write a program that reads an integer from the user. Then your program should display a message indicating whether the integer is even or odd.


2. A string is a palindrome if it is identical forward and backward. For example “anna”, “civic”, “level” and“hannah” are all examples of palindromic words. Write a program that reads a string from the user and uses a loop to determines whether or not it is a palindrome. 


1
Expert's answer
2021-05-17T10:15:16-0400

1.

n = int(input('Enter an integer: '))
print('The number', n, 'is', end=' ')
if n%2 == 0:
    print('even')
else:
    print('odd')

2.

word = input('Enter a word: ')

n = len(word)
m = n//2
print('The word "', word, '" is ', sep='', end='')
for i in range(m):
    if word[i] != word[-1-i]:
        print('not ', end='')
        break
print('a palindrome')

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

Tyron
05.07.22, 01:23

great

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS