Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

This is my code: string = input('input string: ') def part_one(string): print(len(string)) print(string[1]) print(string[0:10]) print(string[-5:]) lower_case = string.lower() print(lower_case) def part_two(string): upper_letter = ['A', 'B',

This is my code:

string = input('input string: ')

def part_one(string):

print(len(string))

print(string[1])

print(string[0:10])

print(string[-5:])

lower_case = string.lower()

print(lower_case)

def part_two(string):

upper_letter = ['A', 'B', 'C', 'D', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'N', 'O', 'P', 'Q', 'S', 'U', 'V', 'X', 'Z']

lower_letter = ['a', 'b', 'c', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'm', 'n','r', 's','v', 'x', 'z']

qwerty = ['Q', 'W', 'E', 'R', 'T', 'Y', 'q', 'w', 'e', 'r', 't', 'y']

uiop = ['u', 'i', 'o', 'p']

if string[0].isnumeric():

print('DIGIT')

if string[0] in qwerty:

print('QWERTY')

if string[0] in uiop:

print('UIOP')

if string[0] in upper_letter:

print('LETTER')

if string[0] in lower_letter:

print('LETTER')

else:

print('OTHER')

def input_function():

number_1 = int(input())

number_2 = int((input()))

result = number_1 * number_2

print(result)

def main(string):

part_one(string)

part_two(string)

input_function()

main(string)

I need to classify the first character of the inputted string. If it starts with Q, W, E, R, T, or Y or q, w, e, r, t, or ,y, itll print 'QWERTY'

if it starts with u, i, o , or p, itll print 'UIOP'

if it starts with any other letter itll print 'LETTER;

if it starts with a digit itll print 'DIGIT'

if it starts iwth anything else it will print other. My code keeps printing other when it isnt supposed to like when it stars with a letter or a digit or number.

I also want to be able to take in two numbers and save them into variables without being prompted. These numbers will be converted to integers and printed out.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Introduction to Wireless and Mobile Systems

Authors: Dharma P. Agrawal, Qing An Zeng

4th edition

1305087135, 978-1305087132, 9781305259621, 1305259629, 9781305537910 , 978-130508713

More Books

Students also viewed these Programming questions