Professional Documents
Culture Documents
Basically u r telling python that you want to create function by using def
Code or logic
Reading data from different file formats like xlsx, csv, json, txt, database,
Create a function where your code will read data from different file formats
Purpose of the function is reading the data (put comments along the code)
4D
Data -
Descriptive - 100
Develop - 500
Positional arguments
Default arguments
Named arguments
def string_operations(inp_str):
upper_case_chars = 0
lower_case_chars = 0
for char in inp_str:
if char.isupper():
upper_case_chars = upper_case_chars + 1
elif char.islower():
lower_case_chars = lower_case_chars + 1
return upper_case_chars, lower_case_chars
objective of the code is to count the number of lowercase and uppercase characters
Use of for loop is to travel the whole string (inp_str) – the argument which is passed inside the
function
Now check the condition if the character is uppercase, if so then add to uppercase count
Then check the condition if the character is lowercase,if so then add to lowercase count
In summary,
Function structure:
Def function_name (argument/parameter):
Lines of code
Return