Python Exercise Lists

Python Numpy String Exercises

1. Write a Python Numpy program to repeat the words: Python, Numpy and Pandas two times..

The output is:

Original Array: ['Python', 'Numpy', 'Pandas']

Expected Answer:
New array: ['PythonPython' 'NumpyNumpy' 'PandasPandas']

Click for the answer



2. Write a Python Numpy program to switch the original array to Capital letter, lowercase and uppercase.

The output is:

Original Array: ['python', 'numpy', 'pandas']

Expected Answer:
New_capitalized: ['Python' 'Numpy' 'Pandas']
New_lower_case: ['python' 'numpy' 'pandas']
New_Upper_case: ['PYTHON' 'NUMPY' 'PANDAS']

Click for the answer



3. Write a Python Numpy program to print the string in the center, left-justified and right-justified with length 5 and 10.

The output is:

Original Array: ['python', 'numpy', 'pandas']

Expected Answer:
Center_5_width = ['pytho' 'numpy' 'panda']
Left_5_width = ['pytho' 'numpy' 'panda']
Right_5_width = ['pytho' 'numpy' 'panda']

Center_10_width = ['__python__' '__numpy___' '__pandas__']
Left_10_width = ['python____' 'numpy_____' 'pandas____']
Right_10_width = ['____python' '_____numpy' '____pandas']

Click for the answer



4. Write a Python Numpy program to combine two different string a1 and a2 into one phrase.

The output is:

a1 = 'Python'
a2 = ' Exercises'

Expected Answer:
new array: ['Python Exercises']

Click for the answer



5. Write a Python Numpy program to include a space in between of initial array.

The output is:

Initial Array = ['python', 'numpy', 'pandas']

Expected Answer:
New Array: ['p y t h o n' 'n u m p y' 'p a n d a s']

Click for the answer



6. Write a Python Numpy program to remove the whitespaces of the left side, whitespace of right side and all whitespaces between the initial array.

The output is:

Initial Array = [' python ', ' numpy ', ' pandas ', ' free ', ' exercises ']

Expected Answer:
Initial Array: [' python ' ' numpy ' ' pandas ' ' free ' ' exercises ']
Remove the left side whitespaces : ['python ' 'numpy ' 'pandas ' 'free ' 'exercises ']
Remove the right side whitespaces : [' python' ' numpy' ' pandas' ' free' ' exercises']
Remove the leading and trailing whitespaces: ['python' 'numpy' 'pandas' 'free' 'exercises']

Click for the answer



7. Write a Python Numpy program to separate the initial array into their respective words.

The output is:

Initial Array: [' python numpy pandas free exercises ']

Expected Answer:
Separate the element of the intiial array with spaces: [list(['python', 'numpy', 'pandas', 'free', 'exercises'])]

Click for the answer



8. Write a Python Numpy program to replace Numpy with Pandas in the initial array.

The output is:

Initial Array = ['Python', 'Numpy', 'Free', 'Exercises']

Expected Answer:
Initial Array: ['Python' 'Numpy' 'Free' 'Exercises']

New Array: ['Python' 'Pandas' 'Free' 'Exercises']

Click for the answer



9. Write a Python Numpy program to fill in zero in left side of words with total length of 10 space including the words.

The output is:

Initial Array = ['Python', 'Numpy', 'Free', 'Exercises']

Expected Answer:
Initial Array: ['Python' 'Numpy' 'Free' 'Exercises']

String of 10 digits with zeros: ['0000Python' '00000Numpy' '000000Free' '0Exercises']

Click for the answer



10. Write a Python Numpy program to the number of alphabet "e" in the initial array.

The output is:

Initial Array = ['Python', 'Numpy', 'Free', 'Exercises']

Expected Answer:
Initial Array: ['Python' 'Numpy' 'Free' 'Exercises']

Number of 'e': [0 0 2 2]

Click for the answer



                               


More Exercises:

Python String Exercises
Python List Exercises
Python Library Exercises
Python Sets Exercises
Python Array Exercises
Python Condition Statement Exercises
Python Lambda Exercises
Python Function Exercises
Python File Input Output Exercises
Python Tkinter Exercises


More Numpy Exercises:

Numpy String Exercises
Numpy Integer Exercises
Numpy Array Exercises
Numpy Data Analysis Exercises
Numpy Data Sorting Exercises


More Pandas Exercises:

Pandas Series Exercises


More Tutorials:

Python Installation - Linux (Ubuntu)
Python Installation - Mac OS
Integrated Development Environment - IDE
Python - Basic Variables
Python - Sequence Introduction
Python - Output Formatting
Python - Escape Character
Python - Type Conversion
Python - Numbers
Python – Arithmetic Operators
Python – Assignment Operators
Python – Comparison Operators
Python – Logical Operators
Python – Precedence and Associativity Operators
Python – Bytes Type and Usage
Python – Long & Raw Strings
Python – Concatenate Function
Python – Slice Function
Python – Length and Split Function
Python – Join and Count Function
Python – Find Function
Python – Index Function
Python – Alignment Function
Python – Startswith and Endswith Function
Python – String Case Conversion
Python – Remove Specified Character
Python – Encode and Decode Function
Python – dir and help Function
Python – Input Output Introduction
Python – Basic Operation
Python – Open Function
Python – Read Function
Python – Readline Function
Python – Write Function
Python – Close Function
Python – Seek and Tell Function
Python – Pickle Module
Python - File Input Module and Linecache Module
Python - Pathlib Module
Python - Pathlib Module
Python - os.path Module
Python - fnmatch Module
Python - Tuple Introduction
Python - List Introduction
Python - List Add Element
Python - List Delete Element
Python - List Modification Element
Python - List Find Element
Python - Dictionary Introduction
Python - Dictionary Basic Operation
Python - Dictionary Method Guide
Python - Set Collection
Python - Set Basic Operation
Python - Set Basic Method
Python - Frozenset Method
Python - If Condition I
Python - If Condition II
Python - While loop
Python - For loop
Python - Pass Statement
Python - Break Statement
Python - Zip Reverse Function
Python - Function Introduction
Python - Positional Parameters
Python - Key Arguments
Python - None and Return
Python - Variable Scope
Python - Local Function
Python - Closure Method
Python - Lamdba Expression