Answer to Question #291917 in Python for Micky

Question #291917

a) Write a program which allows a student to enter a string and test for whether string is a palindrome or not. If string is a palindrome replace all characters with random numbers between 1 and 100 and displays the output, else prompt student re-enter string.



b) Write a program which allows a company secretary to write employee details in file called EmployeeHours.txt and retrieves the information using pointers to display it on the screen.

1
Expert's answer
2022-01-31T07:56:27-0500
# Python 3.9.5

# a)
#
# import random
#
#
# def isPalindrome(s):
#     # Run loop from 0 to len/2
#     for i in range(0, int(len(s) / 2)):
#         if s[i] != s[len(s) - i - 1]:
#             print('String is not palindrome!')
#             main()
#     new_str = ''
#     for i in range(1, len(s)+1):
#         new_str += str(random.randint(1, 101))
#     if new_str is not None:
#         print(new_str)
#         exit()
#
#
# def main():
#     s = input('Enter string: ')
#     isPalindrome(s)
#
#
# if __name__ == '__main__':
#     main()

# b)

text = input('Enter details: ')
with open('EmployeeHours.txt', 'w') as f:
    f.write(text)
    f.close()

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

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS