1. Write a python program to print the following patterns.
The output is:
HHH HHH
HHH HHH HHH
HHH HHH
HHH HHH
HHH HHH
HHH HHH
HHH
2. Write a python program to display the sentence B after defining the variable A as shown in the following.
The output is:
variable A = ("brother", "Canada")
sentence B = I have a brother and he stays at Canada with his wife.
3. Write a python program to display the sentence B after defining the variable A as shown in the following.
The output is:
variable A = ("brother", 20)
sentence B = I have a brother and he is 20 years old.
4. To define the variable of name_list as in the following output. Write a python program to display the first and third name in the variable of name_list. The expected answer will be displayed in the following output too.
The output is:
name_list = ["Mark", "Nicole", "Jason", "Stephanie"]
Answer: Mark Jason
5. Write a python program to request the program user to input two personal information (name and age). Then print out those program user personal information as same as the following output.
The output is:
Please input your name: Mark
Please input your age: 20
Expected Answer: Hello, Mark. You are 20 years old now. You can access to this program!
6. Write a python program to print out the sentence with exactly same format as the following output.
The output is:
Expected Answer: Hello, everyone! I'm a beginner coder. Let's learn Python Programming Language together. Let me know if you need more exercises!
7. Write a python program to calculate the number of days between 2018-8-8 and 2018-9-3.
The output is:
Expected Answer: The number of days between 8th Aug and 3rd September 2018: 26 days
8. Write a python program to print out the names which exists in the first name list but not exist in the second set of name list as same answer in the following output.
The output is:
name_list_1= "Mark", "Nicole", "Jason", "Howard"
name_list_2= "Nicole", "Howard"
Expected Answer: The names which exists in the first name list but not exist in the second set of name
list : {'Jason', 'Mark'}
9. Write a python program to print out the names "Howard" has been removed from the first name list as same answer in the following output.
The output is:
name_list_1= "Mark", "Nicole", "Jason", "Howard"
Expected Answer: The names after removing Howard: {'Jason', 'Mark', 'Nicole'}
10. Write a python program to change the variable_a from type of integer to string type.
The output is:
variable_a = 666
Expected Answer: The type of variable_a change from integer to: class 'str'
11. Write a python program to generate the multiplication of string. The program shall allow user to input string and number of multiplications.
The output is:
string = python, number of multiplications = 3
Expected Answer:
pythonpythonpython
12. Write a python program to allow user to input their weight and height in order to calculate the BMI of user. [formula of BMI = weight (kg) / height (m)]
The output is:
Please input your weight in kg: 50
Please input your height in m: 1.56
Expected Answer:
Please input your weight in kg: 50
Please input your height in m: 1.56
Your BMI is 20.55
13. Write a python program to calculate the mathematics question of (a + b) * (a + b)
The output is:
a = 5
b = 8
Expected Answer:
(5 + 8) * (5 + 8) = 169
14. Write a python program to calculate the distance between two defined coordinates, coordinate_1 and coordinate_2 as provided in the output below.
The output is:
coordinate_1 = [5, 1]
coordinate_2 = [8, 7]
Expected Answer:
The distance between two coordinate points is 6.708203932499369
15. Write a python program to access all environment variable and a particular environment variable
The output is:
Expected Answer:
Depends on your respective environment variable
16. Write a python program to calculate the total interest amount of the car loan. The borrow amount is 30,000 for 5 years with 3% interest rate.
The output is:
Borrow amount: 30 000
Years: 5
Interest rate: 3%
Expected Answer:
The total interest amount is 4500.0
17. Write a python program to convert the seconds input by user into day, hour and minute.
The output is:
Please input the seconds: 43954
Expected Answer:
days:hours:minutes:seconds --> 0:12:12:34
18. Write a python program to request user to input 3 random numbers therefore sort the them in increasing order without using conditional statement.
The output is:
Example:
Please input the first number: 9
Plese input the second number: 2
Please input the third number: 5
Expected Answer:
The numbers in increasing order: 2 5 9
19. Write a python program to check the detail of pandas module.
The output is:
Expected Answer:
----------------------------pandas detail----------------------------
['Categorical', 'CategoricalDtype', 'CategoricalIndex', 'DataFrame', 'DateOffset', 'DatetimeIndex',
'DatetimeTZDtype', 'ExcelFile', 'ExcelWriter', 'Float64Index', 'Grouper', 'HDFStore',
'Index', 'IndexSlice', 'Int16Dtype', 'Int32Dtype', 'Int64Dtype', 'Int64Index', 'Int8Dtype',
'Interval', 'IntervalDtype', 'IntervalIndex', 'MultiIndex', 'NaT', 'Panel', 'Period',
'PeriodDtype', 'PeriodIndex', 'RangeIndex', 'Series', 'SparseArray', 'SparseDataFrame',
'SparseDtype', 'SparseSeries', 'TimeGrouper', 'Timedelta', 'TimedeltaIndex', 'Timestamp',
'UInt16Dtype', 'UInt32Dtype', 'UInt64Dtype', 'UInt64Index', 'UInt8Dtype',
'__builtins__', '__cached__', '__doc__', '__docformat__', '__file__', '__git_version__',
'__loader__', '__name__', '__package__', '__path__', '__spec__', '__version__',
'_hashtable', '_lib', '_libs', '_np_version_under1p13', '_np_version_under1p14',
'_np_version_under1p15', '_np_version_under1p16', '_np_version_under1p17', '_tslib',
'_version', 'api', 'array', 'arrays', 'bdate_range', 'compat', 'concat', 'core',
'crosstab', 'cut', 'date_range', 'datetime', 'describe_option', 'errors', 'eval',
'factorize', 'get_dummies', 'get_option', 'infer_freq', 'interval_range', 'io', 'isna',
'isnull', 'lreshape', 'melt', 'merge', 'merge_asof', 'merge_ordered', 'notna',
'notnull', 'np', 'offsets', 'option_context', 'options', 'pandas', 'period_range',
'pivot', 'pivot_table', 'plotting', 'qcut', 'read_clipboard', 'read_csv', 'read_excel',
'read_feather', 'read_fwf', 'read_gbq', 'read_hdf', 'read_html', 'read_json',
'read_msgpack', 'read_parquet', 'read_pickle', 'read_sas', 'read_sql', 'read_sql_query',
'read_sql_table', 'read_stata', 'read_table', 'reset_option', 'set_eng_float_format',
'set_option', 'show_versions', 'test', 'testing', 'timedelta_range', 'to_datetime',
'to_msgpack', 'to_numeric', 'to_pickle', 'to_timedelta', 'tseries', 'unique', 'util',
'value_counts', 'wide_to_long']
More Exercises:
Python String ExercisesMore Numpy Exercises:
Numpy String ExercisesMore Pandas Exercises:
Pandas Series ExercisesMore Tutorials:
Python Installation - Linux (Ubuntu)