
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Found 10476 Articles for Python

1K+ Views
In this article, we will see how a user can add tags in AWS Glue Resources.ExampleAdd tags “glue-db: tests” in AWS glue database. Problem Statement: Use boto3 library in Python to add tags in AWS Glue Resources.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: resource_arn and tags_dict are the required parameters in this function.The format of resource_arn should be as following −Catalogarn:aws:glue:region:account-id:catalogDatabasearn:aws:glue:region:account-id:database/database nameTablearn:aws:glue:region:account-id:table/database name/table nameConnectionarn:aws:glue:region:account-id:connection/connection nameCrawlerarn:aws:glue:region:account-id:crawler/crawler-nameJobarn:aws:glue:region:account-id:job/job-nameTriggerarn:aws:glue:region:account-id:trigger/trigger-nameDevelopment endpointarn:aws:glue:region:account-id:devEndpoint/development-endpoint-nameMachine learning transformarn:aws:glue:region:account-id:mlTransform/transform-idtags_dict should be as {“key”:”value”, ..}Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is ... Read More

605 Views
When it is required to create a lap timer using Python, the ‘time’ method is used. The number of laps is predefined, and a try catch block is defined, to start the lap timer.Below is a demonstration of the same −Example Live Demoimport time start_time=time.time() end_time=start_time lap_num=1 print("Click on ENTER to count laps.Press CTRL+C to stop") try: while True: input() time_laps=round((time.time() - end_time), 2) tot_time=round((time.time() - start_time), 2) print("Lap No. "+str(lap_num)) print("Total Time: "+str(tot_time)) print("Lap Time: ... Read More

400 Views
When it is required to find the difference between the current time and a given time, a method can be defined, that takes the hours, minutes, and seconds as parameter. It then calculates the difference between two given times.Below is a demonstration of the same −Example Live Demodef difference_time(h_1, m_1, h_2, m_2): t_1 = h_1 * 60 + m_1 t_2 = h_2 * 60 + m_2 if (t_1 == t_2): print("The times are the same") return else: diff = t_2-t_1 hours = (int(diff / ... Read More

465 Views
When it is required to find yesterday, today and tomorrow’s date with respect to current date, the current time is determined, and a method is used (in built) that helps find previous day and next day’s dates.Below is a demonstration of the same −Example Live Demofrom datetime import datetime, timedelta present = datetime.now() yesterday = present - timedelta(1) tomorrow = present + timedelta(1) print("Yesterday was :") print(yesterday.strftime('%d-%m-%Y')) print("Today is :") print(present.strftime('%d-%m-%Y')) print("Tomorrow would be :") print(tomorrow.strftime('%d-%m-%Y'))OutputYesterday was : 05-04-2021 Today is : 06-04-2021 Tomorrow would be : 07-04-2021ExplanationThe required packages are imported into the environment.The current date is determined ... Read More

576 Views
When it is required to print the pattern of the letter ‘G’ using ‘*’, a method can be defined, and nested loop can be used to iterate through the numbers and print ‘*” to form a ‘G’ pattern.Below is a demonstration of the same −Exampledef display_pattern(my_line): my_pattern="" for i in range(0, my_line): for j in range(0, my_line): if ((j == 1 and I != 0 and I != my_line-1) or ((I == 0 or I == my_line-1) and j > 1 and j < my_line-2) or (I == ((my_line-1)/2) and j ... Read More

386 Views
When it is required to print the fibonacci sequence using the method of recursion, a method can be declared that calls the same method again and again until a base value is reached.Below is a demonstration of the same −Example Live Demodef fibonacci_recursion(my_val): if my_val

252 Views
In this article, we will see how a user can stop a crawler present in an AWS Glue Data Catalog.ExampleProblem Statement: Use boto3 library in Python to stop a crawler.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: crawler_name is the parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create an AWS client for glue.Step 5: Now use the stop_crawler function and pass the parameter crawler_name ... Read More

524 Views
In this article, we will see how a user can stop a workflow present in an AWS account.ExampleProblem Statement: Use boto3 library in Python to stop a workflow.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: workflow_name and run_id are the required parameters in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create an AWS client for glue.Step 5: Now use the stop_workflow_run function and pass the parameter ... Read More

746 Views
In this article, we will see how a user can start a workflow in AWS Glue Data Catlog.ExampleProblem Statement: Use boto3 library in Python to start a workflow.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: workflow_name is parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create an AWS client for glue.Step 5: Now use start_workflow_run function and pass the parameter workflow_name as Name.Step 6: It returns ... Read More

387 Views
In this article, we will see how a user can stop a trigger in AWS Glue Data Catalog.ExampleProblem Statement: Use boto3 library in Python to stop a trigger.Approach/Algorithm to solve this problemStep 1: Import boto3 and botocore exceptions to handle exceptions.Step 2: trigger_name is parameter in this function.Step 3: Create an AWS session using boto3 lib. Make sure region_name is mentioned in the default profile. If it is not mentioned, then explicitly pass the region_name while creating the session.Step 4: Create an AWS client for glue.Step 5: Now use the stop_trigger function and pass the parameter trigger_name as Name.Step 6: ... Read More