Option #1: Creating a Python Application Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits,...

1 answer below »

Option #1:Creating a Python Application


Python has built-in string validation methods for basic data. It can check if a string is composed of alphabetical characters, alphanumeric characters, digits, etc.



str.isalnum()(Links to an external site.)

This method checks if all the characters of a string are alphanumeric(a-z, A-Z and 0-9). >>> print 'ab123'.isalnum() True >>> print 'ab123#'.isalnum() False
str.isalpha()(Links to an external site.)
This method checks if all the characters of a string are alphabetical(a-z and A-Z). >>> print 'abcD'.isalpha() True >>> print 'abcd1'.isalpha() False
str.isdigit()(Links to an external site.)
This method checks if all the characters of a string are digits(0-9). >>> print '1234'.isdigit() True >>> print '123edsd'.isdigit() False
str.islower()(Links to an external site.)
This method checks if all the characters of a string are lowercase characters(a-z). >>> print 'abcd123#'.islower() True >>> print 'Abcd123#'.islower() False
str.isupper()(Links to an external site.)

This method checks if all the characters of a string are uppercase characters(A-Z). >>> print 'ABCD123#'.isupper() True >>> print 'Abcd123#'.isupper() False


Assignment Instructions



  1. Write a Python program that performs the following tasks:

  2. Read from the console an arbitrary string S of length less than 50 characters.

  3. In the first output line, printTrueifShas anyalphanumeric characters. Otherwise, printFalse.

  4. In the second line, printTrueifShas anyalphabetical characters. Otherwise, printFalse.

  5. In the third line, printTrueifShas anydigits. Otherwise, printFalse.

  6. In the fourth line, printTrueifShas anylowercase characters. Otherwise, printFalse.

  7. In the fifth line, printTrueifShas anyuppercase characters. Otherwise, printFalse.

  8. Develop Python code that implements the program requirements.

Answered Same DayNov 18, 2021

Answer To: Option #1: Creating a Python Application Python has built-in string validation methods for basic...

Neha answered on Nov 18 2021
157 Votes
print("Please enter your string of less than length 50")
s = input()
if len(s) >= 50:
print("
The allowed length of input is 50.")
print("performing operation for first 50 characters")

string = s.replace(" " , "")

new = string[:50]
if any(x.isalnum() for x in new):
...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here