Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment you will practice: command-line arguments, loops, counting, and comparing values in Python. Write a program that determines if a string (passed as

In this assignment you will practice: command-line arguments, loops, counting, and comparing

values in Python.

Write a program that determines if a string (passed as a command-line argument) has all unique

characters. The program must print the number of times each existing character appears, and then

print whether or not they are all unique.

Special requirements:

You are NOT allowed to modify the input string or create any additional data structures

(no arrays, lists, dictionaries, or other strings).

You may have only one string (the one received as the command-line argument).

You may have one boolean variable and up to 3 integer variables (hint: one is the

counter).

DO NOT use any built-in String methods, such as the ones listed here:

https://www.w3schools.com/python/python_ref_string.asp

Input validation: You must print a friendly error message and end execution if the program does

not receive any arguments from the command-line.

Here are some

sample

runs:

C:\>python unique.py

Usage: python unique.py "Any string you want..."

C:\>python unique.py This is a string!

Usage: python unique.py "Any string you want..."

C:\>python unique.py "This is a string!"

T : 1

h : 1

i : 3

s : 3

: 3

i : 3

s : 3

: 3

a : 1

: 3

s : 3

t : 1

r : 1

i : 3

n : 1

g : 1

! : 1

Not unique! One or more characters appear more than once.

C:\>python unique.py "My string!"

M : 1

y : 1

: 1

s : 1

t : 1

r : 1

i : 1

n : 1

g : 1

! : 1

Unique! All characters appear only once.

WHAT TO SUBMIT:

name your program unique.py and submit on Canvas.

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

Step: 3

blur-text-image

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

Oracle Database 19c DBA By Examples Installation And Administration

Authors: Ravinder Gupta

1st Edition

B09FC7TQJ6, 979-8469226970

More Books

Students also viewed these Databases questions

Question

What is job enlargement ?

Answered: 1 week ago

Question

what is the most common cause of preterm birth in twin pregnancies?

Answered: 1 week ago

Question

Which diagnostic test is most commonly used to confirm PROM?

Answered: 1 week ago

Question

What is the hallmark clinical feature of a molar pregnancy?

Answered: 1 week ago

Question

Understanding Groups

Answered: 1 week ago