otherwise (i.e. str1 is not an alphabetic string) print a message saying that the user entered an invalid input.
3.Write a program, with comments, to do the following:
1)ans..
str1 = input("Enter string : ") #Read input
str2=str1 #assign it to str2
if(str1.isalpha()): #check if it contains only aplphabets or
not
print(str1," is valid")
if(str1[0].isupper()): #echck if first is capital or not
print(str1.upper())
elif(str1[0].islower()): #check if second char is lower case or
not
print(str1.lower())
else:
print("you entered a invalid input")
else:
print("you entered a invalid input")
print(str1.center(25,'#'))
OUTPUT:
Q2)ANS
CODE:
str1 = input("Enter string in UPPERCASE : ")
if((str1[0]>='A' and str1[0]<='H')and (str1[1]>='A' and
str1[1]<='M')):
print("belongs to group 1")
elif((str1[0]>='H' and str1[0]<='K')and (str1[1]>='I' and
str1[1]<='N')):
print("belongs to group 2")
elif((str1[0]>='K' and str1[0]<='T')and (str1[1]>='J' and
str1[1]<='Z')):
print("belongs to group 3")
else:
print("belongs to group 4")
OUTPUT:
Q3)ANS
CODE:
L1 =
['apple','ball','camera','dog','elephant','flower','go']
vowel="aeiou"
n = int(input("Enter n value : "))
if(n>=0 and n<=len(L1)-1):
x=L1[n]
print("Elements at",n," is",x)
if(x[len(x)-1] in vowel):
print(x.upper())
else:
print("Number of characters in",x ," is",len(x))
else:
print("out of range ")
OUTPUT::
If you have any doubts please COMMENT..
If you understand the answer please give THUMBS UP...
Write a program(Python language for the following three questions), with comments, to do the following: ...
Write a Python program, with comments, to do the following: Ask the user to enter a string with at least 7 characters. Assume user will enter a valid string. Assign the string to a variable str1 and print str1. In a loop do the following: Update the value of str1 so that the first character from the current value of str1 is removed and added to the end. Print the updated str1. The loop should continue until updated...
2. Searching a String: Write a MIPS assembly language program to do the following: Read a string and store it in memory. Limit the string length to 100 characters. Then, ask the user to enter a character. Search and count the number of occurrences of the character in the string. The search is not case sensitive. Lowercase and uppercase letters should be equal. Then ask the user to enter a string of two characters. Search and count the number of...
In this program, you will be using C++ programming constructs, such as overloaded functions. Write a program that requests 3 integers from the user and displays the largest one entered. Your program will then request 3 characters from the user and display the largest character entered. If the user enters a non-alphabetic character, your program will display an error message. You must fill in the body of main() to prompt the user for input, and call the overloaded function showBiggest()...
Your assignment is to write an assembly language program which read a string and print it in uppercase. This program asks the user to enter a string which is subsequently displayed in uppercase. It is important to first ensure that string to be converted is in the a-z range. The program does not recognize any space, symbols or any kind of punctuation marks. Any time the user enters any of this character the program is going to repeatedly ask for the...
Your assignment is to write an assembly language program which read a string and print it in uppercase. This program asks the user to enter a string which is subsequently displayed in uppercase. It is important to first ensure that string to be converted is in the a-z range. The program does not recognize any space, symbols or any kind of punctuation marks. Any time the user enters any of this character the program is going to repeatedly ask for...
Python program. Character-Analysis Program Problem Statement: Design a program - IN PYTHON - that asks the user to enter a string. The string will then be displayed back to the user. This is followed by determining the number of alphabetic characters, numeric characters, lower_case letters, upper_case letters, whitespace characters, and then displaying them. The user should be given additional chances to enter additional strings, and each time a string is entered, the above process is to be performed. The inputting...
Using the Arduino IDE, write a program for an Arduino board that will perform the following three tasks: 1. Input: Prompt the user to enter a character string. Read the character string from your computer through the Arduino's serial interface. 2. Processing: Convert lowercase characters to uppercase and uppercase characters to lowercase, and 3. Output: Return the processed string through the serial output and display it on your computer screen. Example: If the input character string is, “Here I am”,...
in Python: •Flip case: Write a program to do the following: •Accept the input of a sentence from the user that contains lowercase, uppercase, and special characters. •Make a new sentence in which the lowercase characters are changed to uppercase and the uppercase are changed to lower case. All other characters will retain their original value. Print the original sentence and the new sentence.
Take the following C++ code and add to it the following: Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contain a function with one of its parameters as a char variable, and if the character is a vowel, it increments that vowel's count. #include<iostream> #include<string> using namespace std; int countVowel(char, char); int main(void) { string str1; int countA = 0; int countE = 0; int countI...
Write a program that inputs a string from the user representing a password, and checks its validity. A valid password must contain: -At least 1 lowercase letter (between 'a' and 'z') and 1 uppercase letter (between 'A' and 'Z'). -At least 1 digit (between '0' and '9' and not between 0 and 9). At least 1 special character (hint: use an else to count all the characters that are not letters or digits). -A minimum length 6 characters. -No spaces...