├── .github ├── ISSUE_TEMPLATE │ └── feature_request.md └── workflows │ ├── codacy-analysis.yml │ ├── codeql-analysis.yml │ └── crunch42-analysis.yml ├── .gitignore ├── .python.py.swp ├── AI ML ├── Cab fare prediction dataset │ ├── TEST.csv │ ├── TRAIN.csv │ ├── empty files.csv │ ├── output.csv │ ├── output_wo_src_dest.csv │ ├── output_wo_src_dest_linReg.csv │ ├── predis_rf.csv │ ├── res.csv │ ├── results.csv │ └── sample_submission.csv ├── Candidate_Elimination_Problem │ ├── Candidate Elimination Problem.ipynb │ └── dataset-1.csv ├── Linear Regression Model │ ├── Linearregression.ipynb │ ├── Readme.md │ ├── Screenshot 2022-10-07 153212.png │ ├── Screenshot 2022-10-07 153430.png │ ├── Week2_LR.ipynb │ ├── Week2_Regression.ipynb │ └── homeprices.csv ├── Random_Forest_Regressor.py ├── Resnet.py ├── SLR │ ├── ReadMe.md │ ├── Simple Linear Regression.ipynb │ └── ml_data_salary.csv ├── SMS_Project.py ├── Test.txt ├── U-net.ipynb ├── Virtual_Painter │ ├── Hand_Tracking_Module.py │ ├── README.md │ ├── Virtual_Painter.py │ └── src │ │ ├── app │ │ ├── __init__.py │ │ ├── admin.py │ │ ├── apps.py │ │ ├── camera.py │ │ ├── migrations │ │ │ └── __init__.py │ │ ├── models.py │ │ ├── tests.py │ │ ├── urls.py │ │ └── views.py │ │ ├── manage.py │ │ ├── src │ │ ├── __init__.py │ │ ├── __pycache__ │ │ │ ├── __init__.cpython-39.pyc │ │ │ └── settings.cpython-39.pyc │ │ ├── asgi.py │ │ ├── settings.py │ │ ├── urls.py │ │ └── wsgi.py │ │ └── templates │ │ └── index.html ├── blink-detector │ ├── blink.py │ └── eye_blink.py └── vieh_project.py ├── Advanced python programs ├── Extract IP address from file using Python.py ├── LR.py ├── Median_in_a_data_stream.py ├── Red-Black Tree.py ├── checkpass.py ├── count_set_bits_positive_integer.py ├── hangman.py ├── menace.py ├── morse_code.py ├── split_data_sort_from_the_file │ ├── split_and_store_in_list.py │ └── test.txt ├── sudoku_solver.py └── wifi-password-extractor.py ├── Arrays and Matrix ├── ArrayOperations.py ├── BinarySearch.py ├── DFS.py ├── Introsort.py ├── Leetcode-question-Set-Matrix-Zeroes.py ├── Leetcode-question-Sum-of-Even-Numbers-After-Queries.py ├── Matrix_Multiplication.Py ├── MergeSort.py ├── OddEvenSort.py ├── QuickSort │ └── quicksort.py ├── Radix-Sort.py ├── SelectionSort.py ├── add_subtract_matrices.py ├── column_zig_zag_swap.py ├── dynamic_sort.py ├── encode_decode.py ├── fibonacci.py ├── hashing.py ├── insertion_sort.py ├── int_array_rotator.py ├── matrix_inverse.py ├── matrix_rotation.py ├── maximum_sum_subarray.py ├── rotate_matrix.py ├── shell_sort.py └── sortArrays.py ├── Automate-Google-Form-Filling └── fill_google_form.py ├── COA Algorithms ├── Binary Multiplication.py ├── Booth Multiplication.py ├── IEEE 754 Additon.py ├── Non Restoring Division.py ├── README.md ├── Restoring Division.py └── Utils.py ├── CODE_OF_CONDUCT.md ├── CONTRIBUTING.md ├── Calculator Using html,css and js ├── index.html ├── script.js └── style.css ├── Digital clock ├── Discord_TextScraper.py ├── Face Reaction └── app.py ├── Guess_the_number.py ├── Jarvis_Virtual_Assistant.py ├── Mad-libs with.py ├── Madhya Pradesh Tourism Website ├── assests │ ├── 1.jpg │ ├── 2.jpg │ ├── 3.jpg │ ├── 4.jpg │ ├── 5.jpg │ ├── audio │ │ ├── A_Documentary_on_Ujjain_(getmp3.pro).mp3 │ │ ├── India_Marvels_Mysteries__(getmp3.pro).mp3 │ │ ├── Indian_bison_gaur_of_Kanha_nation_(getmp3.pro).mp3 │ │ └── New_Development_in_Omkareshwar_-_A_(getmp3.pro).mp3 │ ├── feature-image-v1-1.jpg │ ├── mike-tinnion-BA7da404ekg-unsplash.jpg │ ├── shutterstock_1430024867.jpg │ └── yash-parashar-3J6Jy2defyw-unsplash.jpg ├── bookings.html ├── bstyle.css ├── index.html └── style.css ├── PYTHON GUI ├── 2048.py ├── 2Dgraphs.py ├── Alien Spaceship Game │ ├── .gitignore │ ├── README.md │ ├── alien.py │ ├── alien_invasion.py │ ├── alien_invasion_demo.gif │ ├── bullet.py │ ├── button.py │ ├── game_functions.py │ ├── game_stats.py │ ├── images │ │ ├── alien.bmp │ │ └── ship.bmp │ ├── scoreboard.py │ ├── settings.py │ └── ship.py ├── Automatic Birthday Wisher Using Python │ ├── data.xlsx │ └── main.py ├── Digital_clock.py ├── GUI Calendar │ ├── README.md │ └── gui-calendar.py ├── GUI_For_Database.py ├── Guess the Number │ └── Guess_The_Number.py ├── Hand Cricket │ └── Hand_Cricket_Game.py ├── Heart_in_python_using_turtle.py ├── NumberGuessingGame.py ├── PigLatin in Python ├── Snake_game_using_pygame.py ├── Stone Paper Scissor │ └── Stone_Paper_Scissor_Game.py ├── Tic-Tac-Toe-Game-In-Python-srishti │ ├── Gui.PNG │ ├── README.md │ ├── Tic_Tac_Toe_Game.py │ ├── Winning_message.PNG │ └── draw_messge.PNG ├── Torrent_Finder.py ├── TowerofHanoi.py ├── alarm_Clock.py ├── calculator.py ├── eggCatcher.py ├── game.py ├── hamming.py ├── hangman.py ├── national_flag_turtle.py ├── pomodoro.py ├── progress_bar.py ├── snakeWaterGun.py ├── to-do-list.py └── typing-speed-test.py ├── Paint GUI and Digit Recognizer ├── GUI.py ├── img │ ├── abc │ ├── img_0.png │ └── img_0.pngimg_0.png └── mnist.h5 ├── Python Basic Programs ├── 8ball.py ├── Aerial-distance-calculator.py ├── Age_Calculator.py ├── Alarm_Clock.py ├── ArmstrongNumber.py ├── BMI_Calculator.py ├── DiceRollingSimulator.py ├── Fibonacci.py ├── FizzBuzz.py ├── Group Anagrams.py ├── Guessing Game Challenge.py ├── Hangman.py ├── High_outliers_and_Low_outliers.py ├── Information_Fusion ├── Lapindromes.py ├── Longest-Palindromic-Substring.py ├── Password Checker.py ├── Quadratic Equation Solver.py ├── Rock Paper Scissors.py ├── Shell_sort.py ├── Steganography.py ├── Student_Management_System.py ├── Tic Tac Toe.py ├── Turtle_animations │ ├── hexagon.py │ ├── indianFlag.py │ ├── star.py │ ├── trihexagonal.py │ └── viruspattern.py ├── ValidSudoku.py ├── acid_solution.py ├── avengers.py ├── calander.py ├── calculator.py ├── celsiusToFahrenheit.py ├── count_prime_in_defined_interval.py ├── counting_sort.py ├── diagonaldifference.py ├── diamond pattern.py ├── dicestimulator.py ├── email_pass_generation.py ├── factorial.py ├── fibo.py ├── fibonacci.py ├── hcf.py ├── heap-sort.py ├── heapSort.py ├── heart.py ├── insertionsort.py ├── internetspeedtest.py ├── longest_common_substring.py ├── mean_median_mode.py ├── odd_no_square.py ├── palindrome.py ├── palindrome_string.py ├── palindromicnumber.py ├── patterns.py ├── prime_nums.py ├── print_the-elements_of_an_array_in_reverse_order.py ├── py.py ├── pythagoras.py ├── quicksort.py ├── range_and_interquartile_range.py ├── screen_Pet_Game.py ├── snake-water-gun.py ├── standard_deviation_variance.py ├── string punctuation in Python.py ├── student-registration-program.py ├── temperature_converter.py ├── toss.py ├── tower_of_hanoi.py ├── url_find.py ├── whstappbot.py └── wireless_sound_control.py ├── Python Turtle Projects ├── Figure Designs │ ├── Among_Us.py │ ├── Avengers_logo.py │ ├── Batman.py │ ├── Captain_America_Shield.py │ ├── Doraemon.py │ ├── Ironman_Helmet.py │ ├── Panda.py │ ├── Pikachu.py │ ├── Robert_Downey_Jr.py │ ├── Shinchan.py │ ├── Tom_Holland.py │ └── Yash.py ├── Games Design │ ├── Pong_Game.py │ ├── Snake_Game.py │ └── Two_Player_Game.py └── Pattern Designs │ ├── Animation_Circle.py │ ├── Attractive_Circle.py │ ├── Circle_Mania.py │ ├── Circle_Ring.py │ ├── Fractal_Art.py │ ├── Graphics_Pattern.py │ ├── Random_Flower_Design.py │ ├── Spiral_Draw.py │ ├── Spiral_Web.py │ └── Square_Spirograph.py ├── Python Turtle ProjectsBeautifulColoredPattern.py ├── README.md ├── RockcpaperScissor └── Rock,Paper and Scissors.ipynb ├── SECURITY.md ├── Text to Handwritten ├── pywhatkit.png ├── requirements.txt └── text-to-handwritten.py ├── US-forieghn-AID ├── US_foriegn_AID.ipynb └── us_foreign_aid_country.csv ├── Virtual-Painter ├── tools.png └── virtual_paint_app.py ├── Web and Automation and Networking ├── Financial Service main.xlsx ├── Password_Strength_Checker.py ├── Python-Web-Crawler │ ├── README.md │ ├── demo.py │ ├── domain.py │ ├── link_finder.py │ ├── main.py │ └── spider.py ├── Scrapper.py ├── Web_blocker.py ├── comic extracter.py ├── data.xlsx ├── emailSender.py ├── file.xlsx ├── generate_jwt │ └── generate_jwt.py ├── house_pred_deployment.py ├── main.py ├── scrapping_timesjobs_website.py ├── socket_ip_hostname.py ├── todolist │ ├── README.md │ ├── TodoList │ │ ├── .idea │ │ │ ├── .gitignore │ │ │ ├── TodoList.iml │ │ │ ├── encodings.xml │ │ │ ├── inspectionProfiles │ │ │ │ └── profiles_settings.xml │ │ │ ├── misc.xml │ │ │ └── modules.xml │ │ ├── TodoList │ │ │ ├── __init__.py │ │ │ ├── asgi.py │ │ │ ├── settings.py │ │ │ ├── urls.py │ │ │ └── wsgi.py │ │ ├── manage.py │ │ ├── pass.txt │ │ └── tasks │ │ │ ├── __init__.py │ │ │ ├── admin.py │ │ │ ├── apps.py │ │ │ ├── forms.py │ │ │ ├── migrations │ │ │ ├── 0001_initial.py │ │ │ └── __init__.py │ │ │ ├── models.py │ │ │ ├── templates │ │ │ └── tasks │ │ │ │ ├── delete.html │ │ │ │ ├── list.html │ │ │ │ └── update_task.html │ │ │ ├── tests.py │ │ │ ├── urls.py │ │ │ └── views.py │ ├── preview.jpg │ └── requirements.txt ├── twitter url extracter.py ├── webscraping.py ├── whatsapp-scheduler.py └── youtube_downloader │ └── youtube_downloader.py ├── anagrams.py ├── cypher.py ├── data_structures ├── Boruvkas_algorithm.py ├── Double_linked_list.py ├── PairingHeaps.py ├── __init__.py ├── binary_tree │ ├── __init__.py │ ├── avl tree.py │ ├── avl_tree.py │ ├── basic_binary_tree.py │ ├── binary_search_tree.py │ ├── binary_search_tree_recursive.py │ ├── binary_tree_mirror.py │ ├── binary_tree_traversals.md │ ├── binary_tree_traversals.py │ ├── diameter_of_binary_tree.py.py │ ├── fenwick_tree.py │ ├── lazy_segment_tree.py │ ├── lowest_common_ancestor.py │ ├── maximum_fenwick_tree.py │ ├── merge_two_binary_trees.py │ ├── non_recursive_segment_tree.py │ ├── number_of_possible_binary_trees.py │ ├── red_black_tree.py │ ├── segment_tree.py │ ├── segment_tree_other.py │ ├── treap.py │ └── wavelet_tree.py ├── bubblesort.py ├── dfs_Python │ └── dfs.py ├── diamond_asterisk.py ├── linked_list │ ├── __init__.py │ ├── circular_linked_list.py │ ├── deque_doubly.py │ ├── doubly_linked_list.py │ ├── doubly_linked_list_two.py │ ├── from_sequence.py │ ├── has_loop.py │ ├── is_palindrome.py │ ├── linkedlist.py │ ├── merge_two_lists.py │ ├── middle_element_of_linked_list.py │ ├── print_reverse.py │ ├── singly_linked_list.py │ ├── skip_list.py │ └── swap_nodes.py ├── menu-driven-binary-operations.py ├── printAGivenDoublyLinkedListInReverseOrder.py ├── queue │ ├── __init__.py │ ├── circular_queue.py │ ├── circular_queue_linked_list.py │ ├── double_ended_queue.py │ ├── linked_queue.py │ ├── myCircularQueue.py │ ├── priority_queue_using_list.py │ ├── queue_on_list.py │ └── queue_on_pseudo_stack.py └── stacks │ ├── __init__.py │ ├── balanced_parentheses.py │ ├── dijkstras_two_stack_algorithm.py │ ├── evaluate_postfix_notations.py │ ├── infix_to_postfix_conversion.py │ ├── infix_to_prefix_conversion.py │ ├── next_greater_element.py │ ├── postfix_evaluation.py │ ├── prefix_evaluation.py │ ├── stack.py │ ├── stack_with_doubly_linked_list.py │ ├── stack_with_singly_linked_list.py │ └── stock_span_problem.py ├── drinking ├── drink.py └── icon.ico ├── dynamic_sort.py ├── gps ├── coordinates.py ├── display.html ├── findonmap.py ├── gps.py ├── gps_data.txt └── visual_track │ ├── requirements.txt │ ├── route.html │ ├── track1.txt │ └── track_visu.py ├── merge_sort.py ├── pattern.py ├── pol reg.py ├── python zip file brute forcer ├── railway_assistance.py ├── requirements.txt ├── resize.py ├── rock_paper_scissor.py ├── rotation.py ├── snake game ├── snake.py ├── translation.py └── translator.py /.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: Feature 5 | labels: featurerequest 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /.python.py.swp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/.python.py.swp -------------------------------------------------------------------------------- /AI ML/Cab fare prediction dataset/sample_submission.csv: -------------------------------------------------------------------------------- 1 | index,fare 2 | 0,11.0 3 | 1,26.0 4 | 2,18.5 5 | 3,11.5 6 | 4,9.0 7 | 5,10.5 8 | 6,7.0 9 | 7,7.0 10 | 8,26.0 11 | 9,5.0 12 | 10,32.5 13 | 11,19.5 14 | -------------------------------------------------------------------------------- /AI ML/Candidate_Elimination_Problem/dataset-1.csv: -------------------------------------------------------------------------------- 1 | Sky,AirTemp,Humidity,Wind,Water,Forecast,EnjoySport 2 | Sunny,Warm,Normal,Strong,Warm,Same,Yes 3 | Sunny,Warm,High,Strong,Warm,Same,Yes 4 | Rainy,Cold,High,Strong,Warm,Change,No 5 | Sunny,Warm,High,Strong,Cool,Change,Yes 6 | -------------------------------------------------------------------------------- /AI ML/Linear Regression Model/Readme.md: -------------------------------------------------------------------------------- 1 | ![Screenshot 2022-10-07 153430](https://user-images.githubusercontent.com/76916192/195048037-5814509a-aa14-41a1-b808-e706e6fd8d6e.png) 2 | -------------------------------------------------------------------------------- /AI ML/Linear Regression Model/Screenshot 2022-10-07 153212.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/AI ML/Linear Regression Model/Screenshot 2022-10-07 153212.png -------------------------------------------------------------------------------- /AI ML/Linear Regression Model/Screenshot 2022-10-07 153430.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/AI ML/Linear Regression Model/Screenshot 2022-10-07 153430.png -------------------------------------------------------------------------------- /AI ML/Linear Regression Model/homeprices.csv: -------------------------------------------------------------------------------- 1 | area,price 2 | 2600,550000 3 | 3000,565000 4 | 3200,610000 5 | 3600,680000 6 | 4000,725000 7 | -------------------------------------------------------------------------------- /AI ML/Random_Forest_Regressor.py: -------------------------------------------------------------------------------- 1 | # Random Forest Regressor Example 2 | from sklearn.datasets import load_boston 3 | from sklearn.ensemble import RandomForestRegressor 4 | from sklearn.metrics import mean_absolute_error, mean_squared_error 5 | from sklearn.model_selection import train_test_split 6 | 7 | 8 | def main(): 9 | 10 | """ 11 | Random Forest Regressor Example using sklearn function. 12 | Boston house price dataset is used to demonstrate the algorithm. 13 | """ 14 | 15 | # Load Boston house price dataset 16 | boston = load_boston() 17 | print(boston.keys()) 18 | 19 | # Split dataset into train and test data 20 | x = boston["data"] # features 21 | y = boston["target"] 22 | x_train, x_test, y_train, y_test = train_test_split( 23 | x, y, test_size=0.3, random_state=1 24 | ) 25 | 26 | # Random Forest Regressor 27 | rand_for = RandomForestRegressor(random_state=42, n_estimators=300) 28 | rand_for.fit(x_train, y_train) 29 | 30 | # Predict target for test data 31 | predictions = rand_for.predict(x_test) 32 | predictions = predictions.reshape(len(predictions), 1) 33 | 34 | # Error printing 35 | print(f"Mean Absolute Error:\t {mean_absolute_error(y_test, predictions)}") 36 | print(f"Mean Square Error :\t {mean_squared_error(y_test, predictions)}") 37 | 38 | 39 | if __name__ == "__main__": 40 | main() -------------------------------------------------------------------------------- /AI ML/SLR/ReadMe.md: -------------------------------------------------------------------------------- 1 | ## Simple Linear Regression 2 | -------------------------------------------------------------------------------- /AI ML/SLR/ml_data_salary.csv: -------------------------------------------------------------------------------- 1 | age,distance,YearsExperience,Salary 2 | 31.1,77.75,1.1,39343 3 | 31.3,78.25,1.3,46205 4 | 31.5,78.75,1.5,37731 5 | 32,80,2,43525 6 | 32.2,80.5,2.2,39891 7 | 32.9,82.25,2.9,56642 8 | 33,82.5,3,60150 9 | 33.2,83,3.2,54445 10 | 33.2,83,3.2,64445 11 | 33.7,84.25,3.7,57189 12 | 33.9,84.75,3.9,63218 13 | 34,85,4,55794 14 | 34,85,4,56957 15 | 34.1,85.25,4.1,57081 16 | 34.5,86.25,4.5,61111 17 | 34.9,87.25,4.9,67938 18 | 35.1,87.75,5.1,66029 19 | 35.3,88.25,5.3,83088 20 | 35.9,89.75,5.9,81363 21 | 36,90,6,93940 22 | 36.8,92,6.8,91738 23 | 37.1,92.75,7.1,98273 24 | 37.9,94.75,7.9,101302 25 | 38.2,95.5,8.2,113812 26 | 38.7,96.75,8.7,109431 27 | 39,97.5,9,105582 28 | 39.5,98.75,9.5,116969 29 | 39.6,99,9.6,112635 30 | 40.3,100.75,10.3,122391 31 | 40.5,101.25,10.5,121872 32 | -------------------------------------------------------------------------------- /AI ML/Test.txt: -------------------------------------------------------------------------------- 1 | 000.0000.00.00 2 | 192.168.1.1 3 | 912.456.123.123 4 | 192.168.4.164 5 | 69.168.4.226 6 | 32.89.31.164 7 | 67.168.3.227 8 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/README.md: -------------------------------------------------------------------------------- 1 | # Virtual_Painter 2 | 3 | It is an OPEN_CV2 project build with the help of concepts of OPEN_CV2. 4 | Framework used-MediaPipe. 5 | 6 | With this project one can draw on screen with the help of their hands. 7 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/AI ML/Virtual_Painter/src/app/__init__.py -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class AppConfig(AppConfig): 5 | default_auto_field = 'django.db.models.BigAutoField' 6 | name = 'app' 7 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/camera.py: -------------------------------------------------------------------------------- 1 | import cv2 2 | 3 | class VideoCamera(object): 4 | def __init__(self): 5 | self.video=cv2.VideoCapture(0) 6 | 7 | def __del__(self): 8 | self.video.release() 9 | 10 | def get_frame(self): 11 | success,image=self.video.read() 12 | ret,jpeg=cv2.imencode('.jpg',image) 13 | return jpeg.tobytes() -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/AI ML/Virtual_Painter/src/app/migrations/__init__.py -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from camera import views 3 | urlpatterns=[ 4 | path('',views.index,name="index"), 5 | path('video_feed',views.video_feed,name='video_feed'), 6 | ] -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/app/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render 2 | from django.http import StreamingHttpResponse 3 | from .camera import VideoCamera 4 | # Create your views here. 5 | def index(request): 6 | return render(request,'index.html') 7 | 8 | def gen(camera): 9 | while True: 10 | frame=camera.get_frame() 11 | yield(b'--frame\r\n' 12 | b'Content-Type: image/jpeg\r\n\r\n' + frame + b'\r\n\r\n') 13 | 14 | 15 | def video_feed(request): 16 | return StreamingHttpResponse(gen(VideoCamera()),content_type='multipart/x-mixed-replace; boundary=frame') 17 | 18 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | """Run administrative tasks.""" 9 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') 10 | try: 11 | from django.core.management import execute_from_command_line 12 | except ImportError as exc: 13 | raise ImportError( 14 | "Couldn't import Django. Are you sure it's installed and " 15 | "available on your PYTHONPATH environment variable? Did you " 16 | "forget to activate a virtual environment?" 17 | ) from exc 18 | execute_from_command_line(sys.argv) 19 | 20 | 21 | if __name__ == '__main__': 22 | main() 23 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/src/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/AI ML/Virtual_Painter/src/src/__init__.py -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/src/__pycache__/__init__.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/AI ML/Virtual_Painter/src/src/__pycache__/__init__.cpython-39.pyc -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/src/__pycache__/settings.cpython-39.pyc: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/AI ML/Virtual_Painter/src/src/__pycache__/settings.cpython-39.pyc -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/src/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for src project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/src/urls.py: -------------------------------------------------------------------------------- 1 | """src URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/4.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path,include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('',include('app.urls')), 22 | ] 23 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/src/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for src project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/4.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'src.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /AI ML/Virtual_Painter/src/templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | OpenCV-Django 9 | 10 | 11 | 12 | 37 |

Live Streaming with Webcam using OpenCV and Django

38 |
39 | 40 |
41 | 42 | 43 | -------------------------------------------------------------------------------- /Advanced python programs/Extract IP address from file using Python.py: -------------------------------------------------------------------------------- 1 | 2 | # importing the module 3 | import re 4 | 5 | # opening and reading the file 6 | with open('C:/Users/user/Desktop/New Text Document.txt') as fh: 7 | fstring = fh.readlines() 8 | 9 | # declaring the regex pattern for IP addresses 10 | pattern = re.compile(r'(\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3})') 11 | 12 | # initializing the list object 13 | lst=[] 14 | 15 | # extracting the IP addresses 16 | for line in fstring: 17 | lst.append(pattern.search(line)[0]) 18 | 19 | # displaying the extracted IP addresses 20 | print(lst) 21 | -------------------------------------------------------------------------------- /Advanced python programs/LR.py: -------------------------------------------------------------------------------- 1 | def checkLowercase(inStr): 2 | charLCState = [] 3 | for charVal in inStr: 4 | charLCState.append(charVal.islower()) 5 | return charLCState.count(True) == len(inStr) 6 | 7 | inGrammer = input('Enter Grammer :: ') 8 | cfgSplit = inGrammer.replace(' ', '').split('->') 9 | cfgProds = cfgSplit[1].split('|') 10 | newSymbol, lrList, terminalStates, nonTerminalStates = f'{cfgSplit[0]}\'', [], [], [] 11 | if len(cfgProds) >= 2: 12 | for i in cfgProds: 13 | if len(i) != 1: 14 | if i.startswith(cfgSplit[0]): 15 | nonTerminalStates.append(f'{i}') 16 | else: 17 | if checkLowercase(i): 18 | terminalStates.append(f'{i}{newSymbol}') 19 | lrList.append(i.startswith(cfgSplit[0])) 20 | else: 21 | terminalStates.append(f'{i}{newSymbol}') 22 | else: 23 | lrList.append(False) 24 | 25 | if True in lrList: 26 | newSymbolProductions = [] 27 | for i in nonTerminalStates: 28 | newSymbolProductions.append(f'{i[1:]}{newSymbol}') 29 | newSymbolProductions.append('ε') 30 | print(f'\nAfter eliminating left recursion:') 31 | print(f'{cfgSplit[0]} -> {" | ".join(terminalStates)}') 32 | print(f'{newSymbol} -> {" | ".join(newSymbolProductions)}') 33 | else: 34 | print(f'\n{inGrammer} Is Not Left Recursive.') 35 | -------------------------------------------------------------------------------- /Advanced python programs/Median_in_a_data_stream.py: -------------------------------------------------------------------------------- 1 | # Python code for finding the median in a running data stream 2 | 3 | import math 4 | from heapq import heappush, heappop, heapify 5 | 6 | #Function that finds the median of the data stream 7 | def median(arr, N): 8 | 9 | # Declaring two min heaps 10 | h1 = [] 11 | h2 = [] 12 | for i in range(len(arr)): 13 | 14 | # Negation for treating it as max heap 15 | heappush(h2, -arr[i]) 16 | heappush(h1, -heappop(h2)) 17 | if len(h1) > len(h2): 18 | heappush(h2, -heappop(h1)) 19 | 20 | if len(h1) != len(h2): 21 | print(-h2[0]) 22 | else: 23 | print((h1[0] - h2[0])/2) 24 | 25 | 26 | # Driver code 27 | if __name__ == '__main__': 28 | arr = list(map(int, input().split())) 29 | n=len(arr); 30 | 31 | # Function call 32 | median(arr, n) 33 | -------------------------------------------------------------------------------- /Advanced python programs/checkpass.py: -------------------------------------------------------------------------------- 1 | 2 | 3 | import requests 4 | import hashlib 5 | import sys 6 | def request_api_data(query_char): 7 | url="https://api.pwnedpasswords.com/range/" + query_char 8 | res=requests.get(url) 9 | if res.status_code !=200: 10 | raise RuntimeError(f'Error fetching: {res.status_code}, check the api and try again') 11 | return res 12 | def get_password_leaks_count(hashes, hash_to_check): 13 | hashes=(line.split(':') for line in hashes.text.splitlines()) 14 | for h, count in hashes: 15 | if h==hash_to_check: 16 | return count 17 | return 0 18 | def pwned_api_check(password): 19 | sha1password=hashlib.sha1(password.encode('utf-8')).hexdigest().upper() 20 | first5_char, tail=sha1password[:5],sha1password[5:] 21 | response=request_api_data(first5_char) 22 | return get_password_leaks_count(response,tail) 23 | #Check password if it exists in API response 24 | def main(args): 25 | for password in args: 26 | count=pwned_api_check(password) 27 | if count: 28 | print(f'{password} was found {count} times... You should probably change your password') 29 | else: 30 | print(f'{password} was NOT found. Carry on!') 31 | return 'done!' 32 | if __name__=='__main__': 33 | main(sys.argv[1:]) 34 | 35 | 36 | 37 | 38 | 39 | -------------------------------------------------------------------------------- /Advanced python programs/count_set_bits_positive_integer.py: -------------------------------------------------------------------------------- 1 | def countSetBitsInPositiveInteger(num: int) -> int: 2 | counter = 0 3 | mask = 1 4 | shift = 1 5 | while (num): 6 | counter += num & mask 7 | num >>= shift 8 | return counter 9 | -------------------------------------------------------------------------------- /Advanced python programs/split_data_sort_from_the_file/split_and_store_in_list.py: -------------------------------------------------------------------------------- 1 | fname = input("Enter file name: ") 2 | fh = open(fname) 3 | lst = list() 4 | for line in fh: 5 | line=line.rstrip() 6 | for i in line.split(): 7 | if i not in lst: 8 | lst.append(i) 9 | lst.sort() 10 | print(lst) 11 | -------------------------------------------------------------------------------- /Advanced python programs/split_data_sort_from_the_file/test.txt: -------------------------------------------------------------------------------- 1 | But soft what light through yonder window breaks 2 | It is the east and Juliet is the sun 3 | Arise fair sun and kill the envious moon 4 | Who is already sick and pale with grief -------------------------------------------------------------------------------- /Advanced python programs/wifi-password-extractor.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | 3 | data = subprocess.check_output(['netsh', 'wlan', 'show', 'profiles']).decode('utf-8').split('\n') 4 | profiles = [i.split(":")[1][1:-1] for i in data if "All User Profile" in i] 5 | for i in profiles: 6 | results = subprocess.check_output(['netsh', 'wlan', 'show', 'profile', i, 'key=clear']).decode('utf-8').split('\n') 7 | results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b] 8 | try: 9 | print ("{:<30}| {:<}".format(i, results[0])) 10 | except IndexError: 11 | print ("{:<30}| {:<}".format(i, "")) 12 | except: 13 | print("Password Not Found") 14 | input("") -------------------------------------------------------------------------------- /Arrays and Matrix/ArrayOperations.py: -------------------------------------------------------------------------------- 1 | print("String Array Operations in Python") 2 | 3 | array = [] 4 | choice=0; 5 | n = int(input("Enter the number of elements string array : ")) 6 | for i in range(n): 7 | array.append(input()) 8 | while(choice!=6): 9 | print("The current array is",array) 10 | 11 | print("Choose the operation you want to perform on the string array") 12 | choice = int(input("1.Append 2.Count 3.Index 4.Insert 5.Print 6.Quit")) 13 | 14 | if(choice==1): 15 | try: 16 | array.append(input("Enter the string to append")) 17 | except: 18 | print("Could not perform the operation") 19 | if(choice==2): 20 | temp=input("Enter the element to count") 21 | try: 22 | print("The count is:",array.count(temp)) 23 | except: 24 | print("The element is not in the array") 25 | if(choice==3): 26 | temp=input("Enter the element to find index the array") 27 | try: 28 | print("Array index is:",array.index(temp)) 29 | except: 30 | print("The element is not in the array") 31 | if(choice==4): 32 | try: 33 | array.insert(int(input("Enter the index value: ")),input("Enter the element to insert")) 34 | except: 35 | print("Could not perform operation with the above input") 36 | if(choice==5): 37 | print("The current array is",array) 38 | 39 | -------------------------------------------------------------------------------- /Arrays and Matrix/BinarySearch.py: -------------------------------------------------------------------------------- 1 | def binary_search(arr, x): 2 | l = 0 3 | r = len(arr) - 1 4 | mid = 0 5 | 6 | while l <= r: 7 | mid = (r + l) 8 | if arr[mid] < x: 9 | l = mid + 1 10 | elif arr[mid] > x: 11 | r = mid - 1 12 | else: 13 | return mid 14 | return -1 15 | 16 | arr = [] 17 | n = int(input("Enter the number of elements in array : ")) 18 | print("Enter the elements") 19 | for i in range(n): 20 | arr.append(int(input())) 21 | 22 | x = int(input("Enter the element to search in the array : ")) 23 | 24 | 25 | res = binary_search(arr, x) 26 | 27 | if res != -1: 28 | print("Element is at index", str(res)) 29 | else: 30 | print("Element is not there in array") 31 | -------------------------------------------------------------------------------- /Arrays and Matrix/DFS.py: -------------------------------------------------------------------------------- 1 | # Using a Python dictionary to act as an adjacency list 2 | graph = { 3 | '5' : ['3','7'], 4 | '3' : ['2', '4'], 5 | '7' : ['8'], 6 | '2' : [], 7 | '4' : ['8'], 8 | '8' : [] 9 | } 10 | 11 | visited = set() # Set to keep track of visited nodes of graph. 12 | 13 | def dfs(visited, graph, node): #function for dfs 14 | if node not in visited: 15 | print (node) 16 | visited.add(node) 17 | for neighbour in graph[node]: 18 | dfs(visited, graph, neighbour) 19 | 20 | # Driver Code 21 | print("Following is the Depth-First Search") 22 | dfs(visited, graph, '5') 23 | -------------------------------------------------------------------------------- /Arrays and Matrix/Leetcode-question-Set-Matrix-Zeroes.py: -------------------------------------------------------------------------------- 1 | def setZeroes(self, matrix: List[List[int]]) -> None: 2 | """ 3 | Do not return anything, modify matrix in-place instead. 4 | """ 5 | row=[] #need to store the indeces of rows which will be equal to 0 6 | col=[] #need to store the indeces of columns which will be equal to 0 7 | for i in range(len(matrix)): 8 | for j in range(len(matrix[0])): 9 | if matrix[i][j]==0: 10 | row.append(i) #storing the indeces of rows 11 | col.append(j) #storing the indeces of columns 12 | 13 | #need to skip the duplicates to restict the TLE 14 | row=set(row) 15 | col=set(col) 16 | for i in range(len(matrix)): #for rows indeces 17 | if i in row: 18 | matrix[i]=[0]*len(matrix[0]) #update the whole row to 0 (total columns in particular row = len(matrix[0])) 19 | for j in range(len(matrix[0])): #for columns indeces 20 | if j in col: 21 | matrix[i][j]=0 #updating the whole column to 0 one by one 22 | 23 | -------------------------------------------------------------------------------- /Arrays and Matrix/Leetcode-question-Sum-of-Even-Numbers-After-Queries.py: -------------------------------------------------------------------------------- 1 | def sumEvenAfterQueries(self, nums: List[int], queries: List[List[int]]) -> List[int]: 2 | s=0 3 | #firstly calculating all the even numbers sum if the nums 4 | for j in nums: 5 | if j%2==0: 6 | s+=j 7 | 8 | r=[] 9 | for i in range(len(queries)): 10 | 11 | #if the previous value at the position of queries[i][1] in nums is even then remove it from s 12 | #coz when queries[i][1] position in nums will get updated with addition of queries[i][0] 13 | #to the nums[queries[i][1]] 14 | 15 | if nums[queries[i][1]]%2==0: 16 | s-=nums[queries[i][1]] 17 | 18 | #updation 19 | nums[queries[i][1]]+=queries[i][0] 20 | 21 | #again checking if the updation value is even then add to the s, otherwise not 22 | if nums[queries[i][1]]%2==0: 23 | s+=nums[queries[i][1]] 24 | 25 | #storing the everytime updating sum 26 | r.append(s) 27 | 28 | return r 29 | -------------------------------------------------------------------------------- /Arrays and Matrix/Matrix_Multiplication.Py: -------------------------------------------------------------------------------- 1 | 2 | def print_matrix(matrix): 3 | for i in range(len(matrix)): 4 | for j in range(len(matrix[0])): 5 | print("\t",matrix[i][j],end=" ") 6 | print("\n") 7 | 8 | def main(): 9 | m = int( input("enter first matrix rows")) 10 | n = int( input("enter first matrix columns")) 11 | p = int( input("enter second matrix rows")) 12 | q = int( input("enter second matrix columns")) 13 | if( n != p): 14 | print("matrice multipilication not possible...") 15 | 16 | #declaration ofarrays 17 | array1=[[0 for j in range (0 , n)] for i in range (0 , m)] 18 | array2=[[0 for j in range (0 , q)] for i in range (0 , p)] 19 | result=[[0 for j in range (0 , q)] for i in range (0 , m)] 20 | 21 | #taking input from user 22 | print ("enter first matrix elements:" ) 23 | for i in range(0 , m): 24 | for j in range(0 , n): 25 | array1[i][j]=int (input("enter element")) 26 | print ("enter second matrix elements:") 27 | for i in range(0 , p): 28 | for j in range(0 , q): 29 | array2[i][j]=int(input("enter element")) 30 | print ("first matrix") 31 | print_matrix(array1) 32 | print ("second matrix") 33 | print_matrix(array2) 34 | #for multiplication 35 | # i will run throgh each row of matrix1 36 | for i in range(0 , m): 37 | # j will run through each column of matrix 2 38 | for j in range(0 , q): 39 | # k will run throguh each row of matrix 2 40 | for k in range(0 , n): 41 | result[i][j] += array1[i][k] * array2[k][j] 42 | #printing result 43 | print ( "multiplication of two matrices:" ) 44 | print_matrix(result) 45 | main() 46 | -------------------------------------------------------------------------------- /Arrays and Matrix/MergeSort.py: -------------------------------------------------------------------------------- 1 | def merge(arr, l, m, r): 2 | n1 = m - l + 1 3 | n2 = r - m 4 | 5 | # create temp arrays 6 | L = [0] * (n1) 7 | R = [0] * (n2) 8 | 9 | # Copy data to temp arrays L[] and R[] 10 | for i in range(0, n1): 11 | L[i] = arr[l + i] 12 | 13 | for j in range(0, n2): 14 | R[j] = arr[m + 1 + j] 15 | 16 | # Merge the temp arrays back into arr[l..r] 17 | i = 0 # Initial index of first subarray 18 | j = 0 # Initial index of second subarray 19 | k = l # Initial index of merged subarray 20 | 21 | while i < n1 and j < n2: 22 | if L[i] <= R[j]: 23 | arr[k] = L[i] 24 | i += 1 25 | else: 26 | arr[k] = R[j] 27 | j += 1 28 | k += 1 29 | 30 | # Copy the remaining elements of L[], if there 31 | # are any 32 | while i < n1: 33 | arr[k] = L[i] 34 | i += 1 35 | k += 1 36 | 37 | # Copy the remaining elements of R[], if there 38 | # are any 39 | while j < n2: 40 | arr[k] = R[j] 41 | j += 1 42 | k += 1 43 | 44 | # l is for left index and r is right index of the 45 | # sub-array of arr to be sorted 46 | 47 | 48 | def mergeSort(arr, l, r): 49 | if l < r: 50 | 51 | # Same as (l+r)//2, but avoids overflow for 52 | # large l and h 53 | m = l+(r-l)//2 54 | 55 | # Sort first and second halves 56 | mergeSort(arr, l, m) 57 | mergeSort(arr, m+1, r) 58 | merge(arr, l, m, r) 59 | 60 | 61 | # Driver code to test above 62 | arr = [12, 11, 13, 5, 6, 7] 63 | n = len(arr) 64 | print("Given array is") 65 | for i in range(n): 66 | print("%d" % arr[i],end=" ") 67 | 68 | mergeSort(arr, 0, n-1) 69 | print("\n\nSorted array is") 70 | for i in range(n): 71 | print("%d" % arr[i],end=" ") 72 | -------------------------------------------------------------------------------- /Arrays and Matrix/OddEvenSort.py: -------------------------------------------------------------------------------- 1 | def oddEvenSort(arr, n): 2 | isSorted = 0 3 | 4 | while isSorted == 0: 5 | isSorted = 1 6 | temp = 0 7 | 8 | for i in range(1, n-1, 2): 9 | if arr[i] > arr[i+1]: 10 | arr[i], arr[i+1] = arr[i+1], arr[i] 11 | isSorted = 0 12 | 13 | for i in range(0, n-1, 2): 14 | if arr[i] > arr[i+1]: 15 | arr[i], arr[i+1] = arr[i+1], arr[i] 16 | isSorted = 0 17 | 18 | return 19 | 20 | arr = [9,7,3,8,5,6,4,1] 21 | n = len(arr) 22 | oddEvenSort(arr, n); 23 | 24 | for i in range(0, n): 25 | print(arr[i], end = ' ') -------------------------------------------------------------------------------- /Arrays and Matrix/QuickSort/quicksort.py: -------------------------------------------------------------------------------- 1 | def partition(array, low, high): 2 | pivot = array[high] 3 | i = low - 1 4 | 5 | for j in range(low, high): 6 | if array[j] <= pivot: 7 | i = i + 1 8 | (array[i], array[j]) = (array[j], array[i]) 9 | (array[i + 1], array[high]) = (array[high], array[i + 1]) 10 | return i + 1 11 | 12 | def quick_sort(array, low, high): 13 | if low < high: 14 | pi = partition(array, low, high) 15 | quick_sort(array, low, pi - 1) 16 | quick_sort(array, pi + 1, high) 17 | 18 | array = list(map(int,input().split())) 19 | quick_sort(array, 0, len(array) - 1) 20 | 21 | print(f'Sorted array: {array}') -------------------------------------------------------------------------------- /Arrays and Matrix/Radix-Sort.py: -------------------------------------------------------------------------------- 1 | # Using counting sort to sort the elements in the basis of significant places 2 | def countingSort(array, place): 3 | size = len(array) 4 | output = [0] * size 5 | count = [0] * 10 6 | 7 | # Calculate count of elements 8 | for i in range(0, size): 9 | index = array[i] // place 10 | count[index % 10] += 1 11 | 12 | # Calculate cumulative count 13 | for i in range(1, 10): 14 | count[i] += count[i - 1] 15 | 16 | # Place the elements in sorted order 17 | i = size - 1 18 | while i >= 0: 19 | index = array[i] // place 20 | output[count[index % 10] - 1] = array[i] 21 | count[index % 10] -= 1 22 | i -= 1 23 | 24 | for i in range(0, size): 25 | array[i] = output[i] 26 | 27 | 28 | # Main function to implement radix sort 29 | def radixSort(array): 30 | # Get maximum element 31 | max_element = max(array) 32 | 33 | # Apply counting sort to sort elements based on place value. 34 | place = 1 35 | while max_element // place > 0: 36 | countingSort(array, place) 37 | place *= 10 38 | 39 | 40 | data = [121, 432, 564, 23, 1, 45, 788] 41 | radixSort(data) 42 | print(data) 43 | -------------------------------------------------------------------------------- /Arrays and Matrix/SelectionSort.py: -------------------------------------------------------------------------------- 1 | #SelectionSort 2 | def selection_sort(alist): 3 | for i in range(0, len(alist) - 1): 4 | smallest = i 5 | for j in range(i + 1, len(alist)): 6 | if alist[j] < alist[smallest]: 7 | smallest = j 8 | alist[i], alist[smallest] = alist[smallest], alist[i] 9 | 10 | 11 | alist = input('Enter the list of numbers: ').split() 12 | alist = [int(x) for x in alist] 13 | selection_sort(alist) 14 | print('Sorted list: ', end='') 15 | print(alist) 16 | -------------------------------------------------------------------------------- /Arrays and Matrix/add_subtract_matrices.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | def adding_two_matrices(A, B): 4 | # This functions returns the result from the sum of matrix A with matrix B 5 | 6 | # Make sure we have numpy matrices (type cast) 7 | A = np.array(A) 8 | B = np.array(B) 9 | 10 | return np.add(A, B) 11 | 12 | def substracting_two_matrices(A, B): 13 | # This functions returns the result from substracting matrix B from matrix A 14 | 15 | # Make sure we have numpy matrices (type cast) 16 | A = np.array(A) 17 | B = np.array(B) 18 | 19 | return np.subtract(A, B) 20 | 21 | # Tests 22 | first_test_matrix = [4, 5] 23 | second_test_matrix = [6, 5] 24 | 25 | print(f"First matrix {first_test_matrix}") 26 | print(f"Second matrix {second_test_matrix}") 27 | print("Matrix Addition") 28 | print(adding_two_matrices(first_test_matrix, second_test_matrix)) 29 | print("Matrix Substraction") 30 | print(substracting_two_matrices(first_test_matrix, second_test_matrix)) 31 | -------------------------------------------------------------------------------- /Arrays and Matrix/column_zig_zag_swap.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | r,c=map(int,input().split()) 3 | mat=[list(map(int,input().split())) for i in range(r)] 4 | mod=[] 5 | for i in zip(*mat): 6 | mod.append(list(i)) 7 | l=[] 8 | for i in range(c): 9 | if i%2==0: 10 | l.append(list(mod[c-1-i][r//2:]+mod[i][r//2:])) 11 | else: 12 | l.append(list(mod[i][:r//2]+mod[c-1-i][:r//2])) 13 | for i in zip(*l): 14 | print(*i) 15 | -------------------------------------------------------------------------------- /Arrays and Matrix/dynamic_sort.py: -------------------------------------------------------------------------------- 1 | 2 | #Name: Srishti Chauhan 3 | #Problem: Hackerrank Dynamic-sort 4 | 5 | from numpy import sort 6 | #!/bin/python3 7 | 8 | import math 9 | import os 10 | import random 11 | import re 12 | import sys 13 | 14 | # 15 | # Complete the 'dynamicArray' function below. 16 | # 17 | # The function is expected to return an INTEGER_ARRAY. 18 | # The function accepts following parameters: 19 | # 1. INTEGER n 20 | # 2. 2D_INTEGER_ARRAY queries 21 | # 22 | 23 | def dynamicArray(n, queries): 24 | # Write your code here 25 | 26 | if __name__ == '__main__': 27 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 28 | 29 | first_multiple_input = input().rstrip().split() 30 | 31 | n = int(first_multiple_input[0]) 32 | 33 | q = int(first_multiple_input[1]) 34 | 35 | queries = [] 36 | 37 | for _ in range(q): 38 | queries.append(list(map(int, input().rstrip().split()))) 39 | 40 | result = dynamicArray(n, queries) 41 | 42 | fptr.write('\n'.join(map(str, result))) 43 | fptr.write('\n') 44 | 45 | fptr.close() 46 | -------------------------------------------------------------------------------- /Arrays and Matrix/encode_decode.py: -------------------------------------------------------------------------------- 1 | import base64 2 | 3 | def encode(string): 4 | Encoded_string = "" 5 | length_of_the_string = len(string) 6 | if length_of_the_string > 1: 7 | for variable in string: 8 | ans = str(ord(variable)) + " " + \ 9 | str(length_of_the_string+ord(variable)) + "&" 10 | Encoded_string += ans 11 | else: 12 | ans = str(ord(string)) + "&" + str(ord(string)) 13 | Encoded_string += ans 14 | encoded = string.encode() 15 | return encoded 16 | 17 | 18 | def decode(string): 19 | ans = string.split("&") 20 | ans1 = "" 21 | value = "" 22 | ans.pop() 23 | for ans in ans: 24 | x = ans.split() 25 | ans1 = chr(int(x[0])) 26 | value += ans1 27 | return value 28 | -------------------------------------------------------------------------------- /Arrays and Matrix/fibonacci.py: -------------------------------------------------------------------------------- 1 | 2 | nterms = int(input("How many terms? ")) 3 | 4 | # first two terms 5 | n1, n2 = 0, 1 6 | count = 0 7 | 8 | # check if the number of terms is valid 9 | if nterms <= 0: 10 | print("Please enter a positive integer") 11 | # if there is only one term, return n1 12 | elif nterms == 1: 13 | print("Fibonacci sequence upto",nterms,":") 14 | print(n1) 15 | # generate fibonacci sequence 16 | else: 17 | print("Fibonacci sequence:") 18 | while count < nterms: 19 | print(n1) 20 | nth = n1 + n2 21 | # update values 22 | n1 = n2 23 | n2 = nth 24 | count += 1 25 | 26 | 27 | -------------------------------------------------------------------------------- /Arrays and Matrix/hashing.py: -------------------------------------------------------------------------------- 1 | import hashlib 2 | 3 | 4 | def hashing(personal_key: str, data: str) -> str: 5 | """Provide the hash 256 of the value you want to hashing. 6 | 7 | :param personal_key: (str) the key word to use for a very high hashing. 8 | It's any word, not particular word to put. Example: You can put like personal_key = 'word'. 9 | :param data: (str) the data you want to hash. 10 | :return: (str) the hashing value. 11 | """ 12 | key = personal_key.encode("UTF8") 13 | data = data.encode("UTF8") 14 | hash_ = hashlib.sha256(key+data).hexdigest() 15 | return hash_ 16 | 17 | 18 | if __name__ == '__main__': 19 | p_k = input("Enter your personal key for the hashing: ") 20 | d = input("Enter data you want to hash: ") 21 | 22 | hash = hashing(p_k, d) 23 | print("\nThe hash :", hash) 24 | -------------------------------------------------------------------------------- /Arrays and Matrix/insertion_sort.py: -------------------------------------------------------------------------------- 1 | def insertionsort(A): 2 | #we start loop at second element (index 1) since the first item is already sorted 3 | for j in range(1,len(A)): 4 | key = A[j] #The next item we are going to insert into the sorted section of the array 5 | 6 | i = j-1 #the last item we are going to compare to 7 | #now we keep moving the key back as long as it is smaller than the last item in the array 8 | while (i > -1) and key < A[i]: #if i == -1 means that this key belongs at the start 9 | A[i+1]=A[i] #move the last object compared one step ahead to make room for key 10 | i=i-1 #observe the next item for next time. 11 | #okay i is not greater than key means key belongs at i+1 12 | A[i+1] = key 13 | return A 14 | 15 | 16 | 17 | if __name__=="__main__": 18 | x = [5,2,4,6,1,3] 19 | insertionsort(x) 20 | print x 21 | -------------------------------------------------------------------------------- /Arrays and Matrix/int_array_rotator.py: -------------------------------------------------------------------------------- 1 | def int_array_rotator(rotation_request: int, my_list: list[int], ) -> list[int]: 2 | """ 3 | This function takes an int array and rotates by a certain number 4 | """ 5 | 6 | array_size = len(my_list)-1 7 | 8 | # We are returning the same list because in Python the list is passed by reference and not by value 9 | for i in range(rotation_request): 10 | temporary_memory = my_list[array_size] 11 | my_list.pop(array_size) 12 | 13 | my_list.insert(0,temporary_memory) 14 | return my_list 15 | 16 | print("----------------------") 17 | print("Proof of Concept with this example: [1, 2, 3, 4]") 18 | print(int_array_rotator(1, [1, 2, 3, 4])) 19 | print(int_array_rotator(2, [1, 2, 3, 4])) 20 | print(int_array_rotator(3, [1, 2, 3, 4])) 21 | print(int_array_rotator(4, [1, 2, 3, 4])) 22 | print(int_array_rotator(5, [1, 2, 3, 4])) 23 | print("----------------------") 24 | -------------------------------------------------------------------------------- /Arrays and Matrix/matrix_inverse.py: -------------------------------------------------------------------------------- 1 | from __future__ import annotations 2 | 3 | from decimal import Decimal 4 | 5 | 6 | def inverse_of_matrix(matrix: list[list[float]]) -> list[list[float]]: 7 | """ 8 | 9 | >>> inverse_of_matrix([[2, 5], [2, 0]]) 10 | [[0.0, 0.5], [0.2, -0.2]] 11 | >>> inverse_of_matrix([[2.5, 5], [1, 2]]) 12 | Traceback (most recent call last): 13 | ... 14 | ValueError: This matrix has no inverse. 15 | >>> inverse_of_matrix([[12, -16], [-9, 0]]) 16 | [[0.0, -0.1111111111111111], [-0.0625, -0.08333333333333333]] 17 | >>> inverse_of_matrix([[12, 3], [16, 8]]) 18 | [[0.16666666666666666, -0.0625], [-0.3333333333333333, 0.25]] 19 | >>> inverse_of_matrix([[10, 5], [3, 2.5]]) 20 | [[0.25, -0.5], [-0.3, 1.0]] 21 | """ 22 | 23 | D = Decimal # An abbreviation for conciseness 24 | 25 | # Check if the provided matrix has 2 rows and 2 columns 26 | # since this implementation only works for 2x2 matrices 27 | if len(matrix) != 2 or len(matrix[0]) != 2 or len(matrix[1]) != 2: 28 | raise ValueError("Please provide a matrix of size 2x2.") 29 | 30 | # Calculate the determinant of the matrix 31 | determinant = D(matrix[0][0]) * D(matrix[1][1]) - D(matrix[1][0]) * D(matrix[0][1]) 32 | if determinant == 0: 33 | raise ValueError("This matrix has no inverse.") 34 | 35 | # Creates a copy of the matrix with swapped positions of the elements 36 | swapped_matrix = [[0.0, 0.0], [0.0, 0.0]] 37 | swapped_matrix[0][0], swapped_matrix[1][1] = matrix[1][1], matrix[0][0] 38 | swapped_matrix[1][0], swapped_matrix[0][1] = -matrix[1][0], -matrix[0][1] 39 | 40 | # Calculate the inverse of the matrix 41 | return [[float(D(n) / determinant) or 0.0 for n in row] for row in swapped_matrix] 42 | -------------------------------------------------------------------------------- /Arrays and Matrix/matrix_rotation.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def rotate(self, matrix): 3 | temp_matrix = [] 4 | column = len(matrix)-1 5 | for column in range(len(matrix)): 6 | temp = [] 7 | for row in range(len(matrix)-1,-1,-1): 8 | temp.append(matrix[row][column]) 9 | temp_matrix.append(temp) 10 | for i in range(len(matrix)): 11 | for j in range(len(matrix)): 12 | matrix[i][j] = temp_matrix[i][j] 13 | return matrix 14 | 15 | ob1 = Solution() 16 | print(ob1.rotate([[1,5,7],[9,6,3],[2,1,3]])) 17 | -------------------------------------------------------------------------------- /Arrays and Matrix/maximum_sum_subarray.py: -------------------------------------------------------------------------------- 1 | def maxSubArray(nums): 2 | if len(nums) > 1: 3 | current_sum = 0 4 | max_sum = -10000000 5 | for i in range(len(nums)): 6 | current_sum += nums[i] 7 | if current_sum > max_sum: 8 | max_sum = current_sum 9 | if current_sum < 0: 10 | current_sum = 0 11 | return max_sum 12 | return nums[0] 13 | -------------------------------------------------------------------------------- /Arrays and Matrix/shell_sort.py: -------------------------------------------------------------------------------- 1 | #This program is made by GodDrago 2 | 3 | def shellSort(array, n): 4 | 5 | 6 | interval = n // 2 7 | while interval > 0: 8 | for i in range(interval, n): 9 | temp = array[i] 10 | j = i 11 | while j >= interval and array[j - interval] > temp: 12 | array[j] = array[j - interval] 13 | j -= interval 14 | 15 | array[j] = temp 16 | interval //= 2 17 | 18 | 19 | data = [9, 8, 3, 7, 5, 6, 4, 1] 20 | size = len(data) 21 | shellSort(data, size) 22 | print('Sorted Array in Ascending Order:') 23 | print(data) 24 | -------------------------------------------------------------------------------- /COA Algorithms/Binary Multiplication.py: -------------------------------------------------------------------------------- 1 | from Utils import Dec 2 | 3 | 4 | def main(): 5 | num1, num2 = map(int, input("Enter two nos: ").split()) 6 | sign = 1 7 | if num1 < 0: 8 | sign *= -1 9 | num1_bin = bin(-num1)[2:] 10 | else: 11 | num1_bin = bin(num1)[2:] 12 | 13 | if num2 < 0: 14 | sign *= -1 15 | num2_bin = bin(-num2)[2:] 16 | else: 17 | num2_bin = bin(num2)[2:] 18 | print("x = ", num1_bin) 19 | print("y = ", num2_bin) 20 | num1_len = len(num1_bin) 21 | num2_len = len(num2_bin) 22 | space = num1_len + num2_len - 1 23 | count = 0 24 | total = 0 25 | print(" ", num1_bin.rjust(space)) 26 | print("x", num2_bin.rjust(space)) 27 | print('-'*(space+2)) 28 | for i in range(num2_len - 1, -1, -1): 29 | temp = num2_bin[i] 30 | if temp == '0': 31 | add = '0' * num1_len + '0' * count 32 | else: 33 | add = num1_bin + '0' * count 34 | print("+", add.rjust(space)) 35 | total += Dec(add) 36 | count += 1 37 | total *= sign 38 | print('-'*(space + 2)) 39 | print("=",bin(total)[2:]) 40 | print(f"{num1} x {num2} = {total}") 41 | 42 | 43 | if __name__ == '__main__': 44 | main() 45 | -------------------------------------------------------------------------------- /COA Algorithms/Non Restoring Division.py: -------------------------------------------------------------------------------- 1 | from Utils import Dec, Add, divInput, LeftShift 2 | 3 | 4 | def main(): 5 | num1, num2, Q_bin, M_bin, M_bar_plus_one, A, SC = divInput() 6 | for i in range(SC - 1): 7 | print("Cycle:", i + 1) 8 | print(f" A = {A} {Q_bin} ") 9 | 10 | A, Q_bin = LeftShift(A, Q_bin) 11 | print(f" Left Shift = {A} {Q_bin} ") 12 | 13 | if A[0] == "1": 14 | A = Add(A, M_bin, SC) 15 | print(f" Add +{M_bin}") 16 | else: 17 | A = Add(A, M_bar_plus_one, SC) 18 | print(f" Subtract +{M_bar_plus_one}") 19 | 20 | if A[0] == "1": 21 | Q_bin = Q_bin[:-1] + "0" 22 | else: 23 | Q_bin = Q_bin[:-1] + "1" 24 | 25 | print(f" A = {A} {Q_bin} ") 26 | print() 27 | print() 28 | 29 | if A[0] == "1": 30 | print(f" Add +{M_bin}") 31 | A = Add(A, M_bin, SC) 32 | print(f" A = {A} {Q_bin} ") 33 | 34 | quotient = Dec(Q_bin) 35 | remainder = Dec(A) 36 | print(f"{num1}/{num2}") 37 | print(f"Quotient = {quotient}, Remainder = {remainder}") 38 | 39 | 40 | if __name__ == '__main__': 41 | main() 42 | -------------------------------------------------------------------------------- /COA Algorithms/README.md: -------------------------------------------------------------------------------- 1 | # Computer Organization & Architecture (COA or CSA) Algorithms 2 | 3 | ### All the codes mentioned here are in python language and there's a reason behind this i.e. the codes for such algorithms are a bit lengthy, so python help us here as it reduces the code-length (lines of code) 4 | --- 5 | *Thankyou* :) 6 | -------------------------------------------------------------------------------- /COA Algorithms/Restoring Division.py: -------------------------------------------------------------------------------- 1 | from Utils import Dec, Add, divInput, LeftShift 2 | 3 | 4 | def main(): 5 | num1, num2, Q_bin, M_bin, M_bar_plus_one, A, SC = divInput() 6 | for i in range(SC - 1): 7 | print("Cycle:", i + 1) 8 | print(f" A = {A} {Q_bin} ") 9 | A, Q_bin = LeftShift(A, Q_bin) 10 | print(f" Left Shift = {A} {Q_bin} ") 11 | A = Add(A, M_bar_plus_one, SC) 12 | print(f" Subtract +{M_bar_plus_one}") 13 | if A[0] == "1": 14 | Q_bin = Q_bin[:-1] + "0" 15 | A = Add(A, M_bin, SC) 16 | else: 17 | Q_bin = Q_bin[:-1] + "1" 18 | 19 | print(f" A = {A} {Q_bin} ") 20 | print() 21 | print() 22 | 23 | quotient = Dec(Q_bin) 24 | remainder = Dec(A) 25 | print(f"{num1}/{num2}") 26 | print(f"Quotient = {quotient}, Remainder = {remainder}") 27 | 28 | 29 | if __name__ == '__main__': 30 | main() 31 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | 2 | If a person want to contribute to this repository then He/She must be beginner or at an intermediate to the code. 3 | 4 | the person needs to get assined before making the pull request 5 | 6 | if the person is making the pull request then the request will not be accepted and marked as spam 7 | -------------------------------------------------------------------------------- /Calculator Using html,css and js/script.js: -------------------------------------------------------------------------------- 1 | function display(val){ 2 | 3 | document.getElementById('result').value += val 4 | 5 | return val 6 | 7 | } 8 | 9 | function solve(){ 10 | 11 | let x = document.getElementById('result').value 12 | 13 | let y = eval(x); 14 | 15 | document.getElementById('result').value = y 16 | 17 | return y 18 | 19 | } 20 | 21 | function clearScreen(){ 22 | 23 | document.getElementById('result').value = '' 24 | 25 | } -------------------------------------------------------------------------------- /Discord_TextScraper.py: -------------------------------------------------------------------------------- 1 | # Dynamic Programming implementation of LCS problem 2 | 3 | def lcs(X, Y): 4 | 5 | m = len(X) 6 | n = len(Y) 7 | 8 | 9 | L = [[None]*(n + 1) for i in range(m + 1)] 10 | 11 | for i in range(m + 1): 12 | for j in range(n + 1): 13 | if i == 0 or j == 0 : 14 | L[i][j] = 0 15 | elif X[i-1] == Y[j-1]: 16 | L[i][j] = L[i-1][j-1]+1 17 | else: 18 | L[i][j] = max(L[i-1][j], L[i][j-1]) 19 | 20 | 21 | return L[m][n] 22 | 23 | 24 | 25 | 26 | X = "AGGTAB" 27 | Y = "GXTXAYB" 28 | print("Length of LCS is ", lcs(X, Y)) 29 | -------------------------------------------------------------------------------- /Mad-libs with.py: -------------------------------------------------------------------------------- 1 | #Loop back to this point once code finishes 2 | 3 | loop = 1 4 | 5 | while (loop < 10): 6 | 7 | # All the questions that the program asks the user 8 | 9 | noun = input("Choose a noun: ") 10 | 11 | p_noun = input("Choose a plural noun: ") 12 | 13 | noun2 = input("Choose a noun: ") 14 | 15 | place = input("Name a place: ") 16 | 17 | adjective = input("Choose an adjective (Describing word): ") 18 | 19 | noun3 = input("Choose a noun: ") 20 | 21 | #Displays the story based on the users input 22 | 23 | print ("------------------------------------------") 24 | 25 | print ("Be kind to your",noun,"- footed", p_noun) 26 | 27 | print ("For a duck may be somebody's", noun2,",") 28 | 29 | print ("Be kind to your",p_noun,"in",place) 30 | 31 | print ("Where the weather is always",adjective,".") 32 | 33 | print () 34 | 35 | print ("You may think that is this the",noun3,",") 36 | 37 | print ("Well it is.") 38 | 39 | print ("------------------------------------------") 40 | 41 | # Loop back to "loop = 1" 42 | 43 | loop = loop + 1 44 | -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/1.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/2.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/2.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/3.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/3.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/4.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/4.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/5.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/5.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/audio/A_Documentary_on_Ujjain_(getmp3.pro).mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/audio/A_Documentary_on_Ujjain_(getmp3.pro).mp3 -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/audio/India_Marvels_Mysteries__(getmp3.pro).mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/audio/India_Marvels_Mysteries__(getmp3.pro).mp3 -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/audio/Indian_bison_gaur_of_Kanha_nation_(getmp3.pro).mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/audio/Indian_bison_gaur_of_Kanha_nation_(getmp3.pro).mp3 -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/audio/New_Development_in_Omkareshwar_-_A_(getmp3.pro).mp3: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/audio/New_Development_in_Omkareshwar_-_A_(getmp3.pro).mp3 -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/feature-image-v1-1.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/feature-image-v1-1.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/mike-tinnion-BA7da404ekg-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/mike-tinnion-BA7da404ekg-unsplash.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/shutterstock_1430024867.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/shutterstock_1430024867.jpg -------------------------------------------------------------------------------- /Madhya Pradesh Tourism Website/assests/yash-parashar-3J6Jy2defyw-unsplash.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Madhya Pradesh Tourism Website/assests/yash-parashar-3J6Jy2defyw-unsplash.jpg -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/.gitignore: -------------------------------------------------------------------------------- 1 | /__pycache__ -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/README.md: -------------------------------------------------------------------------------- 1 | # Alien Spaceship Game in Python 2 | 3 | This project is inspired by the book **Eric Matthes - Python Crash Course A Hands-On, Project-Based Introduction to Programming-No Starch Press (2016)** 4 | 5 | ## Introduction 6 | This is a game created using python pygame. 7 | 8 | ## Installation 9 | 10 | Use the package manager [pip](https://pip.pypa.io/en/stable/) to install pygame. 11 | 12 | ```bash 13 | pip install pygame 14 | ``` 15 | 16 | ## Usage 17 | * Run the game by typing the following command in terminal. 18 | ```bash 19 | py alien_invasion.py 20 | ``` 21 | * Use **left and right arrow keys** to move the spaceship. 22 | * Use **spacebar** to fire the bullet. 23 | * You can modify speed of every component in **settings.py** 24 | 25 | ## Comments 26 | This project is created for my practice and I would like to thank Eric Matthes for this great book. 27 | 28 | ## Demo Video 29 | demo -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/alien.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | 3 | from pygame.sprite import Sprite 4 | 5 | #class to represent single alien 6 | class Alien(Sprite): 7 | 8 | def __init__(self,ai_settings,screen): 9 | #initializing parent class as inherited as sprite 10 | super(Alien,self).__init__() 11 | self.screen=screen 12 | self.ai_settings=ai_settings 13 | 14 | #loading alien image and set its rect attribute 15 | self.image=pygame.image.load('images/alien.bmp') 16 | self.rect=self.image.get_rect() 17 | 18 | #putting alien to top left having space equal to width and height as top space 19 | self.rect.x=self.rect.width 20 | self.rect.y=self.rect.height 21 | 22 | #store aliens exact position 23 | self.x=float(self.rect.x) 24 | 25 | #drawing alien on screen 26 | def blitme(self): 27 | self.screen.blit(self.image,self.rect) 28 | 29 | #checking edges/return true if alien is at edge 30 | def check_edges(self): 31 | screen_rect=self.screen.get_rect() 32 | if self.rect.right>=screen_rect.right: 33 | return True 34 | elif self.rect.left<=0: 35 | return True 36 | 37 | 38 | 39 | #moving the alien left/right 40 | def update(self): 41 | self.x+=(self.ai_settings.alien_speed_factor*self.ai_settings.fleet_direction) 42 | self.rect.x=self.x -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/alien_invasion_demo.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/PYTHON GUI/Alien Spaceship Game/alien_invasion_demo.gif -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/bullet.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | 3 | from pygame.sprite import Sprite 4 | 5 | class Bullet(Sprite): 6 | def __init__(self,ai_settings,screen,ship): 7 | super(Bullet,self).__init__() #or super().__init__() 8 | 9 | self.screen=screen 10 | 11 | # Create a bullet rect at (0, 0) and then set correct position. 12 | self.rect=pygame.Rect(0,0,ai_settings.bullet_width,ai_settings.bullet_height) 13 | self.rect.centerx=ship.rect.centerx 14 | self.rect.top=ship.rect.top 15 | 16 | #store bullet position as decimal value 17 | self.y=float(self.rect.y) 18 | self.color=ai_settings.bullet_color 19 | self.speed_factor=ai_settings.bullet_speed_factor 20 | 21 | def update(self): 22 | #move the bullets up the screen 23 | self.y-=self.speed_factor 24 | #maintaining the x cordinate only y cordinate of bullet changes 25 | self.rect.y=self.y 26 | 27 | #drawing bullet on screen 28 | def draw_bullet(self): 29 | pygame.draw.rect(self.screen,self.color,self.rect) 30 | -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/button.py: -------------------------------------------------------------------------------- 1 | import pygame.font 2 | 3 | #making play button 4 | class Button(): 5 | def __init__(self,ai_settings,screen,msg): 6 | self.screen=screen 7 | self.screen_rect=screen.get_rect() 8 | 9 | #set dimensions and properties of the button 10 | self.width,self.height=200,50 11 | self.button_color=(0,255,0) 12 | self.text_color=(255,255,255) 13 | self.font=pygame.font.SysFont(None,48) #none means import default font size=48px 14 | 15 | #build the button's rect object and center it 16 | self.rect=pygame.Rect(0,0,self.width,self.height) 17 | self.rect.center=self.screen_rect.center 18 | 19 | #the button message need to be prepped only once 20 | self.prep_msg(msg) 21 | 22 | #turn message into rendered image and center it 23 | def prep_msg(self,msg): 24 | self.msg_image=self.font.render(msg,True,self.text_color,self.button_color) 25 | self.msg_image_rect=self.msg_image.get_rect() 26 | self.msg_image_rect.center=self.rect.center 27 | 28 | #draw blank rect then over it draw msg rect 29 | def draw_button(self): 30 | #to daw rectangle over screen we use fill 31 | self.screen.fill(self.button_color,self.rect) 32 | #to draw image over screen we use blit 33 | self.screen.blit(self.msg_image,self.msg_image_rect) 34 | 35 | 36 | 37 | -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/game_stats.py: -------------------------------------------------------------------------------- 1 | 2 | #track statistics of game 3 | 4 | class GameStats(): 5 | def __init__(self,ai_settings): 6 | self.ai_settings=ai_settings 7 | self.reset_stats() 8 | #start game in inactive state 9 | self.game_active=False 10 | #high score should never reset 11 | self.high_score=0 12 | 13 | 14 | def reset_stats(self): 15 | #initialize stats that can change during the game 16 | self.ships_left=self.ai_settings.ship_limit 17 | self.score=0 18 | self.level=1 19 | -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/images/alien.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/PYTHON GUI/Alien Spaceship Game/images/alien.bmp -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/images/ship.bmp: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/PYTHON GUI/Alien Spaceship Game/images/ship.bmp -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/settings.py: -------------------------------------------------------------------------------- 1 | class Settings(): 2 | #setting to store the settings of alien invasion 3 | def __init__(self): 4 | """initializes games static settings""" 5 | #screen settings 6 | self.screen_height=700 7 | self.screen_width=1200 8 | self.bg_color=(230,230,230) 9 | 10 | #ship settings 11 | self.ship_limit=3 12 | 13 | #bullet settings 14 | self.bullet_width=3 15 | self.bullet_height=15 16 | self.bullet_color=(60,60,60) 17 | self.bullets_allowed=10 18 | 19 | #alien settings 20 | self.fleet_drop_speed=10 21 | 22 | #how quickly the game speed up 23 | self.speedup_scale=1.1 24 | #how quickly the alien points value increase 25 | self.score_scale=1.5 26 | 27 | self.initialize_dynamic_settings() 28 | 29 | """initialize dynamic settings of game""" 30 | def initialize_dynamic_settings(self): 31 | self.ship_speed_factor=1.5 32 | self.bullet_speed_factor=3 33 | self.alien_speed_factor=1 34 | self.fleet_direction=1 #1=right,-1=left 35 | #scoring 36 | self.alien_points=50 37 | 38 | #increse alien speed and point scale 39 | def increase_speed(self): 40 | self.ship_speed_factor*=self.speedup_scale 41 | self.bullet_speed_factor*=self.speedup_scale 42 | self.alien_speed_factor*=self.speedup_scale 43 | self.alien_points=int(self.alien_points*self.score_scale) 44 | -------------------------------------------------------------------------------- /PYTHON GUI/Alien Spaceship Game/ship.py: -------------------------------------------------------------------------------- 1 | import pygame 2 | from pygame.sprite import Sprite 3 | 4 | class Ship(Sprite): 5 | def __init__(self,ai_settings,screen): 6 | #initialize the ship and set its starting position 7 | super(Ship,self).__init__() 8 | self.screen=screen 9 | 10 | #load ship image ang get rect() of screen and ship image 11 | self.image=pygame.image.load('images/ship.bmp') 12 | self.rect=self.image.get_rect() 13 | self.screen_rect=screen.get_rect() 14 | 15 | #position the ship at bottom center os game window 16 | self.rect.centerx=self.screen_rect.centerx 17 | self.rect.bottom=self.screen_rect.bottom 18 | 19 | self.ai_settings=ai_settings 20 | #store decimal value of ship's center 21 | self.center=float(self.rect.centerx) 22 | 23 | #movement flags 24 | self.moving_right=False 25 | self.moving_left=False 26 | 27 | #updating ship position on movement flag 28 | def update(self): 29 | if self.moving_right and self.rect.right0: 32 | self.center-=self.ai_settings.ship_speed_factor 33 | 34 | #update rect object from self.center 35 | self.rect.centerx=self.center 36 | 37 | #center the ship when new ship reloads 38 | def center_ship(self): 39 | self.center=self.screen_rect.centerx 40 | 41 | #drawing the ship at given location 42 | def blitme(self): 43 | #providing position and image for ship to display 44 | self.screen.blit(self.image,self.rect) 45 | 46 | 47 | -------------------------------------------------------------------------------- /PYTHON GUI/Automatic Birthday Wisher Using Python/data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/PYTHON GUI/Automatic Birthday Wisher Using Python/data.xlsx -------------------------------------------------------------------------------- /PYTHON GUI/Automatic Birthday Wisher Using Python/main.py: -------------------------------------------------------------------------------- 1 | import pandas as pd 2 | import datetime 3 | import smtplib 4 | import os 5 | 6 | os.chdir(r"D:\Automatic Birthday Wisher") 7 | # os.mkdir("testing") 8 | 9 | def sendEmail(to, sub, msg): 10 | # Enter your authentication details 11 | GMAIL_ID = 'test@gmail.com' 12 | GMAIL_PSWD = 'password@123' 13 | print(f"Email to {to} sent with subject: {sub} and message {msg}") 14 | s = smtplib.SMTP('smtp.gmail.com', 587) 15 | s.starttls() 16 | s.login(GMAIL_ID, GMAIL_PSWD) 17 | 18 | s.sendmail(GMAIL_ID, to, f"Subject: {sub}\n\n{msg}") 19 | s.quit() 20 | if __name__ == "__main__": 21 | df = pd.read_excel("data.xlsx") 22 | # print(df) 23 | today = datetime.datetime.now().strftime("%d-%m") 24 | yearNow = datetime.datetime.now().strftime("%Y") 25 | # print(today) 26 | writeInd = [] # Prevent the code to send birthday wish to the person if he has already been wished in that year 27 | for index, item in df.iterrows(): 28 | # print(index, item['Birthday']) 29 | bday = item['Birthday'].strftime("%d-%m") 30 | # print(bday) 31 | if(today == bday) and yearNow not in str(item['Year']): 32 | sendEmail(item['Email'], "Happy Birthday!", item['Dialogue']) 33 | writeInd.append(index) 34 | # print(writeInd) 35 | for i in writeInd: 36 | if len(writeInd)==0: 37 | break 38 | yr =df.loc[i, 'Year'] 39 | df.loc[i, 'Year'] = str(yr) + ',' + str(yearNow) 40 | # print(df.loc[i, 'Year']) 41 | 42 | # print(df) 43 | df.to_excel('data.xlsx', index = False) # pip install openpyxl 44 | 45 | -------------------------------------------------------------------------------- /PYTHON GUI/Digital_clock.py: -------------------------------------------------------------------------------- 1 | import time 2 | from tkinter import * 3 | root=Tk() 4 | root.geometry("350x120+0+0") 5 | root.configure(background="black") 6 | root.resizable(0,0) 7 | root.overrideredirect(1) 8 | def start(): 9 | text=time.strftime("%H:%M:%S") 10 | label.config(text=text) 11 | label.after(200,start) 12 | label= Label(root,font=("ds-digital",50,'bold'),bg='black',fg='red',bd=50) 13 | label.grid(row=0,column=1) 14 | start() 15 | print("done") 16 | root.mainloop() -------------------------------------------------------------------------------- /PYTHON GUI/GUI Calendar/README.md: -------------------------------------------------------------------------------- 1 | # GUI Calendar Python 2 | A simple GUI Calendar using Python 3 | ## Usage 4 | Make sure you have Python installed. 5 | How to run 6 | ```bash 7 | $ python gui-calendar.py 8 | ``` 9 | or 10 | ```bash 11 | $ python3 gui-calendar.py 12 | ``` 13 | then just enter a year. -------------------------------------------------------------------------------- /PYTHON GUI/GUI Calendar/gui-calendar.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | import calendar 3 | 4 | def showCal(): 5 | new_gui = Tk() 6 | 7 | new_gui.config(background='white') 8 | new_gui.title('GUI CALENDAR') 9 | new_gui.geometry('550x600') 10 | 11 | fetch_year = int(year_field.get()) 12 | cal_content = calendar.calendar(fetch_year) 13 | 14 | cal_year = Label(new_gui, text=cal_content, font='Consolas 10 bold') 15 | cal_year.grid(row=5, column=1, padx=20) 16 | 17 | new_gui.mainloop() 18 | 19 | if __name__ == "__main__": 20 | gui = Tk() 21 | 22 | gui.config(background='white') 23 | gui.title("GUI CALENDAR") 24 | gui.geometry('190x150') 25 | 26 | cal = Label(gui, text='CALENDAR', bg='white', font=('calibri', 30, 'bold')) 27 | cal.grid(row=1, column=1) 28 | 29 | year = Label(gui, text='Enter Year', bg='white', font=('calibri', 10)) 30 | year.grid(row=2, column=1) 31 | 32 | year_field = Entry(gui) 33 | year_field.grid(row=3, column=1) 34 | 35 | Show = Button(gui, text='Show Calendar', fg='Black', bg='light green', font=('calibri', 10), command=showCal) 36 | Show.grid(row=4, column=1) 37 | 38 | Exit = Button(gui, text='Exit', fg='#000000', bg='#e0536b', font=('calibri', 10), command=exit) 39 | Exit.grid(row=6, column=1) 40 | 41 | gui.mainloop() -------------------------------------------------------------------------------- /PYTHON GUI/GUI_For_Database.py: -------------------------------------------------------------------------------- 1 | #Name:Ashish Ramesh 2 | #Github ID : AshishRamesh 3 | 4 | from tkinter import * 5 | 6 | window= Tk(className='Database_GUI') 7 | 8 | L1=Label(window,text='Title') 9 | L1.grid(row=0,column=0) 10 | L2=Label(window,text='Name') 11 | L2.grid(row=0,column=2) 12 | L3=Label(window,text='Year') 13 | L3.grid(row=1,column=0) 14 | L4=Label(window,text='Phone No.') 15 | L4.grid(row=1,column=2) 16 | 17 | title_val = StringVar() 18 | E1=Entry(window,textvariable=title_val) 19 | Author_val = StringVar() 20 | E1.grid(row=0,column=1) 21 | E2=Entry(window,textvariable=Author_val) 22 | E2.grid(row=0,column=3) 23 | year_val = StringVar() 24 | E3=Entry(window,textvariable=year_val) 25 | E3.grid(row=1,column=1) 26 | ISBN_val=StringVar() 27 | E4=Entry(window,textvariable=ISBN_val) 28 | E4.grid(row=1,column=3) 29 | 30 | T1= Text(window,height=10,width=15) 31 | T1.grid(row=2,column=1,rowspan=5) 32 | 33 | B1=Button(window,text='View All',width=12) 34 | B1.grid(row=2,column=3) 35 | B2=Button(window,text='Search Entry',width=12) 36 | B2.grid(row=3,column=3) 37 | B3=Button(window,text='Add Entry',width=12) 38 | B3.grid(row=4,column=3) 39 | B4=Button(window,text='Update Selected',width=12) 40 | B4.grid(row=5,column=3) 41 | B5=Button(window,text='Delete Selected',width=12) 42 | B5.grid(row=6,column=3) 43 | B6=Button(window,text='Close',width=12) 44 | B6.grid(row=7,column=3) 45 | 46 | window.mainloop() -------------------------------------------------------------------------------- /PYTHON GUI/Hand Cricket/Hand_Cricket_Game.py: -------------------------------------------------------------------------------- 1 | import random 2 | import sys 3 | a = 1 4 | Score = 0 5 | print(""" 6 | Rules : 7 | Player should enter number below 10. 8 | The score will be displayed at the ending of the game 9 | When the player and computer plays the same number thus it is counted as OUT""") 10 | xyz = input(f"\n Ready for the game??? Hit enter to start...") 11 | 12 | while a == 1: 13 | User = int(input("\nEnter your number : ")) 14 | Comp = int(random.randint(0, 10)) 15 | Score = Score+User 16 | if User == Comp: 17 | print("Opps.. !!OUT!!") 18 | print("Total runs : ", Score) 19 | a = 1 20 | if Score >= 50 and Score <= 99: 21 | a = 2 22 | if Score > 100: 23 | a = 3 24 | if a == 2: 25 | print("Congratulations for your half-century!") 26 | a = 0 27 | break 28 | if a == 3: 29 | print("Congratulations for your century!") 30 | a = 0 31 | break 32 | 33 | break 34 | sys.exit() 35 | 36 | if User > 10: 37 | print("Enter number below 10..") 38 | a = 0 39 | print("Computer's number : ", Comp, "\n") 40 | -------------------------------------------------------------------------------- /PYTHON GUI/Heart_in_python_using_turtle.py: -------------------------------------------------------------------------------- 1 | 2 | import turtle 3 | 4 | 5 | pen = turtle.Turtle() 6 | 7 | 8 | def curve(): 9 | for i in range(200): 10 | 11 | pen.right(1) 12 | pen.forward(1) 13 | 14 | 15 | def heart(): 16 | 17 | pen.fillcolor('red') 18 | 19 | pen.begin_fill() 20 | 21 | pen.left(140) 22 | pen.forward(113) 23 | 24 | curve() 25 | pen.left(120) 26 | 27 | curve() 28 | 29 | pen.forward(112) 30 | 31 | pen.end_fill() 32 | 33 | def txt(): 34 | 35 | pen.up() 36 | 37 | pen.setpos(-68, 95) 38 | 39 | pen.down() 40 | 41 | pen.color('lightgreen') 42 | 43 | pen.write("Hacktober Fest 2022", font=( 44 | "Verdana", 9, "bold")) 45 | 46 | 47 | heart() 48 | 49 | txt() 50 | 51 | pen.ht() 52 | 53 | # Hacktoberfest 2022 54 | # Happy Hacking -------------------------------------------------------------------------------- /PYTHON GUI/PigLatin in Python: -------------------------------------------------------------------------------- 1 | /** 2 | *Pig Latin. noun. a secret language used by children in which any consonants at the beginning of a word are placed at the end, 3 | *followed by -ay; for example cathedral becomes athedralcay. 4 | **/ 5 | /* 6 | *This is a siple python code to implement Piglatin Translation 7 | */ 8 | 9 | name=input("Enter the name") 10 | print("The Initial word is :" +name) 11 | 12 | #converting the input name to lowercase 13 | name=name.lower() 14 | 15 | if(len(name)>0 and name.isalpha()) : 16 | pyg='ay' 17 | first=name[0] 18 | new_word= name + first + pyg 19 | new_word= new_word[1:len(new_word)] 20 | print("PIG LATIN TRANSTATION OF THIS WORD IS : "+new_word) 21 | 22 | else: 23 | print('Enter a valid String') 24 | 25 | /** 26 | 27 | Input 1 28 | Enter the nameRIYA 29 | The Initial word is :RIYA 30 | PIG LATIN TRANSTATION OF THIS WORD IS : iyaray 31 | 32 | Input2 33 | Enter the namedfgr345@ 34 | The Initial word is :dfgr345@ 35 | Enter a valid String 36 | 37 | Input3 38 | Enter the name 39 | The Initial word is : 40 | Enter a valid String 41 | 42 | **/ 43 | -------------------------------------------------------------------------------- /PYTHON GUI/Tic-Tac-Toe-Game-In-Python-srishti/Gui.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/PYTHON GUI/Tic-Tac-Toe-Game-In-Python-srishti/Gui.PNG -------------------------------------------------------------------------------- /PYTHON GUI/Tic-Tac-Toe-Game-In-Python-srishti/README.md: -------------------------------------------------------------------------------- 1 | # Tic-Tac-Toe-Game-In-Python 2 | 3 | Don't Forget to Subscribe My Channel , like video and share to your friends. If you want to learn any new things then comment over that. We will make new video on that As soon As Possible. 4 | 5 | Tic Tac Toe game 6 | 7 | ## GUI of game 8 | 9 | ![Gui](https://user-images.githubusercontent.com/52067673/83345735-36b9e200-a334-11ea-942e-d9dda5586477.png) 10 | 11 | ## Winning message Image 12 | 13 | ![Winning_message](https://user-images.githubusercontent.com/52067673/83345776-7ed90480-a334-11ea-9fff-ddb43ca7401a.png) 14 | 15 | ## Draw match message Image 16 | 17 | ![draw_messge](https://user-images.githubusercontent.com/52067673/83345796-9c0dd300-a334-11ea-8204-cb2611819a8a.png) 18 | -------------------------------------------------------------------------------- /PYTHON GUI/Tic-Tac-Toe-Game-In-Python-srishti/Winning_message.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/PYTHON GUI/Tic-Tac-Toe-Game-In-Python-srishti/Winning_message.PNG -------------------------------------------------------------------------------- /PYTHON GUI/Tic-Tac-Toe-Game-In-Python-srishti/draw_messge.PNG: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/PYTHON GUI/Tic-Tac-Toe-Game-In-Python-srishti/draw_messge.PNG -------------------------------------------------------------------------------- /PYTHON GUI/Torrent_Finder.py: -------------------------------------------------------------------------------- 1 | #Name:Ashish Ramesh 2 | #Github ID : AshishRamesh 3 | 4 | import webbrowser, colorama 5 | from colorama import Fore 6 | 7 | colorama.init() 8 | print(Fore.YELLOW +'Welcome to TORRENT FILE FINDER :)') 9 | print(Fore.BLUE +'Press 1 to find GAMES file \nPress 2 to find MOVIE files \n2Press 3 to find Torrent files in genral') 10 | input1 = input('What would you like to do ?? ') 11 | entry = input('Enter the game you want to find torrent file of : ') 12 | entry1 = entry.replace(' ','+') 13 | list1 = list(entry1.split(',')) 14 | 15 | for i in list1 : 16 | nam = i 17 | nam1 = nam.replace('+',' ') 18 | 19 | try: 20 | print(Fore.GREEN + 'Searching for torrent files....') 21 | if input1 == '1' : 22 | webbrowser.open("https://proxifiedpiratebay.org/search.php?q={}&cat=401".format(i)) 23 | elif input1 == '2' : 24 | webbrowser.open("https://proxifiedpiratebay.org/search.php?q={}&cat=207".format(i)) 25 | elif input1 == '3' : 26 | webbrowser.open("https://proxifiedpiratebay.org/search.php?q={}".format(i)) 27 | else : 28 | exit() 29 | break 30 | print(Fore.GREEN + '{} Files Found!!!'.format(nam1)) 31 | except: 32 | print(Fore.RED + '{} Error in file search :('.format(nam1)) -------------------------------------------------------------------------------- /PYTHON GUI/TowerofHanoi.py: -------------------------------------------------------------------------------- 1 | # Tower Of Hanoi using recursion 2 | def toh(n,ts, td, tm): 3 | if(n==1): 4 | print(str(n)+"["+ts+"->"+td+"]") 5 | else: 6 | toh(n-1,ts,tm,td) 7 | print(str(n)+"["+ts+"->"+td+"]") 8 | toh(n-1,tm,td,ts) 9 | n=int(input("Enter no. of discs-")) 10 | ts=(input("Enter id of source tower-")) 11 | td=(input("Enter id of destination tower-")) 12 | tm=(input("Enter id of mediator tower-")) 13 | toh(n,ts,td,tm) 14 | -------------------------------------------------------------------------------- /PYTHON GUI/game.py: -------------------------------------------------------------------------------- 1 | # libraries- collection of std codes... 2 | # module is a collection of pre-build functions... 3 | # package is the software "repository"... 4 | 5 | import random 6 | 7 | # lets see how many chances the computer need to guess the number... 8 | def computer_chance(lower_v,higher_v,rand_num,count=0): 9 | if higher_v >= lower_v: 10 | # divide and conquer approach... 11 | guess = lower_v + (higher_v-lower_v)//2 12 | if guess == rand_num: 13 | return count 14 | elif guess > rand_num: 15 | # this means number in lower half... 16 | count=count+1 17 | return computer_chance(lower_v,guess-1,rand_num,count) 18 | else: 19 | count=count+1 20 | return computer_chance(guess+1,higher_v,rand_num,count) 21 | else: 22 | return -1 23 | 24 | # generate a random number... 25 | rand_num = random.randint(1,100) 26 | # print(rand_num) # This is to check the number in case the code is need to be verified... 27 | 28 | count=0 29 | guess=-99 30 | 31 | while(guess!=rand_num): 32 | guess = (int)(input("Enter your guess between 1 and 100:")) 33 | if guess < rand_num: 34 | print("Higher") 35 | elif guess > rand_num: 36 | print("Lower") 37 | else: 38 | print("you guessed it...") 39 | break 40 | count=count+1 41 | 42 | print("You took "+str(count)+" steps to guess the number correctly.") 43 | 44 | print("Computer took "+ str(computer_chance(0,100,rand_num))+ " steps to reach") 45 | 46 | 47 | -------------------------------------------------------------------------------- /PYTHON GUI/national_flag_turtle.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | def rectangle(color): 3 | t.begin_fill() 4 | t.fillcolor(color) 5 | for i in range(2): 6 | t.forward(400) 7 | t.right(90) 8 | t.forward(100) 9 | t.right(90) 10 | t.end_fill() 11 | 12 | t=turtle.Turtle() 13 | turtle.screensize(1100,1100) 14 | turtle.title("National Flag Of India ") 15 | t.up() 16 | t.pensize(4) 17 | t.goto(0,-300) 18 | t.down() 19 | t.goto(0,400) 20 | rectangle("orange") 21 | t.goto(0,300) 22 | t.forward(200) 23 | t.color("blue") 24 | t.circle(-50) 25 | t.setheading(270) 26 | t.forward(50) 27 | t.setheading(0) 28 | for i in range(24): 29 | t.forward(45) 30 | t.bk(45) 31 | t.left(15) 32 | t.setheading(90) 33 | t.forward(50) 34 | t.setheading(0) 35 | t.color("black") 36 | t.forward(200) 37 | t.right(90) 38 | t.forward(100) 39 | t.right(90) 40 | t.forward(400) 41 | t.right(90) 42 | t.forward(100) 43 | t.right(90) 44 | t.goto(0,200) 45 | rectangle("green") -------------------------------------------------------------------------------- /PYTHON GUI/progress_bar.py: -------------------------------------------------------------------------------- 1 | ''' 2 | Program to print custom progress bar 3 | ''' 4 | import time 5 | import sys 6 | 7 | 8 | def main(): 9 | ''' 10 | main function that does all the work using sys and time libraries 11 | ''' 12 | bar_width = 50 13 | 14 | sys.stdout.write("[%s]" % ('-' * bar_width)) 15 | sys.stdout.flush() 16 | sys.stdout.write('\b' * (bar_width + 1)) 17 | 18 | for _ in range(bar_width): 19 | time.sleep(0.1) 20 | sys.stdout.write('>') 21 | sys.stdout.flush() 22 | 23 | sys.stdout.write(']\n') 24 | time.sleep(1) 25 | print('Progress Completed') 26 | 27 | 28 | if __name__ == '__main__': 29 | main() 30 | -------------------------------------------------------------------------------- /PYTHON GUI/snakeWaterGun.py: -------------------------------------------------------------------------------- 1 | # Snake Water Gun or Rock Paper Scissor. 2 | import random 3 | 4 | def gameWin(comp,you): 5 | # If two value are equal declare a tie. 6 | if comp == you: 7 | return None 8 | # Check for all possibilities when computer chooses s. 9 | elif comp=='s': 10 | if you == 'w': 11 | return False 12 | else: 13 | return True 14 | # Check for all possibilities when computer chooses w. 15 | elif comp=='w': 16 | if you == 'g': 17 | return False 18 | else: 19 | return True 20 | # Check for all possibilities when computer chooses g. 21 | elif comp=='g': 22 | if you == 's': 23 | return False 24 | else: 25 | return True 26 | 27 | 28 | randNo = random.randint(1,3) 29 | if randNo==1: 30 | comp = 's' 31 | elif randNo==2: 32 | comp = 'w' 33 | else: 34 | comp = 'g' 35 | 36 | you = input("Player's Turn: Snake(s) , water(w) or gun(g) ? : ") 37 | 38 | a=gameWin(comp,you) 39 | 40 | print(f"\nYou choose {you}\n") 41 | print(f"computer choose {comp}\n") 42 | 43 | if a==None: 44 | print("Game Draw....") 45 | elif a==False: 46 | print("Computer Win !!") 47 | elif a==True: 48 | print("You win !!") 49 | -------------------------------------------------------------------------------- /PYTHON GUI/typing-speed-test.py: -------------------------------------------------------------------------------- 1 | from tkinter import * 2 | from timeit import default_timer as timer 3 | import random 4 | 5 | window = Tk() 6 | 7 | window.geometry("450x200") 8 | 9 | x = 0 10 | 11 | def game(): 12 | global x 13 | if x == 0: 14 | window.destroy() 15 | x = x+1 16 | 17 | def check_result(): 18 | if entry.get() == words[word]: 19 | 20 | end = timer() 21 | 22 | print(end-start) 23 | else: 24 | print("Wrong Input") 25 | 26 | words = ['programming', 'coding', 'algorithm', 27 | 'systems', 'python', 'software'] 28 | 29 | word = random.randint(0, (len(words)-1)) 30 | 31 | start = timer() 32 | windows = Tk() 33 | windows.geometry("450x200") 34 | 35 | x2 = Label(windows, text=words[word], font="times 20") 36 | 37 | x2.place(x=150, y=10) 38 | x3 = Label(windows, text="Start Typing", font="times 20") 39 | x3.place(x=10, y=50) 40 | 41 | entry = Entry(windows) 42 | entry.place(x=280, y=55) 43 | 44 | b2 = Button(windows, text="Done", 45 | command=check_result, width=12, bg='grey') 46 | b2.place(x=150, y=100) 47 | 48 | b3 = Button(windows, text="Try Again", 49 | command=game, width=12, bg='grey') 50 | b3.place(x=250, y=100) 51 | windows.mainloop() 52 | 53 | 54 | x1 = Label(window, text="Lets start playing..", font="times 20") 55 | x1.place(x=10, y=50) 56 | 57 | b1 = Button(window, text="Go", command=game, width=12, bg='grey') 58 | b1.place(x=150, y=100) 59 | 60 | window.mainloop() 61 | -------------------------------------------------------------------------------- /Paint GUI and Digit Recognizer/img/abc: -------------------------------------------------------------------------------- 1 | hi 2 | -------------------------------------------------------------------------------- /Paint GUI and Digit Recognizer/img/img_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Paint GUI and Digit Recognizer/img/img_0.png -------------------------------------------------------------------------------- /Paint GUI and Digit Recognizer/img/img_0.pngimg_0.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Paint GUI and Digit Recognizer/img/img_0.pngimg_0.png -------------------------------------------------------------------------------- /Paint GUI and Digit Recognizer/mnist.h5: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Paint GUI and Digit Recognizer/mnist.h5 -------------------------------------------------------------------------------- /Python Basic Programs/8ball.py: -------------------------------------------------------------------------------- 1 | import random 2 | #future: name can be changed to input to get a name from the users input 3 | name = "YourName" 4 | #future: question as above can be redone to ask user 5 | question="Are we living in a simulation?" 6 | #sets up empty string for answer is then populated with the elif statements 7 | answer="" 8 | #random number assigner between 1 and 9 9 | random_number =random.randint(1,9) 10 | 11 | #print(random_number) 12 | print(name + " asks: " + question) 13 | if name =="": 14 | print("Question" + question) 15 | if question=="": 16 | print("Error no question asked") 17 | if random_number==1: 18 | answer="Yes - definitely." 19 | elif random_number==2: 20 | answer="It is decidedly so." 21 | elif random_number==3: 22 | answer="Without a doubt." 23 | elif random_number==4: 24 | answer="Reply hazy, try again." 25 | elif random_number==5: 26 | answer="Ask again later." 27 | elif random_number==6: 28 | answer="Better not tell you now." 29 | elif random_number==7: 30 | answer="My sources say no." 31 | elif random_number==8: 32 | answer="Outlook not so good." 33 | elif random_number==9: 34 | answer="Very doubtful." 35 | 36 | else: 37 | print("Error") 38 | 39 | print("Magic 8 Ball's Answer: " + answer) -------------------------------------------------------------------------------- /Python Basic Programs/Aerial-distance-calculator.py: -------------------------------------------------------------------------------- 1 | from geopy.geocoders import Nominatim 2 | from geopy import distance 3 | 4 | geodecoder = Nominatim(user_agent="python") 5 | 6 | print(""" 7 | WELCOME TO AERIAL DISTANCE CALCULATOR! 8 | """) 9 | 10 | location1 = input("\tEnter your current location : ") 11 | location2 = input("\tEnter your destination : ") 12 | 13 | coordinates1 = geodecoder.geocode(location1) 14 | coordinates2 = geodecoder.geocode(location2) 15 | 16 | lat1 = coordinates1.latitude 17 | lon1 = coordinates1.longitude 18 | lat2 = coordinates2.latitude 19 | lon2 = coordinates2.longitude 20 | 21 | starting = (lat1, lon1) 22 | destination = (lat2, lon2) 23 | 24 | dist = distance.distance(starting, destination) 25 | diststr = str(dist) 26 | accdist = diststr.split(".", 2)[0] 27 | print(f"\n\tYour aerial distance would b around {accdist} km (approx).") 28 | -------------------------------------------------------------------------------- /Python Basic Programs/Age_Calculator.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf-8 -*- 2 | import time 3 | from calendar import isleap 4 | 5 | # judge the leap year 6 | def judge_leap_year(year): 7 | if isleap(year): 8 | return True 9 | else: 10 | return False 11 | 12 | 13 | # returns the number of days in each month 14 | def month_days(month, leap_year): 15 | if month in [1, 3, 5, 7, 8, 10, 12]: 16 | return 31 17 | elif month in [4, 6, 9, 11]: 18 | return 30 19 | elif month == 2 and leap_year: 20 | return 29 21 | elif month == 2 and (not leap_year): 22 | return 28 23 | 24 | 25 | name = input("input your name: ") 26 | age = input("input your age: ") 27 | localtime = time.localtime(time.time()) 28 | 29 | year = int(age) 30 | month = year * 12 + localtime.tm_mon 31 | day = 0 32 | 33 | begin_year = int(localtime.tm_year) - year 34 | end_year = begin_year + year 35 | 36 | # calculate the days 37 | for y in range(begin_year, end_year): 38 | if (judge_leap_year(y)): 39 | day = day + 366 40 | else: 41 | day = day + 365 42 | 43 | leap_year = judge_leap_year(localtime.tm_year) 44 | for m in range(1, localtime.tm_mon): 45 | day = day + month_days(m, leap_year) 46 | 47 | day = day + localtime.tm_mday 48 | print("%s's age is %d years or " % (name, year), end="") 49 | print("%d months or %d days" % (month, day)) 50 | -------------------------------------------------------------------------------- /Python Basic Programs/ArmstrongNumber.py: -------------------------------------------------------------------------------- 1 | # Python program to check if the number is an Armstrong number or not 2 | 3 | # take input from the user 4 | num = int(input("Enter a number: ")) 5 | 6 | # initialize sum 7 | sum = 0 8 | 9 | # find the sum of the cube of each digit 10 | temp = num 11 | while temp > 0: 12 | digit = temp % 10 13 | sum += digit ** 3 14 | temp //= 10 15 | 16 | # display the result 17 | if num == sum: 18 | print(num,"is an Armstrong number") 19 | else: 20 | print(num,"is not an Armstrong number") 21 | -------------------------------------------------------------------------------- /Python Basic Programs/BMI_Calculator.py: -------------------------------------------------------------------------------- 1 | # Write your height in meters 2 | 3 | height = float(input("Enter your height in meters: ")) 4 | print(height) 5 | 6 | # Write your weight in kilograms (Kg) 7 | 8 | weight = float(input("Enter your weight in kilograms : ")) 9 | print(weight) 10 | bmi = round(weight / (height * height) , 2) 11 | 12 | print("") 13 | print("Your body mass index is : ", bmi) 14 | print("") 15 | if(bmi < 18.5): 16 | print("You are under weight") 17 | 18 | if(bmi > 18.5 and bmi <= 24.9): 19 | print("You have a normal weight") 20 | 21 | if(bmi >= 25 and bmi <= 29.9): 22 | print("You are over weight") 23 | 24 | if(bmi >= 30 and bmi <= 34.9): 25 | print("You are obese (class I)") 26 | 27 | if(bmi >= 35 and bmi <= 39.9): 28 | print("You are obese (class II)") 29 | 30 | if(bmi >= 40): 31 | print("You are obese (class III)") 32 | 33 | if(bmi >= 60): 34 | print("Seek urgent medical advice") -------------------------------------------------------------------------------- /Python Basic Programs/DiceRollingSimulator.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | 4 | x = "y" 5 | 6 | while x == "y": 7 | 8 | # Generates a random number 9 | # between 1 and 6 (including 10 | # both 1 and 6) 11 | no = random.randint(1,6) 12 | 13 | if no == 1: 14 | print("[-----]") 15 | print("[ ]") 16 | print("[ 0 ]") 17 | print("[ ]") 18 | print("[-----]") 19 | if no == 2: 20 | print("[-----]") 21 | print("[ 0 ]") 22 | print("[ ]") 23 | print("[ 0 ]") 24 | print("[-----]") 25 | if no == 3: 26 | print("[-----]") 27 | print("[ ]") 28 | print("[0 0 0]") 29 | print("[ ]") 30 | print("[-----]") 31 | if no == 4: 32 | print("[-----]") 33 | print("[0 0]") 34 | print("[ ]") 35 | print("[0 0]") 36 | print("[-----]") 37 | if no == 5: 38 | print("[-----]") 39 | print("[0 0]") 40 | print("[ 0 ]") 41 | print("[0 0]") 42 | print("[-----]") 43 | if no == 6: 44 | print("[-----]") 45 | print("[0 0 0]") 46 | print("[ ]") 47 | print("[0 0 0]") 48 | print("[-----]") 49 | 50 | x=input("press y to roll again and n to exit:") 51 | print("\n") 52 | 53 | -------------------------------------------------------------------------------- /Python Basic Programs/Fibonacci.py: -------------------------------------------------------------------------------- 1 | def Fibbo_Sequence_Generator(): 2 | # Generates a fibonacci sequence with the size of ngi 3 | runFib = True 4 | while(runFib): 5 | n = int(input('How many numbers do you need? ')) 6 | if n > 0 : 7 | runFib = False 8 | series = [1] 9 | 10 | while len(series) < n: 11 | if len(series) == 1: 12 | series.append(1) 13 | else: 14 | series.append(series[-1] + series[-2]) 15 | 16 | for i in range(len(series)): # Convert the numbers to strings 17 | series[i] = str(series[i]) 18 | else: 19 | print('enter a valid number') 20 | 21 | return(', '.join(series)) # Return the sequence seperated by commas 22 | 23 | print(Fibbo_Sequence_Generator()) -------------------------------------------------------------------------------- /Python Basic Programs/FizzBuzz.py: -------------------------------------------------------------------------------- 1 | # Write a program that prints the numbers from 1 to 100. 2 | # But for multiples of three print “Fizz” instead of the number 3 | # and for the multiples of five print “Buzz”. 4 | # For numbers which are multiples of both three and five print “FizzBuzz". 5 | 6 | for i in range(1, 101): 7 | if i % 3 == 0 and i % 5 == 0: 8 | print ('FizzBuzz') 9 | elif i % 3 == 0: 10 | print ('Fizz') 11 | elif i % 5 == 0: 12 | print ('Buzz') 13 | else: 14 | print (str(i)) -------------------------------------------------------------------------------- /Python Basic Programs/Group Anagrams.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def groupAnagrams(self, strs): 3 | """ 4 | :type strs: List[str] 5 | :rtype: List[List[str]] 6 | """ 7 | dict1= {} 8 | for word in strs: 9 | sorted_word = "".join(sorted(word)) 10 | if sorted_word not in dict1: 11 | dict1[sorted_word]=[word] 12 | else: 13 | dict1[sorted_word].append(word) 14 | result = [] 15 | for words in dict1.values(): 16 | result.append(words) 17 | return result 18 | 19 | -------------------------------------------------------------------------------- /Python Basic Programs/Guessing Game Challenge.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | num = random.randint(1,100) 4 | 5 | print("WELCOME TO GUESS ME!") 6 | print("I'm thinking of a number between 1 and 100") 7 | print("If your guess is more than 10 away from my number, I'll tell you you're COLD") 8 | print("If your guess is within 10 of my number, I'll tell you you're WARM") 9 | print("If your guess is farther than your most recent guess, I'll say you're getting COLDER") 10 | print("If your guess is closer than your most recent guess, I'll say you're getting WARMER") 11 | print("LET'S PLAY!") 12 | 13 | guesses = [0] 14 | 15 | while True: 16 | 17 | guess = int(input("I'm thinking of a number between 1 and 100.\n What is your guess? ")) 18 | 19 | if guess < 1 or guess > 100: 20 | print('OUT OF BOUNDS! Please try again: ') 21 | continue 22 | 23 | if guess == num: 24 | print(f'CONGRATULATIONS, YOU GUESSED IT IN ONLY {len(guesses)} GUESSES!!') 25 | break 26 | 27 | guesses.append(guess) 28 | 29 | if guesses[-2]: 30 | if abs(num-guess) < abs(num-guesses[-2]): 31 | print('WARMER!') 32 | else: 33 | print('COLDER!') 34 | 35 | else: 36 | if abs(num-guess) <= 10: 37 | print('WARM!') 38 | else: 39 | print('COLD!') -------------------------------------------------------------------------------- /Python Basic Programs/High_outliers_and_Low_outliers.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | print("Enter numbers") 4 | arr = list(map(int,input().split())) 5 | 6 | #Interquartile Range 7 | data = np.array(arr) 8 | q3, q1 = np.percentile(data, [75 ,25]) 9 | iqr = q3 - q1 10 | print("Interquartile Range is %.2f"%(iqr)) 11 | 12 | #low_outliers_margin 13 | value1 = q1 - 1.5*iqr 14 | #high_outliers_margin 15 | value2 = q3 + 1.5*iqr 16 | 17 | #total_no_of_low_and_high_outliers 18 | low_outliers = 0 19 | high_outliers = 0 20 | print(value1) 21 | 22 | for i in arr: 23 | if i < value1: 24 | low_outliers += 1 25 | if i > value2: 26 | high_outliers += 1 27 | 28 | print("Total numbers below low outliers are ", low_outliers) 29 | print("Total numbers below high outliers are ", high_outliers) -------------------------------------------------------------------------------- /Python Basic Programs/Information_Fusion: -------------------------------------------------------------------------------- 1 | def XOR(x, y): 2 | return '1' if x != y else '0' 3 | 4 | def _fusion(array): 5 | for i in range(len(array) - 1): 6 | information_fusion = [] 7 | for j in range(len(array[0])): 8 | information_fusion += [XOR(array[i][j], array[i + 1][j]) if i == 0 else XOR(information_fusion[0][j], array[i + 1][j])] 9 | return ''.join(information_fusion).split() 10 | -------------------------------------------------------------------------------- /Python Basic Programs/Lapindromes.py: -------------------------------------------------------------------------------- 1 | t=int(input()) 2 | for i in range(t): 3 | n=input() 4 | len1 = len(n) 5 | if len1 % 2 == 0: 6 | b,c=n[:len1//2],n[len1//2:] 7 | else: 8 | b,c=n[:len1//2], n[len1//2+1:] 9 | if sorted(b) == sorted(c): 10 | print("YES") 11 | else: 12 | print("NO") 13 | -------------------------------------------------------------------------------- /Python Basic Programs/Longest-Palindromic-Substring.py: -------------------------------------------------------------------------------- 1 | class Solution(object): 2 | def longestPalindrome(self, s): 3 | 4 | def helper(s, l, r): 5 | while l >= 0 and r < len(s) and s[l] == s[r]: 6 | l -= 1 7 | r += 1 8 | l += 1 9 | r -= 1 10 | 11 | return ((r - l) + 1, l, r) 12 | 13 | longest = left = right = 0 14 | 15 | for i in range(len(s)): 16 | for j in range(2): 17 | length, l, r = helper(s, i, i + j) 18 | if length > longest: 19 | longest = length 20 | right = r 21 | left = l 22 | 23 | return s[left : right + 1] 24 | -------------------------------------------------------------------------------- /Python Basic Programs/Password Checker.py: -------------------------------------------------------------------------------- 1 | import re 2 | print("YOUR PASSWORD SHOULD HAVE ATLEAST A NUMBER AND A LOWER CASE") 3 | print("IT SHOULD BE ATLEAST 10 CHARACTERS LONG") 4 | print("IT SHOULD START WITH AN UPPER CASE AND END WITH A SPECIAL CHARACTER") 5 | password = input("ENTER YOUR PASSWORD: ") 6 | length = len(password) 7 | lower_case = re.search("[a-z]+",password) 8 | upper_case = re.search("[A-Z]+",password[0]) 9 | special_char = re.search(r"\W+",password[length-1]) 10 | number = re.search("\d+",password) 11 | if(lower_case == None): 12 | print("INVALID PASSWORD. ATLEAST ONE LOWER CASE REQUIRED") 13 | if(upper_case == None): 14 | print("INVALID PASSWORD. UPPER CASE REQUIRED IN FIRST POSITION") 15 | if(special_char == None): 16 | print("INVALID PASSWORD. SPECIAL CHARACTER REQUIRED IN LAST POSITION") 17 | if(number == None): 18 | print("INVALID PASSWORD. ATLEAST ONE NUMBER REQUIRED") 19 | if(length<10): 20 | print("INVALID PASSWORD. ATLEAST 10 CHARACTERS REQUIRED") 21 | if((lower_case!=None) and (upper_case!=None) and (special_char!=None) and (number!= None) and (length>=10)): 22 | print("VALID PASSWORD. HENCE ACCEPTED") 23 | -------------------------------------------------------------------------------- /Python Basic Programs/Quadratic Equation Solver.py: -------------------------------------------------------------------------------- 1 | def roots_quad_eqn(a,b,c): 2 | d = (b**2)-(4*a*c) 3 | if d == 0: 4 | x1 = (-b)/(2*a) 5 | x2 = x1 6 | print("THE EQUATION HAS REAL & EQUAL ROOTS... ",x1,"and",x2) 7 | return(x1,x2,0,0,True) 8 | elif d>0: 9 | x1 = (-b+d)/(2*a) 10 | x2 = (-b-d)/(2*a) 11 | print("THE EQUATION HAS REAL & DISTINCT ROOTS... ",x1,"and",x2) 12 | return(x1,x2,0,0,True) 13 | else: 14 | img = (-d)**(1/2) 15 | real = (-b)/(2*a) 16 | print("THE EQUATION HAS IMAGINARY & CONJUGATE ROOTS... ",real,"+",img,"i and",real,"-",img,"i") 17 | return(real,real,img,img,False) 18 | a = float(input("ENTER THE COEFFICIENT OF x^2: ")) 19 | b = float(input("ENTER THE COEFFICIENT OF x^1: ")) 20 | c = float(input("ENTER THE COEFFICIENT OF x^0: ")) 21 | roots_quad_eqn(a,b,c) 22 | -------------------------------------------------------------------------------- /Python Basic Programs/Rock Paper Scissors.py: -------------------------------------------------------------------------------- 1 | import random 2 | game_list=['Rock', 'rock', 'Paper', 'paper', 'Scissors', 'scissors'] 3 | computer=c=0 4 | command=p=0 5 | print("Score: Computer " +str(c)+ " Player " +str(p)) 6 | # the loop 7 | run=True 8 | while run: 9 | computer_choice=random.choice(game_list) 10 | command=input('Rock, Paper, Scissors or Quit: ') 11 | if command.lower() == computer_choice.lower(): 12 | print("Tie") 13 | elif command == 'rock': 14 | if computer_choice == 'scissors': 15 | print("Player won!") 16 | p+=1 17 | else: 18 | print("Computer won!") 19 | c+=1 20 | elif command == 'scissors': 21 | if computer_choice == 'paper': 22 | print("Player won!") 23 | p+=1 24 | else: 25 | print("Computer won!") 26 | c+=1 27 | elif command == 'paper': 28 | if computer_choice == 'rock': 29 | print("Player won!") 30 | p+=1 31 | else: 32 | print("Computer won!") 33 | c+=1 34 | elif command == 'quit': 35 | print("Thank you for playing!!") 36 | break 37 | else: 38 | print("Wrong command!") 39 | print("Player: " + command.capitalize()) 40 | print("Computer: " + computer_choice.capitalize()) 41 | print("") 42 | print("Score: Computer " + str(c) + " Player " + str(p)) 43 | print("") 44 | -------------------------------------------------------------------------------- /Python Basic Programs/Shell_sort.py: -------------------------------------------------------------------------------- 1 | 2 | def shellSort(array, n): 3 | 4 | interval = n // 2 5 | while interval > 0: 6 | for i in range(interval, n): 7 | temp = array[i] 8 | j = i 9 | while j >= interval and array[j - interval] > temp: 10 | array[j] = array[j - interval] 11 | j -= interval 12 | 13 | array[j] = temp 14 | interval //= 2 15 | 16 | 17 | data = [9, 8, 3, 7, 5, 6, 4, 1] 18 | size = len(data) 19 | shellSort(data, size) 20 | print('Sorted Array in Ascending Order:') 21 | print(data) 22 | -------------------------------------------------------------------------------- /Python Basic Programs/Turtle_animations/hexagon.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | import colorsys 3 | t = turtle.Turtle() 4 | s = turtle.Screen().bgcolor('black') 5 | t.color('white') 6 | t.speed(0) 7 | t.width(5) 8 | n = 200 9 | h = 0 10 | for i in range(300): 11 | t.right(59) 12 | for c in range(1): 13 | t.forward(i*2) 14 | c= colorsys.hsv_to_rgb(h,1,0.8) 15 | h += i/n 16 | t.color(c) 17 | turtle.exitonclick() 18 | -------------------------------------------------------------------------------- /Python Basic Programs/Turtle_animations/indianFlag.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | from turtle import* 3 | 4 | #screen for output 5 | screen = turtle.Screen() 6 | 7 | # Defining a turtle Instance 8 | t = turtle.Turtle() 9 | speed(0) 10 | 11 | # initially penup() 12 | t.penup() 13 | t.goto(-400, 250) 14 | t.pendown() 15 | 16 | # Orange Rectangle 17 | #white rectangle 18 | t.color("orange") 19 | t.begin_fill() 20 | t.forward(800) 21 | t.right(90) 22 | t.forward(167) 23 | t.right(90) 24 | t.forward(800) 25 | t.end_fill() 26 | t.left(90) 27 | t.forward(167) 28 | 29 | # Green Rectangle 30 | t.color("green") 31 | t.begin_fill() 32 | t.forward(167) 33 | t.left(90) 34 | t.forward(800) 35 | t.left(90) 36 | t.forward(167) 37 | t.end_fill() 38 | 39 | # Big Blue Circle 40 | t.penup() 41 | t.goto(70, 0) 42 | t.pendown() 43 | t.color("navy") 44 | t.begin_fill() 45 | t.circle(70) 46 | t.end_fill() 47 | 48 | # Big White Circle 49 | t.penup() 50 | t.goto(60, 0) 51 | t.pendown() 52 | t.color("white") 53 | t.begin_fill() 54 | t.circle(60) 55 | t.end_fill() 56 | 57 | # Mini Blue Circles 58 | t.penup() 59 | t.goto(-57, -8) 60 | t.pendown() 61 | t.color("navy") 62 | for i in range(24): 63 | t.begin_fill() 64 | t.circle(3) 65 | t.end_fill() 66 | t.penup() 67 | t.forward(15) 68 | t.right(15) 69 | t.pendown() 70 | 71 | # Small Blue Circle 72 | t.penup() 73 | t.goto(20, 0) 74 | t.pendown() 75 | t.begin_fill() 76 | t.circle(20) 77 | t.end_fill() 78 | # Spokes 79 | t.penup() 80 | t.goto(0, 0) 81 | t.pendown() 82 | t.pensize(2) 83 | for i in range(24): 84 | t.forward(60) 85 | t.backward(60) 86 | t.left(15) 87 | 88 | #to hold the 89 | #output window 90 | turtle.done() -------------------------------------------------------------------------------- /Python Basic Programs/Turtle_animations/star.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | color = ("red" , "yellow" , "green" ,"cyan" , "blue" , "white") 3 | t = turtle.Turtle() 4 | screen= turtle.Screen() 5 | screen.bgcolor("black") 6 | t.speed(30) 7 | for i in range(100): 8 | t.color(color[i%6]) 9 | t.forward(i*4) 10 | t.left(150) 11 | t.width(2) 12 | -------------------------------------------------------------------------------- /Python Basic Programs/Turtle_animations/trihexagonal.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | bgcolor('black') 3 | speed(0) 4 | pencolor('white') 5 | def des() : 6 | for i in range(3): 7 | for j in range(5) : 8 | fd(60) 9 | right(60) 10 | fd(60) 11 | left(60) 12 | fd(60) 13 | 14 | for i in range(36): 15 | des() 16 | right(10) 17 | 18 | done() 19 | -------------------------------------------------------------------------------- /Python Basic Programs/Turtle_animations/viruspattern.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | speed(10) 3 | color('cyan') 4 | bgcolor('black') 5 | b = 200 6 | while b > 0 : 7 | left(b) 8 | forward(b*3) 9 | b = b-1 -------------------------------------------------------------------------------- /Python Basic Programs/ValidSudoku.py: -------------------------------------------------------------------------------- 1 | from collections import defaultdict 2 | 3 | def isValidSudoku(board): 4 | mat2 = {0:'0',1:'0',2:'0',3:'1',4:'1',5:'1',6:'2',7:'2',8:'2'} 5 | 6 | cheC = defaultdict(set) 7 | che = defaultdict(set) 8 | for i in range(9): 9 | temps = set() 10 | for j in range(9): 11 | num = board[i][j] 12 | 13 | if num != '.': 14 | if num in temps: 15 | return False 16 | temps.add(num) 17 | box = mat2[i]+mat2[j] 18 | if num in che[box]: 19 | return False 20 | che[box].add(num) 21 | if num in cheC[j]: 22 | return False 23 | cheC[j].add(num) 24 | 25 | 26 | return True 27 | 28 | board = [["5","3",".",".","7",".",".",".","."] 29 | ,["6",".",".","1","9","5",".",".","."] 30 | ,[".","9","8",".",".",".",".","6","."] 31 | ,["8",".",".",".","6",".",".",".","3"] 32 | ,["4",".",".","8",".","3",".",".","1"] 33 | ,["7",".",".",".","2",".",".",".","6"] 34 | ,[".","6",".",".",".",".","2","8","."] 35 | ,[".",".",".","4","1","9",".",".","5"] 36 | ,[".",".",".",".","8",".",".","7","9"]] 37 | 38 | print(isValidSudoku(board)) -------------------------------------------------------------------------------- /Python Basic Programs/acid_solution.py: -------------------------------------------------------------------------------- 1 | #Program that calculates the pH of any solution.# 2 | 3 | indice_acid = float(input()) 4 | 5 | while indice_acid != -1: 6 | if indice_acid < 7: 7 | print("ACIDA") 8 | if indice_acid == 7: 9 | print("NEUTRA") 10 | if indice_acid > 7: 11 | print("BASICA") 12 | indice_acid = float(input()) 13 | -------------------------------------------------------------------------------- /Python Basic Programs/calander.py: -------------------------------------------------------------------------------- 1 | # program 2 (updated) 2 | 3 | # Program to show the calender of a specific month of a year 4 | 5 | # First import the calendar module 6 | import calendar 7 | # ask of month and year 8 | yy = int(input("Enter the year:")) 9 | mm = int(input("Enter the month:")) 10 | # display the calendar 11 | print(calendar.month(yy,mm)) 12 | -------------------------------------------------------------------------------- /Python Basic Programs/calculator.py: -------------------------------------------------------------------------------- 1 | def add(P, Q): 2 | # This function is used for adding two numbers 3 | return P + Q 4 | def subtract(P, Q): 5 | # This function is used for subtracting two numbers 6 | return P - Q 7 | def multiply(P, Q): 8 | # This function is used for multiplying two numbers 9 | return P * Q 10 | def divide(P, Q): 11 | # This function is used for dividing two numbers 12 | return P / Q 13 | 14 | print ("Please select the operation.") 15 | print ("a. Add") 16 | print ("b. Subtract") 17 | print ("c. Multiply") 18 | print ("d. Divide") 19 | 20 | choice = input("Please enter choice (a/ b/ c/ d): ") 21 | 22 | num_1 = int (input ("Please enter the first number: ")) 23 | num_2 = int (input ("Please enter the second number: ")) 24 | 25 | if choice == 'a': 26 | print (num_1, " + ", num_2, " = ", add(num_1, num_2)) 27 | 28 | elif choice == 'b': 29 | print (num_1, " - ", num_2, " = ", subtract(num_1, num_2)) 30 | 31 | elif choice == 'c': 32 | print (num_1, " * ", num_2, " = ", multiply(num_1, num_2)) 33 | elif choice == 'd': 34 | print (num_1, " / ", num_2, " = ", divide(num_1, num_2)) 35 | else: 36 | print ("This is an invalid input") 37 | -------------------------------------------------------------------------------- /Python Basic Programs/celsiusToFahrenheit.py: -------------------------------------------------------------------------------- 1 | celsius = float(input("Enter the temperature in celsius: ")) 2 | 3 | fahrenheit = (celsius * 1.8) + 32 4 | print('%0.1f degree Celsius is equal to %0.1f degree Fahrenheit' %(celsius,fahrenheit)) 5 | -------------------------------------------------------------------------------- /Python Basic Programs/count_prime_in_defined_interval.py: -------------------------------------------------------------------------------- 1 | # Tanggal: 29 September 2022 2 | # Deskripsi: Menentukan banyak bilangan prima dan bilangan prima terbesar dari rentang bilangan bulat yang di-input oleh user 3 | 4 | # KAMUS 5 | # a, b, max_prime, count, i, k : int 6 | # prime : bool 7 | 8 | # ALGORITMA 9 | # input 10 | a = int(input("Masukkan a: ")) 11 | b = int(input("Masukkan b: ")) 12 | 13 | # set initial condition 14 | max_prime = 0 15 | count = 0 16 | 17 | for i in range(a, b+1): # start loop from a to b 18 | prime = True # set the initial prime condition to true 19 | k = 2 # k starts from 2 because dividing by 1 isn't necessary 20 | while(prime and k <= i): # will loop from 2 to i or until prime is false 21 | if i % k == 0 and k != i: prime = False # set the prime condition to false if it can be divided by k 22 | k += 1 # don't forget to increment k so that the loop can be stopped at some point i.e k = i+1 23 | 24 | if prime and i != 1: # 1 is not prime 25 | max_prime = i 26 | count += 1 27 | 28 | # output 29 | if count > 0: 30 | print("Banyaknya bilangan prima pada selang [{}, {}] adalah {}. Bilangan prima terbesar di selang tersebut adalah {}.".format(a, b, count, max_prime)) 31 | 32 | else: 33 | print("Tidak ditemukan bilangan prima pada selang [{}, {}]".format(a, b)) 34 | -------------------------------------------------------------------------------- /Python Basic Programs/counting_sort.py: -------------------------------------------------------------------------------- 1 | 2 | def countingSort(array): 3 | size = len(array) 4 | output = [0] * size 5 | 6 | count = [0] * 10 7 | 8 | 9 | for i in range(0, size): 10 | count[array[i]] += 1 11 | 12 | 13 | for i in range(1, 10): 14 | count[i] += count[i - 1] 15 | 16 | i = size - 1 17 | while i >= 0: 18 | output[count[array[i]] - 1] = array[i] 19 | count[array[i]] -= 1 20 | i -= 1 21 | 22 | 23 | for i in range(0, size): 24 | array[i] = output[i] 25 | 26 | 27 | data = [4, 2, 2, 8, 3, 3, 1] 28 | countingSort(data) 29 | print("Sorted Array in Ascending Order: ") 30 | print(data) 31 | -------------------------------------------------------------------------------- /Python Basic Programs/diagonaldifference.py: -------------------------------------------------------------------------------- 1 | 2 | def diagonalDifference(arr): 3 | right_dia_sum = 0 4 | left_dia_sum = 0 5 | for i in range(len(arr)): 6 | #right traversing diagonal elements have the same row and column as index 7 | right_dia_sum += arr[i][i] 8 | # left traversing diagonal elements will have their row number increasing and column number decreaseing or vice-versa 9 | left_dia_sum += arr[i][(len(arr)-1)-i] 10 | return abs(left_dia_sum - right_dia_sum) 11 | -------------------------------------------------------------------------------- /Python Basic Programs/diamond pattern.py: -------------------------------------------------------------------------------- 1 | # Program to print diamond shape 2 | # github.com/djharshit 3 | 4 | n = eval(input("Enter a number of n: ")) 5 | for i in range(n): 6 | print(" "*(n-i), "*"*(i*2+1)) 7 | 8 | for i in range(n-2, -1, -1): 9 | print(" "*(n-i),"*"*(i*2+1)) 10 | 11 | -------------------------------------------------------------------------------- /Python Basic Programs/dicestimulator.py: -------------------------------------------------------------------------------- 1 | import random 2 | print("This is a Dice Stimulator") 3 | x = "y" 4 | 5 | while x == "y": 6 | number = random.randint(1,6) 7 | 8 | if number == 1: 9 | print("----------") 10 | print("| |") 11 | print("| O |") 12 | print("| |") 13 | print("----------") 14 | if number == 2: 15 | print("----------") 16 | print("| |") 17 | print("| O O |") 18 | print("| |") 19 | print("----------") 20 | if number == 3: 21 | print("----------") 22 | print("| O |") 23 | print("| O |") 24 | print("| O |") 25 | print("----------") 26 | if number == 4: 27 | print("----------") 28 | print("| O O |") 29 | print("| |") 30 | print("| O O |") 31 | print("----------") 32 | if number == 5: 33 | print("----------") 34 | print("| O O |") 35 | print("| O |") 36 | print("| O O |") 37 | print("----------") 38 | if number == 6: 39 | print("----------") 40 | print("| O O |") 41 | print("| O O |") 42 | print("| O O |") 43 | print("----------") 44 | x = input("Press y to roll again") 45 | 46 | -------------------------------------------------------------------------------- /Python Basic Programs/email_pass_generation.py: -------------------------------------------------------------------------------- 1 | import random as rand 2 | import string 3 | 4 | def get_random_string(length): 5 | letters = string.ascii_lowercase 6 | numbers = string.digits 7 | result_str = ''.join(rand.choice(numbers+letters) for i in range(length)) 8 | return (result_str) 9 | 10 | first=input("Enter the First Name:") 11 | last=input("Enter the last Name:") 12 | dept=input("Enter the department:") 13 | domain="@abc.com" 14 | email=first+"."+last+"."+dept+domain 15 | length=7 16 | pas=get_random_string(length) 17 | print(email) 18 | print(pas) -------------------------------------------------------------------------------- /Python Basic Programs/factorial.py: -------------------------------------------------------------------------------- 1 | # Python program to find the factorial of a number provided by the user. 2 | 3 | # change the value for a different result 4 | num = 7 5 | 6 | # To take input from the user 7 | #num = int(input("Enter a number: ")) 8 | 9 | factorial = 1 10 | 11 | # check if the number is negative, positive or zero 12 | if num < 0: 13 | print("Sorry, factorial does not exist for negative numbers") 14 | elif num == 0: 15 | print("The factorial of 0 is 1") 16 | else: 17 | for i in range(1,num + 1): 18 | factorial = factorial*i 19 | print("The factorial of",num,"is",factorial) 20 | -------------------------------------------------------------------------------- /Python Basic Programs/fibo.py: -------------------------------------------------------------------------------- 1 | n = int(input("Enter How Many Number Of Fibonachi Serise Do You Want : ")) 2 | fibo = lambda x:x if x < 2 else fibo(x-2) + fibo(x-1) 3 | print(list(map(fibo,range(1,n+1)))) 4 | -------------------------------------------------------------------------------- /Python Basic Programs/fibonacci.py: -------------------------------------------------------------------------------- 1 | def Fibbo_Sequence_Generator(): 2 | # Generates a fibonacci sequence with the size of ngi 3 | runFib = True 4 | while(runFib): 5 | n = int(input('How many numbers do you need? ')) 6 | if n > 0 : 7 | runFib = False 8 | series = [1] 9 | 10 | while len(series) < n: 11 | if len(series) == 1: 12 | series.append(1) 13 | else: 14 | series.append(series[-1] + series[-2]) 15 | 16 | for i in range(len(series)): # Convert the numbers to strings 17 | series[i] = str(series[i]) 18 | else: 19 | print('enter a valid number') 20 | 21 | return(', '.join(series)) # Return the sequence seperated by commas 22 | 23 | print(Fibbo_Sequence_Generator()) -------------------------------------------------------------------------------- /Python Basic Programs/hcf.py: -------------------------------------------------------------------------------- 1 | def calculate_hcf(x, y): 2 | if x > y: 3 | smaller = y 4 | else: 5 | smaller = x 6 | for i in range(1,smaller + 1): 7 | if((x % i == 0) and (y % i == 0)): 8 | hcf = i 9 | return hcf 10 | 11 | num1 = int(input("Enter first number: ")) 12 | num2 = int(input("Enter second number: ")) 13 | 14 | print("The H.C.F. of", num1,"and", num2,"is", calculate_hcf(num1, num2)) 15 | -------------------------------------------------------------------------------- /Python Basic Programs/heapSort.py: -------------------------------------------------------------------------------- 1 | # Python program for implementation of heap Sort 2 | 3 | # To heapify subtree rooted at index i. 4 | # n is size of heap 5 | def heapify(arr, n, i): 6 | largest = i # Initialize largest as root 7 | l = 2 * i + 1 # left = 2*i + 1 8 | r = 2 * i + 2 # right = 2*i + 2 9 | 10 | # See if left child of root exists and is 11 | # greater than root 12 | if l < n and arr[i] < arr[l]: 13 | largest = l 14 | 15 | # See if right child of root exists and is 16 | # greater than root 17 | if r < n and arr[largest] < arr[r]: 18 | largest = r 19 | 20 | # Change root, if needed 21 | if largest != i: 22 | arr[i],arr[largest] = arr[largest],arr[i] # swap 23 | 24 | # Heapify the root. 25 | heapify(arr, n, largest) 26 | 27 | # The main function to sort an array of given size 28 | def heapSort(arr): 29 | n = len(arr) 30 | 31 | # Build a maxheap. 32 | for i in range(n, -1, -1): 33 | heapify(arr, n, i) 34 | 35 | # One by one extract elements 36 | for i in range(n-1, 0, -1): 37 | arr[i], arr[0] = arr[0], arr[i] # swap 38 | heapify(arr, i, 0) 39 | 40 | # Driver code to test above 41 | arr = [ 12, 11, 13, 5, 6, 7] 42 | heapSort(arr) 43 | n = len(arr) 44 | print ("Sorted array is") 45 | for i in range(n): 46 | print ("%d" %arr[i]) 47 | -------------------------------------------------------------------------------- /Python Basic Programs/heart.py: -------------------------------------------------------------------------------- 1 | 2 | import turtle 3 | 4 | pen = turtle.Turtle() 5 | 6 | def curve(): 7 | for i in range(200): 8 | 9 | 10 | pen.right(1) 11 | pen.forward(1) 12 | 13 | def heart(): 14 | 15 | pen.fillcolor('red') 16 | 17 | 18 | pen.begin_fill() 19 | 20 | pen.left(140) 21 | pen.forward(113) 22 | 23 | curve() 24 | pen.left(120) 25 | 26 | 27 | curve() 28 | 29 | 30 | pen.forward(112) 31 | 32 | pen.end_fill() 33 | 34 | 35 | def txt(): 36 | 37 | pen.up() 38 | pen.setpos(-68, 95) 39 | 40 | pen.down() 41 | 42 | pen.color('lightgreen') 43 | 44 | print("Welcome to heart shape creator") 45 | heart() 46 | 47 | txt() 48 | 49 | pen.ht() 50 | -------------------------------------------------------------------------------- /Python Basic Programs/insertionsort.py: -------------------------------------------------------------------------------- 1 | def insertionSort(array): 2 | 3 | for step in range(1, len(array)): 4 | key = array[step] 5 | j = step - 1 6 | 7 | while j >= 0 and key < array[j]: 8 | array[j + 1] = array[j] 9 | j = j - 1 10 | 11 | # Place key at after the element just smaller than it. 12 | array[j + 1] = key 13 | 14 | 15 | data = [9, 5, 1, 4, 3] 16 | insertionSort(data) 17 | print('Sorted Array in Ascending Order:') 18 | print(data) 19 | -------------------------------------------------------------------------------- /Python Basic Programs/internetspeedtest.py: -------------------------------------------------------------------------------- 1 | import speedtest 2 | # pip install speedtest-cli 3 | 4 | def speedtester(): 5 | st = speedtest.Speedtest() 6 | 7 | print("Loading server list...\n") 8 | st.get_servers() 9 | print("Choosing best server...") 10 | best = st.get_best_server() 11 | print(f"Found: {best['host']} located in {best['country']}") 12 | 13 | option = int(input('''What speed do you want to test: 14 | 15 | 1) Download Speed 16 | 17 | 2) Upload Speed 18 | 19 | 3) Ping 20 | 21 | Your Choice: ''')) 22 | 23 | if option == 1: 24 | print("Performing download test...") 25 | downloadresult = st.download() 26 | print(f"Download speed: {downloadresult / 1024 / 1024: .2f} Mbit/s") 27 | 28 | elif option == 2: 29 | print("Performing upload test...") 30 | uploadresult = st.upload() 31 | print(f"Upload result : {uploadresult /1024 /1024:.2f} Mbit/s") 32 | 33 | elif option == 3: 34 | ping_result = st.results.ping 35 | print(f"Ping: {ping_result}ms") 36 | 37 | else: 38 | 39 | print("Please enter the correct choice !") 40 | 41 | 42 | if __name__ == "__main__": 43 | speedtester() -------------------------------------------------------------------------------- /Python Basic Programs/longest_common_substring.py: -------------------------------------------------------------------------------- 1 | # date: 01st October 2022 2 | 3 | def lcs(X, Y): 4 | m = len(X) 5 | n = len(Y) 6 | lcs_suff = [[0 for k in range(n+1)] for l in range(m+1)] 7 | length = 0 8 | 9 | for i in range(m + 1): 10 | for j in range(n + 1): 11 | if (i == 0 or j == 0): 12 | lcs_suff[i][j] = 0 13 | elif (X[i-1] == Y[j-1]): 14 | lcs_suff[i][j] = lcs_suff[i-1][j-1] + 1 15 | length = max(length, lcs_suff[i][j]) 16 | else: 17 | lcs_suff[i][j] = 0 18 | return length 19 | 20 | s1 = 'abcdefghi' 21 | s2 = 'bcdghijkl' 22 | 23 | 24 | print('Length of LCS :', lcs(s1, s2)) 25 | 26 | -------------------------------------------------------------------------------- /Python Basic Programs/mean_median_mode.py: -------------------------------------------------------------------------------- 1 | print("Enter numbers") 2 | arr = list(map(int,input().split())) 3 | 4 | #mean 5 | mean = sum(arr)/len(arr) 6 | print("mean is %.1f" % (mean)) 7 | 8 | #median 9 | arr.sort() 10 | mid = int(len(arr)/2) 11 | if len(arr) % 2 == 0: 12 | median = (arr[mid] + arr[mid-1]) / 2 13 | else: 14 | median = arr[mid] 15 | print("median is %.1f" % (median)) 16 | 17 | #mode 18 | mode = {} 19 | val = [] 20 | for i in arr: 21 | if i not in val: 22 | val.append(i) 23 | 24 | for i in val: 25 | mode[i]=arr.count(i) 26 | 27 | res = True 28 | test_val = list(mode.values())[0] 29 | for ele in mode: 30 | if mode[ele] != test_val: 31 | res = False 32 | break 33 | 34 | mode_value = 0 35 | if res == False: 36 | mode_value = max(mode, key= lambda x: mode[x]) 37 | 38 | if mode_value != 0: 39 | print("Mode is ", mode_value) 40 | else: 41 | print("No mode") -------------------------------------------------------------------------------- /Python Basic Programs/odd_no_square.py: -------------------------------------------------------------------------------- 1 | #Program to print the sum of the following series till the number of terms the user enters 2 | #1^2 + 3^2 + 5^2 + .... + n^2 3 | #eg. if rang = 3, the computer will calculate 1^2 + 3^2 + 5^2 4 | #eg. if rang = 5, the computer will calculate 1^2 + 3^2 + 5^2 + 7^2 + 9^2 5 | 6 | #fist we can see that the bases are nothing but odd numbers 7 | 8 | 9 | #rang is nothing but the number of terms (n) 10 | rang = int(input("enter the range(value of n): ")) 11 | 12 | i = 0 13 | a = 1 14 | 15 | b = 0 16 | 17 | while i < rang: 18 | odd_sq = a ** 2 19 | b = odd_sq + b 20 | 21 | a = a + 2 22 | i = i + 1 23 | 24 | print(b) -------------------------------------------------------------------------------- /Python Basic Programs/palindrome.py: -------------------------------------------------------------------------------- 1 | s = input() 2 | 3 | def find_palindromes_in_sub_string(input, j, k): 4 | count = 0 5 | while j >= 0 and k < len(input): 6 | if input[j] != input[k]: 7 | break 8 | print(input[j: k + 1]) 9 | count += 1 10 | 11 | j -= 1 12 | k += 1 13 | 14 | return count 15 | 16 | 17 | def find_all_palindrome_substrings(input): 18 | count = 0 19 | for i in range(0, len(input)): 20 | count += find_palindromes_in_sub_string(input, i - 1, i + 1) 21 | count += find_palindromes_in_sub_string(input, i, i + 1) 22 | 23 | return count 24 | 25 | 26 | 27 | print("Total palindrome substrings: ", find_all_palindrome_substrings(s)) -------------------------------------------------------------------------------- /Python Basic Programs/palindrome_string.py: -------------------------------------------------------------------------------- 1 | def palindrome(number, string_result = ''): 2 | if number < 1: 3 | return string_result 4 | else: 5 | if str(number) == str(number)[::-1]: 6 | string_result += (str(number)+" ") 7 | return palindrome(number-1, string_result) 8 | 9 | palindrom_num = palindrome(100) 10 | 11 | print(palindrom_num) -------------------------------------------------------------------------------- /Python Basic Programs/palindromicnumber.py: -------------------------------------------------------------------------------- 1 | #Program to check weather a number is palindromic 2 | 3 | number = input("enter a number: ") 4 | 5 | 6 | #the below code finds the number of digits in the number entered 7 | n = 0 8 | for i in number: 9 | n = n + 1 10 | 11 | #the below code reverses the number 12 | rev_number = "" 13 | for a in range (n-1, -1, -1): 14 | rev_num = number[a] 15 | rev_number = rev_number + rev_num 16 | 17 | #the number is converted to an integer, it was an string before 18 | number = int(number) 19 | rev_number = int(rev_number) 20 | 21 | #comparing if the number and its reversed number is equal or not 22 | #and printing the result 23 | 24 | if number == rev_number: 25 | print("the number is a palindrome") 26 | else: 27 | print("the number is not an palindrome") -------------------------------------------------------------------------------- /Python Basic Programs/patterns.py: -------------------------------------------------------------------------------- 1 | #1: Simple Number Triangle Pattern 2 | rows = 6 3 | 4 | for num in range(rows): 5 | for i in range(num): 6 | print(num, end="") # print number 7 | print("") 8 | print() 9 | #2: Inverted Pyramid of Numbers 10 | rows = 5 11 | 12 | b = 0 13 | 14 | for i in range(rows, 0, -1): 15 | b += 1 16 | for j in range(1, i + 1): 17 | print(b, end=' ') 18 | print('\r') 19 | print() 20 | 21 | 22 | #3: Half Pyramid Pattern of Numbers 23 | rows = 5 24 | 25 | for row in range(1, rows+1): 26 | for column in range(1, row + 1): 27 | print(column, end=' ') 28 | print("") 29 | print() 30 | 31 | 32 | #4: Inverted Pyramid of Descending Numbers 33 | rows = 5 34 | for i in range(rows, 0, -1): 35 | num = i 36 | for j in range(0, i): 37 | print(num, end=' ') 38 | print("\r") 39 | print() 40 | -------------------------------------------------------------------------------- /Python Basic Programs/prime_nums.py: -------------------------------------------------------------------------------- 1 | lower = int(intput()) 2 | upper = int(intput()) 3 | 4 | print("Prime numbers between", lower, "and", upper, "are:") 5 | 6 | for num in range(lower, upper + 1): 7 | # all prime numbers are greater than 1 8 | if num > 1: 9 | for i in range(2, num): 10 | if (num % i) == 0: 11 | break 12 | else: 13 | print(num) 14 | -------------------------------------------------------------------------------- /Python Basic Programs/print_the-elements_of_an_array_in_reverse_order.py: -------------------------------------------------------------------------------- 1 | my_list = [1, 2, 3, 4, 5] 2 | 3 | print("The list is : ") 4 | 5 | for i in range(0, len(my_list)): 6 | print(my_list[i]) 7 | 8 | print("The list after reversal is : ") 9 | 10 | for i in range(len(my_list)-1, -1, -1): 11 | print(my_list[i]) -------------------------------------------------------------------------------- /Python Basic Programs/py.py: -------------------------------------------------------------------------------- 1 | list_items = [] 2 | def solve(n): 3 | while n != 0: 4 | x = input().split(' ') 5 | if x[0] == 'insert': 6 | list_items.insert(int(x[1]), int(x[2])) 7 | elif x[0] == "sort": 8 | list_items.sort() 9 | elif x[0] == "append": 10 | list_items.append(int(x[1])) 11 | elif x[0] == "print": 12 | print(list_items) 13 | elif x[0] == "pop": 14 | list_items.pop() 15 | elif x[0] == "reverse": 16 | list_items.reverse() 17 | elif x[0] == "remove": 18 | del list_items[int(x[1])] 19 | n -= 1 20 | 21 | n = int(input()) 22 | solve(n) -------------------------------------------------------------------------------- /Python Basic Programs/pythagoras.py: -------------------------------------------------------------------------------- 1 | #Program that calculates the measures of the sides of a right triangle using the Pythagorean formula.# 2 | 3 | import math 4 | 5 | cateto1 = float(input()) 6 | cateto2 = float(input()) 7 | 8 | hipotenusa = math.sqrt(cateto1**2 + cateto2**2) 9 | 10 | print("%.2f" % hipotenusa) 11 | -------------------------------------------------------------------------------- /Python Basic Programs/quicksort.py: -------------------------------------------------------------------------------- 1 | def partition(array, low, high): 2 | i = low - 1 3 | pivot = array[high] 4 | for j in range(low, high): 5 | if array[j] <= pivot: 6 | i = i + 1 7 | array[i], array[j] = array[j], array[i] 8 | array[i + 1], array[high] = array[high], array[i + 1] 9 | return i + 1 10 | 11 | def quickSort(array, low, high): 12 | if low < high: 13 | pi = partition(array, low, high) 14 | quickSort(array, low, pi - 1) 15 | quickSort(array, pi + 1, high) 16 | 17 | 18 | arr = [int(item) for item in input().split()] 19 | print(arr) 20 | n = len(arr) 21 | quickSort(arr, 0, n - 1) 22 | print('Sorted Array :') 23 | print(arr) -------------------------------------------------------------------------------- /Python Basic Programs/range_and_interquartile_range.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | 3 | print("Enter numbers") 4 | arr = list(map(int,input().split())) 5 | 6 | #range 7 | range = max(arr) - min(arr) 8 | print("Range is", range) 9 | 10 | #Interquartile Range 11 | data = np.array(arr) 12 | q3, q1 = np.percentile(data, [75 ,25]) 13 | iqr = q3 - q1 14 | print("Interquartile Range is %.2f"%(iqr)) -------------------------------------------------------------------------------- /Python Basic Programs/standard_deviation_variance.py: -------------------------------------------------------------------------------- 1 | print("Enter numbers") 2 | arr = list(map(int,input().split())) 3 | 4 | mean = sum(arr)/len(arr) 5 | print("mean is %.1f" % (mean)) 6 | 7 | sum = 0 8 | for i in arr: 9 | sum += (i-mean)**2 10 | deviation = sum / len(arr) 11 | 12 | print("Standard Deviation is %.2f"%(deviation)) 13 | 14 | variance = deviation**1/2 15 | print("variance is %.2f"%(variance)) 16 | -------------------------------------------------------------------------------- /Python Basic Programs/string punctuation in Python.py: -------------------------------------------------------------------------------- 1 | # import string library function 2 | import string 3 | 4 | # Storing the sets of punctuation in variable result 5 | result = string.punctuation 6 | 7 | # Printing the punctuation values 8 | print(result) 9 | -------------------------------------------------------------------------------- /Python Basic Programs/student-registration-program.py: -------------------------------------------------------------------------------- 1 | class Student: 2 | def __init__(self, name, course, year, section): 3 | self.name = name 4 | self.course = course 5 | self.year = year 6 | self.section = section 7 | 8 | def introduce(self): 9 | print(" Name : " + self.name) 10 | print(" Course : " + self.course) 11 | print(" Year : " + self.year) 12 | print(" Section: " + self.section) 13 | 14 | listOfStudents = [] 15 | 16 | while True: 17 | print() 18 | name = input("Name : ") 19 | course = input("Course : ") 20 | year = input("Year : ") 21 | section = input("Section: ") 22 | stud = Student(name, course, year, section) 23 | listOfStudents.append(stud) 24 | print() 25 | choice = input("Create another student?[Y/N]: ") 26 | if choice == 'Y' or choice == 'y': pass 27 | else: break 28 | 29 | i=1 30 | for student in listOfStudents: 31 | print() 32 | print("Student #" + str(i)) 33 | student.introduce() 34 | i += 1 35 | -------------------------------------------------------------------------------- /Python Basic Programs/temperature_converter.py: -------------------------------------------------------------------------------- 1 | #Enter the scale and temperature value and this value will be converted to other scales.# 2 | 3 | escala = str(input()) 4 | valortemp = float(input()) 5 | 6 | celsioskelvin = valortemp + 273.15 7 | 8 | kelvincelsios = valortemp - 273.15 9 | 10 | celsiosfahren = (valortemp*1.8) + 32 11 | 12 | fahrencelsios = (valortemp-32)/1.8 13 | 14 | kelvinfahren = 1.8*(valortemp - 273.15) + 32 15 | 16 | fahrenkelvin = (valortemp + 459.67)*(5/9) 17 | 18 | if escala == "C" and valortemp >= -273.15: 19 | print("%.2f" % celsiosfahren, "F") 20 | print("%.2f" % celsioskelvin, "K") 21 | elif escala =="K" and valortemp >= 0.0: 22 | print("%.2f" % kelvincelsios, "C") 23 | print("%.2f" % kelvinfahren, "F") 24 | elif escala == "F" and valortemp >= -459.67: 25 | print("%.2f" % fahrencelsios, "C") 26 | print("%.2f" % fahrenkelvin, "K") 27 | else: 28 | print("Valor de temperatura abaixo do minimo") 29 | -------------------------------------------------------------------------------- /Python Basic Programs/toss.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | outcomes=["Heads", "Tails"] 4 | print(random.choice(outcomes)) -------------------------------------------------------------------------------- /Python Basic Programs/tower_of_hanoi.py: -------------------------------------------------------------------------------- 1 | 2 | # program for tower of hanoi 3 | 4 | def toh(n , src, dest, aux): 5 | if n==1: 6 | print ("Move disk 1 from source",src,"to destination",dest) 7 | return 8 | toh(n-1, src, aux, dest) 9 | print ("Move disk",n,"from source",src,"to destination",dest) 10 | toh(n-1, aux, dest, src) 11 | 12 | print("Enter N: \n") 13 | n = int(input()) 14 | 15 | toh(n,'A','B','C')# function called -------------------------------------------------------------------------------- /Python Basic Programs/url_find.py: -------------------------------------------------------------------------------- 1 | 2 | # Pyhton code to search for URL in any sentence or string 3 | import re 4 | 5 | # function defined 6 | def find_URL(string): 7 | 8 | # defined regex 9 | regex = r"(?i)\b((?:https?://|www\d{0,3}[.]|[a-z0-9.\-]+[.][a-z]{2,4}/)(?:[^\s()<>]+|\(([^\s()<>]+|(\([^\s()<>]+\)))*\))+(?:\(([^\s()<>]+|(\([^\s()<>]+\)))*\)|[^\s`!()\[\]{};:'\".,<>?«»“”‘’]))" 10 | url = re.findall(regex,string) 11 | return [x[0] for x in url] 12 | 13 | 14 | # take input of string 15 | input_string = str(input("Enter the Input String :")) 16 | 17 | # printing the answer, all URLS in input_string 18 | print("Urls: ", find_URL(input_string)) 19 | -------------------------------------------------------------------------------- /Python Basic Programs/whstappbot.py: -------------------------------------------------------------------------------- 1 | import keyboard 2 | import time 3 | n_members = int(input("Enter the number of members in the group: ")) 4 | print("\n\nSelect the group input box and press x to activate.") 5 | while True: 6 | if keyboard.is_pressed('x'): 7 | keyboard.send("Backspace") 8 | for i in range(n_members): 9 | time.sleep(0.05) 10 | keyboard.write("@") 11 | for j in range(i): 12 | keyboard.send("Down") 13 | keyboard.send("Enter") 14 | # keyboard.write(".") 15 | if i==0: 16 | keyboard.send("Shift+Enter") 17 | keyboard.send("Shift+Enter") 18 | keyboard.send("Shift+Enter") 19 | break 20 | -------------------------------------------------------------------------------- /Python Turtle Projects/Figure Designs/Avengers_logo.py: -------------------------------------------------------------------------------- 1 | from turtle import * 2 | 3 | drawer = Turtle() 4 | s = Screen() 5 | 6 | s.bgcolor("black") 7 | 8 | drawer.penup() 9 | drawer.setposition(-20,-350) 10 | drawer.pendown() 11 | drawer.begin_fill() 12 | drawer.color("red") 13 | drawer.circle(300) 14 | drawer.end_fill() 15 | drawer.penup() 16 | drawer.setposition(-20,-260) 17 | drawer.pendown() 18 | drawer.begin_fill() 19 | drawer.color("black") 20 | drawer.circle(230) 21 | drawer.end_fill() 22 | drawer.penup() 23 | drawer.setposition(0,-100) 24 | drawer.pendown() 25 | drawer.begin_fill() 26 | drawer.color("red") 27 | drawer.pensize(2) 28 | drawer.pencolor("grey") 29 | drawer.backward(100) 30 | drawer.left(60) 31 | drawer.backward(200) 32 | drawer.right(60) 33 | drawer.backward(85) 34 | drawer.right(115) 35 | drawer.backward(600) 36 | drawer.right(65) 37 | drawer.backward(130) 38 | drawer.right(90) 39 | drawer.backward(440) 40 | drawer.right(90) 41 | drawer.backward(100) 42 | drawer.right(90) 43 | 44 | drawer.backward(65) 45 | drawer.end_fill() 46 | drawer.penup() 47 | drawer.setposition(0,-50) 48 | drawer.pendown() 49 | 50 | drawer.pensize(2) 51 | 52 | 53 | drawer.begin_fill() 54 | drawer.color("black") 55 | drawer.pencolor("grey") 56 | drawer.right(90) 57 | 58 | drawer.forward(90) 59 | drawer.right(120) 60 | drawer.forward(170) 61 | drawer.right(150) 62 | drawer.forward(150) 63 | drawer.end_fill() 64 | 65 | done() -------------------------------------------------------------------------------- /Python Turtle Projects/Figure Designs/Captain_America_Shield.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | import math 3 | 4 | t = turtle.Turtle() 5 | 6 | 7 | def ankur(x, y): 8 | t.penup() 9 | t.goto(x, y) 10 | t.pendown() 11 | t.setheading(0) 12 | t.pensize(2) 13 | t.speed(10) 14 | 15 | 16 | def golo(r, color): 17 | x_point = 0 18 | y_pont = -r 19 | ankur(x_point, y_pont) 20 | t.pencolor(color) 21 | t.fillcolor(color) 22 | t.begin_fill() 23 | t.circle(r) 24 | t.end_fill() 25 | 26 | 27 | def paanch(r, color): 28 | ankur(0, 0) 29 | t.pencolor(color) 30 | t.setheading(162) 31 | t.forward(r) 32 | t.setheading(0) 33 | t.fillcolor(color) 34 | t.begin_fill() 35 | for i in range(5): 36 | t.forward(math.cos(math.radians(18)) * 2 * r) # 2cos18°*r 37 | t.right(144) 38 | t.end_fill() 39 | t.hideturtle() 40 | 41 | 42 | if __name__ == '__main__': 43 | golo(288, 'crimson') 44 | golo(234, 'snow') 45 | golo(174, 'crimson') 46 | golo(114, 'blue') 47 | paanch(114, 'snow') 48 | turtle.done() -------------------------------------------------------------------------------- /Python Turtle Projects/Figure Designs/Ironman_Helmet.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | 3 | ankur1 = [[(-40, 120), (-70, 260), (-130, 230), (-170, 200), (-170, 100), (-160, 40), (-170, 10), (-150, -10), (-140, 10), 4 | (-40, -20), (0, -20)], 5 | [(0, -20), (40, -20), (140, 10), (150, -10), (170, 10), (160, 40), (170, 100), (170, 200), (130, 230), (70, 260), 6 | (40, 120), (0, 120)]] 7 | ankur2 = [[(-40, -30), (-50, -40), (-100, -46), (-130, -40), (-176, 0), (-186, -30), (-186, -40), (-120, -170), (-110, -210), 8 | (-80, -230), (-64, -210), (0, -210)], 9 | [(0, -210), (64, -210), (80, -230), (110, -210), (120, -170), (186, -40), (186, -30), (176, 0), (130, -40), 10 | (100, -46), (50, -40), (40, -30), (0, -30)]] 11 | ankur3 = [[(-60, -220), (-80, -240), (-110, -220), (-120, -250), (-90, -280), (-60, -260), (-30, -260), (-20, -250), 12 | (0, -250)], 13 | [(0, -250), (20, -250), (30, -260), (60, -260), (90, -280), (120, -250), (110, -220), (80, -240), (60, -220), 14 | (0, -220)]] 15 | 16 | turtle.hideturtle() 17 | turtle.bgcolor('#ba161e') # Dark Red 18 | turtle.setup(500, 600) 19 | turtle.title("I AM IRONMAN") 20 | ankur1Goto = (0, 120) 21 | ankur2Goto = (0, -30) 22 | ankur3Goto = (0, -220) 23 | turtle.speed(2) 24 | 25 | 26 | def logo(a, b): 27 | turtle.penup() 28 | turtle.goto(b) 29 | turtle.pendown() 30 | turtle.color('#fab104') # Light Yellow 31 | turtle.begin_fill() 32 | 33 | for i in range(len(a[0])): 34 | x, y = a[0][i] 35 | turtle.goto(x, y) 36 | 37 | for i in range(len(a[1])): 38 | x, y = a[1][i] 39 | turtle.goto(x, y) 40 | turtle.end_fill() 41 | 42 | 43 | logo(ankur1, ankur1Goto) 44 | logo(ankur2, ankur2Goto) 45 | logo(ankur3, ankur3Goto) 46 | turtle.hideturtle() 47 | turtle.done() -------------------------------------------------------------------------------- /Python Turtle Projects/Figure Designs/Tom_Holland.py: -------------------------------------------------------------------------------- 1 | from sketchpy import library as lib 2 | 3 | obj = lib.tom_holland() 4 | obj.draw() 5 | -------------------------------------------------------------------------------- /Python Turtle Projects/Pattern Designs/Animation_Circle.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | turtle.bgcolor("black") 3 | Cppsecrets = turtle.Screen() 4 | Cppsecrets.title("Animation Circle ") 5 | turtle=turtle.Turtle() 6 | turtle.color("red") 7 | turtle.speed(0) 8 | turtle.hideturtle() 9 | for i in range(100): 10 | turtle.circle(i*2) 11 | turtle._rotate(5) 12 | -------------------------------------------------------------------------------- /Python Turtle Projects/Pattern Designs/Attractive_Circle.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | turtle.bgcolor("red") 3 | Cppsecrets = turtle.Turtle() 4 | Cppsecrets.speed(0) 5 | for i in range(180): 6 | Cppsecrets.forward(100) 7 | Cppsecrets.right(30) 8 | Cppsecrets.forward(20) 9 | Cppsecrets.left(60) 10 | Cppsecrets.forward(50) 11 | Cppsecrets.right(30) 12 | Cppsecrets.penup() 13 | Cppsecrets.setposition(0, 0) 14 | Cppsecrets.pendown() 15 | Cppsecrets.right(2) 16 | turtle.done() -------------------------------------------------------------------------------- /Python Turtle Projects/Pattern Designs/Circle_Mania.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | Cppsecrets = turtle.Screen() 3 | Cppsecrets.bgcolor('black') 4 | s = turtle.Turtle() 5 | s.speed('fastest') 6 | s.color('white') 7 | rotate=int(180) 8 | def Circles(t,size): 9 | for i in range(10): 10 | t.circle(size) 11 | size=size-4 12 | def Cppsecrets1(t,size,repeat): 13 | for i in range (repeat): 14 | Circles(t,size) 15 | t.right(360/repeat) 16 | Cppsecrets1(s,200,10) 17 | t1 = turtle.Turtle() 18 | t1.speed(0) 19 | t1.color('yellow') 20 | rotate=int(90) 21 | def Circles(t,size): 22 | for i in range(4): 23 | t.circle(size) 24 | size=size-10 25 | def Cppsecrets1(t,size,repeat): 26 | for i in range (repeat): 27 | Circles(t,size) 28 | t.right(360/repeat) 29 | Cppsecrets1(t1,160,10) 30 | t2= turtle.Turtle() 31 | t2.speed(0) 32 | t2.color('blue') 33 | rotate=int(80) 34 | def Circles(t,size): 35 | for i in range(4): 36 | t.circle(size) 37 | size=size-5 38 | def Cppsecrets1(t,size,repeat): 39 | for i in range (repeat): 40 | Circles(t,size) 41 | t.right(360/repeat) 42 | Cppsecrets1(t2,120,10) 43 | t3 = turtle.Turtle() 44 | t3.speed(0) 45 | t3.color('red') 46 | rotate=int(90) 47 | def Circles(t,size): 48 | for i in range(4): 49 | t.circle(size) 50 | size=size-19 51 | def Cppsecrets1(t,size,repeat): 52 | for i in range (repeat): 53 | Circles(t,size) 54 | t.right(360/repeat) 55 | Cppsecrets1(t3,80,10) 56 | t4= turtle.Turtle() 57 | t4.speed(0) 58 | t4.color('green') 59 | 60 | rotate=int(90) 61 | def Circles(t,size): 62 | for i in range(4): 63 | t.circle(size) 64 | size=size-20 65 | def Cppsecrets1(t,size,repeat): 66 | for i in range (repeat): 67 | Circles(t,size) 68 | t.right(360/repeat) 69 | Cppsecrets1(t4,40,10) 70 | -------------------------------------------------------------------------------- /Python Turtle Projects/Pattern Designs/Graphics_Pattern.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | t = turtle.Turtle() 3 | list1 = ["purple","red","orange","blue","green"] 4 | turtle.bgcolor("black") 5 | for i in range(200): 6 | t.color(list1[i%5]) 7 | t.pensize(i/10+1) 8 | t.forward(i) 9 | t.left(59) 10 | -------------------------------------------------------------------------------- /Python Turtle Projects/Pattern Designs/Spiral_Draw.py: -------------------------------------------------------------------------------- 1 | 2 | def Cppsecrets (python , cplusplus): 3 | if python >0: 4 | turtle.forward(python) 5 | turtle.right(cplusplus) 6 | Cppsecrets(python-5,cplusplus) 7 | import turtle 8 | turtle.shape('turtle') 9 | turtle.reset() 10 | turtle.pen(speed =1) 11 | turtle.delay(0) 12 | length =400 13 | turn_by =121 14 | turtle.penup() 15 | turtle.setpos(-length/2,length/2) 16 | turtle.pendown() 17 | Cppsecrets(length,turn_by) 18 | -------------------------------------------------------------------------------- /Python Turtle Projects/Pattern Designs/Spiral_Web.py: -------------------------------------------------------------------------------- 1 | # import turtle 2 | import turtle 3 | 4 | # defining colors 5 | colors = ['red', 'yellow', 'green', 'purple', 'blue', 'orange'] 6 | 7 | # setup turtle pen 8 | t= turtle.Pen() 9 | 10 | # changes the speed of the turtle 11 | t.speed(10) 12 | 13 | # changes the background color 14 | turtle.bgcolor("black") 15 | 16 | # make spiral_web 17 | for x in range(200): 18 | t.pencolor(colors[x%6]) # setting color 19 | t.width(x/100 + 1) # setting width 20 | t.forward(x) # moving forward 21 | t.left(59) # moving left 22 | 23 | turtle.done() 24 | t.speed(10) 25 | 26 | turtle.bgcolor("black") # changes the background color 27 | 28 | # make spiral_web 29 | for x in range(200): 30 | t.pencolor(colors[x%6]) # setting color 31 | t.width(x/100 + 1) # setting width 32 | t.forward(x) # moving forward 33 | t.left(59) # moving left 34 | 35 | turtle.done() 36 | -------------------------------------------------------------------------------- /Python Turtle Projects/Pattern Designs/Square_Spirograph.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | turtle.speed(0) 3 | turtle.bgcolor("black") 4 | for i in range(5): 5 | for colours in ("red" ,"magenta","white","cyan","green","yellow","blue","purple","pink"): 6 | turtle.color(colours) 7 | turtle.pensize(3) 8 | turtle.left(12) 9 | turtle.forward(200) 10 | turtle.left(90) 11 | turtle.forward(200) 12 | turtle.left(90) 13 | turtle.forward(200) 14 | turtle.left(90) 15 | turtle.forward(200) 16 | turtle.left(90) 17 | 18 | -------------------------------------------------------------------------------- /Python Turtle ProjectsBeautifulColoredPattern.py: -------------------------------------------------------------------------------- 1 | from turtle import * import random 2 | 3 | speed(speed ='fastest') 4 | 5 | def draw(n, x, angle): 6 | for i in range(n): 7 | 8 | colormode(255) 9 | 10 | 11 | a = random.randint(0, 255) 12 | b = random.randint(0, 255) 13 | c = random.randint(0, 255) 14 | 15 | pencolor(a, b, c) 16 | fillcolor(a, b, c) 17 | 18 | begin_fill() 19 | 20 | for j in range(5): 21 | 22 | forward(5 * n-5 * i) 23 | right(x) 24 | forward(5 * n-5 * i) 25 | right(72 - x) 26 | 27 | end_fill() 28 | 29 | rt(angle) 30 | 31 | 32 | 33 | n = 30 34 | x = 144 35 | angle = 18 36 | 37 | draw(n, x, angle) 38 | -------------------------------------------------------------------------------- /SECURITY.md: -------------------------------------------------------------------------------- 1 | # Security Policy 2 | 3 | ## Supported Versions 4 | 5 | Use this section to tell people about which versions of your project are 6 | currently being supported with security updates. 7 | 8 | | Version | Supported | 9 | | ------- | ------------------ | 10 | | 5.1.x | :white_check_mark: | 11 | | 5.0.x | :x: | 12 | | 4.0.x | :white_check_mark: | 13 | | < 4.0 | :x: | 14 | 15 | ## Reporting a Vulnerability 16 | 17 | Use this section to tell people how to report a vulnerability. 18 | 19 | Tell them where to go, how often they can expect to get an update on a 20 | reported vulnerability, what to expect if the vulnerability is accepted or 21 | declined, etc. 22 | -------------------------------------------------------------------------------- /Text to Handwritten/pywhatkit.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Text to Handwritten/pywhatkit.png -------------------------------------------------------------------------------- /Text to Handwritten/requirements.txt: -------------------------------------------------------------------------------- 1 | beautifulsoup4==4.11.1 2 | certifi==2022.12.7 3 | charset-normalizer==2.1.1 4 | click==8.1.3 5 | colorama==0.4.5 6 | Flask==2.3.2 7 | idna==3.4 8 | itsdangerous==2.1.2 9 | Jinja2==3.1.2 10 | MarkupSafe==2.1.1 11 | MouseInfo==0.1.3 12 | Pillow==9.3.0 13 | PyAutoGUI==0.9.53 14 | PyGetWindow==0.0.9 15 | PyMsgBox==1.0.9 16 | pyperclip==1.8.2 17 | PyRect==0.2.0 18 | PyScreeze==0.1.28 19 | pytweening==1.0.4 20 | pywhatkit==5.4 21 | requests==2.28.1 22 | soupsieve==2.3.2.post1 23 | urllib3==1.26.12 24 | Werkzeug==2.2.2 25 | wikipedia==1.4.0 26 | -------------------------------------------------------------------------------- /Text to Handwritten/text-to-handwritten.py: -------------------------------------------------------------------------------- 1 | # pip install -r requirements.txt 2 | import pywhatkit 3 | 4 | 5 | text = input("Enter the text : ") 6 | 7 | try: 8 | pywhatkit.text_to_handwriting(text) 9 | print("Succesfull") 10 | 11 | except: 12 | print("Soemthing went wrong please try again.") -------------------------------------------------------------------------------- /Virtual-Painter/tools.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Virtual-Painter/tools.png -------------------------------------------------------------------------------- /Web and Automation and Networking/Financial Service main.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Web and Automation and Networking/Financial Service main.xlsx -------------------------------------------------------------------------------- /Web and Automation and Networking/Password_Strength_Checker.py: -------------------------------------------------------------------------------- 1 | Upper_Case_Count = 0 2 | Lower_Case_Count = 0 3 | Digit_Count = 0 4 | Special_Character_Count = 0 5 | 6 | PSWD = input("ENTER PASSWORD : ") 7 | 8 | if len(PSWD) < 6 or len(PSWD) > 16: 9 | print("Weak Password !!!") 10 | else: 11 | for i in PSWD: 12 | if i.isalpha(): 13 | if i.isupper(): 14 | Upper_Case_Count +=1 15 | elif i.islower(): 16 | Lower_Case_Count += 1 17 | elif i.isdigit(): 18 | Digit_Count +=1 19 | else: 20 | Special_Character_Count += 1 21 | 22 | if Upper_Case_Count == 0 or Lower_Case_Count == 0 or Digit_Count == 0 or Special_Character_Count == 0: 23 | print("Weak Password !!!") 24 | else: 25 | print("Strong Password :)") 26 | -------------------------------------------------------------------------------- /Web and Automation and Networking/Python-Web-Crawler/README.md: -------------------------------------------------------------------------------- 1 | # Python-Web-Crawler 2 | A Web crawler, sometimes called a spider or spiderbot and often shortened to crawler, is an Internet bot that systematically browses the World Wide Web, 3 | typically operated by search engines for the purpose of Web indexing (web spidering). 4 | In this project, using Python, a Web-Crawler is created that fetches all the links from a particular website. 5 | (Use VS Code or PyCharm for getting the desired output) 6 | Ref : The Complete Python Masterclass: Learn Python From Scratch by Ashutosh Pawar. 7 | -------------------------------------------------------------------------------- /Web and Automation and Networking/Python-Web-Crawler/demo.py: -------------------------------------------------------------------------------- 1 | import os 2 | 3 | def create_project_dir(directory): 4 | if not os.path.exists(directory): 5 | print('Creating the directory' + directory) 6 | os.makedirs(directory) 7 | 8 | def create_data_files(project_name, base_url): 9 | queue = os.path.join(project_name,'queue.txt') 10 | crawled = os.path.join(project_name,"crawled.txt") 11 | if not os.path.isfile(queue): 12 | write_file(queue,base_url) 13 | if not os.path.isfile(crawled): 14 | write_file(crawled,'') 15 | 16 | def write_file(path,data): 17 | with open(path,'w') as f: 18 | f.write(data) 19 | 20 | def append_to_file(path,data): 21 | with open(path,'a') as f: 22 | f.write(data,'\n') 23 | 24 | def delete_file_contents(path): 25 | open(path,'w').close() 26 | 27 | def file_to_set(file_name): 28 | results= set() 29 | with open(file_name,'rt') as f: 30 | for line in f: 31 | results.add(line.replace('\n','')) 32 | return results 33 | 34 | def set_to_file(links,file_name): 35 | with open(file_name,"w") as f: 36 | for l in sorted(links): 37 | f.write(l+"\n") -------------------------------------------------------------------------------- /Web and Automation and Networking/Python-Web-Crawler/domain.py: -------------------------------------------------------------------------------- 1 | from urllib.parse import urlparse 2 | 3 | def get_domain_name(url): 4 | try: 5 | results = get_sub_domain_name(url).split('.') 6 | return results[-2] + '.' + results[-1] 7 | except: 8 | return '' 9 | 10 | def get_sub_domain_name(url): 11 | try: 12 | return urlparse(url).netloc 13 | except: 14 | return '' -------------------------------------------------------------------------------- /Web and Automation and Networking/Python-Web-Crawler/link_finder.py: -------------------------------------------------------------------------------- 1 | from html.parser import HTMLParser 2 | from urllib import parse 3 | 4 | class LinkFinder(HTMLParser): 5 | 6 | 7 | def __init__(self,base_url,page_url): 8 | super().__init__() 9 | self.base_url = base_url 10 | self.page_url = page_url 11 | self.links = set() 12 | 13 | def error(self, message): 14 | pass 15 | 16 | def handle_starttag(self, tag, attrs): 17 | if tag == 'a': 18 | for (attribute,value) in attrs: 19 | if attribute == 'href': 20 | url = parse.urljoin(self.base_url,value) 21 | self.links.add(url) 22 | 23 | 24 | def page_links(self): 25 | return self.links 26 | -------------------------------------------------------------------------------- /Web and Automation and Networking/Python-Web-Crawler/main.py: -------------------------------------------------------------------------------- 1 | import threading 2 | from queue import Queue 3 | from spider import Spider 4 | from domain import * 5 | from demo import * 6 | PROJECT_NAME ='thesite' 7 | HOMEPAGE = 'https://lavasa.christuniversity.in/' 8 | DOMAIN_NAME = get_domain_name(HOMEPAGE) 9 | QUEUE_FILE = PROJECT_NAME + '/queue.txt' 10 | CRAWLED_FILE = PROJECT_NAME + '/crawled.txt' 11 | NUMBER_OF_THREADS = 8 12 | queue= Queue() 13 | Spider(PROJECT_NAME,HOMEPAGE,DOMAIN_NAME) 14 | 15 | def crawl(): 16 | queued_links= file_to_set(QUEUE_FILE) 17 | if len(queued_links) > 0: 18 | print(str(len(queued_links))+' Links in the queue ') 19 | create_jobs() 20 | def create_jobs(): 21 | for link in file_to_set(QUEUE_FILE): 22 | queue.put(link) 23 | queue.join() 24 | crawl() 25 | 26 | def create_workers(): 27 | for _ in range(NUMBER_OF_THREADS): 28 | t = threading.Thread(target=work) 29 | t.daemon= True 30 | t.start() 31 | 32 | def work(): 33 | while True: 34 | url = queue.get() 35 | Spider.crawl_page(threading.current_thread().name, url) 36 | queue.task_done() 37 | create_workers() 38 | crawl() -------------------------------------------------------------------------------- /Web and Automation and Networking/Scrapper.py: -------------------------------------------------------------------------------- 1 | 2 | import urllib.request 3 | from bs4 import BeautifulSoup 4 | 5 | 6 | class Scraper: 7 | def __init__(self, site): 8 | self.site = site 9 | 10 | def scrape(self): 11 | r = urllib.request.urlopen(self.site) 12 | html = r.read() 13 | parser = "html.parser" 14 | sp = BeautifulSoup(html,parser) 15 | for tag in sp.find_all("a"): 16 | url = tag.get("href") 17 | if url is None: 18 | continue 19 | if "articles" in url: 20 | print("\n" + url) 21 | 22 | news = "https://news.google.com/" 23 | Scraper(news).scrape() -------------------------------------------------------------------------------- /Web and Automation and Networking/Web_blocker.py: -------------------------------------------------------------------------------- 1 | # Script for blocking certain websites. U can put ur list website 2 | 3 | import time 4 | from datetime import datetime as dt 5 | 6 | hosts_path = r"/etc/hosts" # r is for raw string 7 | hosts_temp = "hosts" 8 | 9 | #Locahost's IP 10 | redirect = "127.0.0.1" 11 | 12 | # Put ur desired website to block it 13 | web_list = ["www.facebook.com", "facebook.com"] 14 | 15 | while True: 16 | # Time of the users work 17 | if dt(dt.now().year, dt.now().month, dt.now().day, 9) < dt.now() < dt(dt.now().year, dt.now().month, dt.now().day, 22): 18 | print("Working hours") 19 | with open(hosts_path, "r+") as file: 20 | content = file.read() 21 | for website in web_list: 22 | if website in content: 23 | pass 24 | else: 25 | file.writable(redirect+" "+website+"\n") 26 | 27 | else: 28 | print("No ad, no pain") 29 | -------------------------------------------------------------------------------- /Web and Automation and Networking/comic extracter.py: -------------------------------------------------------------------------------- 1 | #! python3 2 | 3 | import requests, os, bs4 4 | 5 | url = 'https://xkcd.com' # starting url 6 | os.makedirs('xkcd', exist_ok=True) # store comics in ./xkcd 7 | while not url.endswith('#'): 8 | print('Downloading page %s...' % url) 9 | res = requests.get(url) 10 | res.raise_for_status() 11 | 12 | soup = bs4.BeautifulSoup(res.text, 'html.parser') 13 | comicElem = soup.select('#comic img') 14 | if comicElem == []: 15 | print('Could not find comic image.') 16 | else: 17 | comicUrl = 'https:' + comicElem[0].get('src') 18 | # Download the image. 19 | print('Downloading image %s...' % (comicUrl)) 20 | res = requests.get(comicUrl) 21 | res.raise_for_status() 22 | imageFile = open(os.path.join('xkcd', os.path.basename(comicUrl)), 23 | 'wb') 24 | for chunk in res.iter_content(100000): 25 | imageFile.write(chunk) 26 | imageFile.close() 27 | 28 | # Get the Prev button's url. 29 | prevLink = soup.select('a[rel="prev"]')[0] 30 | url = 'https://xkcd.com' + prevLink.get('href') 31 | 32 | print('Done.') -------------------------------------------------------------------------------- /Web and Automation and Networking/data.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Web and Automation and Networking/data.xlsx -------------------------------------------------------------------------------- /Web and Automation and Networking/emailSender.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup # pip install bs4 3 | from email.mime.multipart import MIMEMultipart 4 | from email.mime.text import MIMEText 5 | import smtplib 6 | 7 | def automateEmail(url): 8 | container = '' 9 | response = requests.get(url) 10 | contents = response.content 11 | # step 1 - scraping data 12 | # create soup 13 | soup = BeautifulSoup(contents, 'html.parser') 14 | # print(soup) 15 | source = soup.find_all('div', attrs={'class':'hm'}) 16 | i = 1 17 | for item in source: 18 | if item.findChildren('h2'): 19 | anchor = item.find('a') 20 | text = item.text 21 | link = anchor.get('href') 22 | if 'https:' not in link: 23 | link = url+link 24 | # print(link) 25 | container += str(i) +':'+text + f"click here
" 26 | i+=1 27 | return container 28 | 29 | update = automateEmail('https://medium.com') 30 | # print(update) 31 | 32 | # server- 33 | SERVER = 'smtp.gmail.com' 34 | PORT = 587 35 | FROM = 'your gmail id' 36 | TO = 'gmail ids (whom to send)' # you can add multiple id using list[] 37 | PASS = 'your password' 38 | 39 | # messge 40 | msg = MIMEMultipart() 41 | msg['Subject'] = 'Trending Medium blogs - Automate' 42 | msg['From'] = FROM 43 | msg['To'] = TO 44 | 45 | msg.attach(MIMEText(update, 'html')) 46 | 47 | # server start 48 | server = smtplib.SMTP(SERVER, PORT) 49 | server.set_debuglevel(1) 50 | server.ehlo() 51 | server.starttls() 52 | server.login(FROM, PASS) 53 | server.sendmail(FROM, TO, msg.as_string()) 54 | 55 | server.quit() -------------------------------------------------------------------------------- /Web and Automation and Networking/file.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Web and Automation and Networking/file.xlsx -------------------------------------------------------------------------------- /Web and Automation and Networking/generate_jwt/generate_jwt.py: -------------------------------------------------------------------------------- 1 | import jwt 2 | 3 | key = "your_secret" 4 | encoded = jwt.encode({"some": "payload"}, key, algorithm="HS256") 5 | print(encoded) 6 | 7 | decoded = jwt.decode(encoded, key, algorithms="HS256") 8 | print(decoded) -------------------------------------------------------------------------------- /Web and Automation and Networking/socket_ip_hostname.py: -------------------------------------------------------------------------------- 1 | # This script uses the socket python in-built library to get hostname and ip address on the local network 2 | 3 | # The socket library let's your interface with network 4 | import socket 5 | 6 | host = socket.gethostname() 7 | ip_addr = socket.gethostbyname(host) 8 | 9 | print("********************") 10 | print("Hostname: " + host) 11 | print("IP: " + ip_addr) 12 | print("********************") 13 | 14 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/README.md: -------------------------------------------------------------------------------- 1 | ## Preview 2 | ![](preview.jpg) 3 | 4 | ## Tech Stack 5 | 6 | * Python django 7 | 8 | 9 | ## Installation 10 | 11 | 12 | ```bash 13 | pip install virtualenv - to install 14 | python -m virtualenv "ENVNAME" - to create 15 | .\"ENVNAME"\Scripts\activate.bat - to activate virtual environment 16 | pip install django - to install in virtual env 17 | pip install -r requirements.txt - to install all of the Python modules and packages 18 | cd "TodoList" - to move to project file 19 | python manage.py runserver - to run project 20 | ..\"ENVNAME"\Scripts\deactivate.bat - to deactivate virtual environment 21 | ``` 22 | 23 | Name : Chandan Kushwaha ( todolist )
24 | GitHub Username : chandanck22
25 | GitHub Profile URL : https://github.com/chandanck22/ 26 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/.idea/.gitignore: -------------------------------------------------------------------------------- 1 | # Default ignored files 2 | /shelf/ 3 | /workspace.xml 4 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/.idea/TodoList.iml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/.idea/encodings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/.idea/inspectionProfiles/profiles_settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 6 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/.idea/misc.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 7 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/.idea/modules.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/TodoList/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Web and Automation and Networking/todolist/TodoList/TodoList/__init__.py -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/TodoList/asgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | ASGI config for TodoList project. 3 | 4 | It exposes the ASGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/asgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.asgi import get_asgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TodoList.settings') 15 | 16 | application = get_asgi_application() 17 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/TodoList/urls.py: -------------------------------------------------------------------------------- 1 | """TodoList URL Configuration 2 | 3 | The `urlpatterns` list routes URLs to views. For more information please see: 4 | https://docs.djangoproject.com/en/3.0/topics/http/urls/ 5 | Examples: 6 | Function views 7 | 1. Add an import: from my_app import views 8 | 2. Add a URL to urlpatterns: path('', views.home, name='home') 9 | Class-based views 10 | 1. Add an import: from other_app.views import Home 11 | 2. Add a URL to urlpatterns: path('', Home.as_view(), name='home') 12 | Including another URLconf 13 | 1. Import the include() function: from django.urls import include, path 14 | 2. Add a URL to urlpatterns: path('blog/', include('blog.urls')) 15 | """ 16 | from django.contrib import admin 17 | from django.urls import path, include 18 | 19 | urlpatterns = [ 20 | path('admin/', admin.site.urls), 21 | path('', include('tasks.urls')) 22 | ] 23 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/TodoList/wsgi.py: -------------------------------------------------------------------------------- 1 | """ 2 | WSGI config for TodoList project. 3 | 4 | It exposes the WSGI callable as a module-level variable named ``application``. 5 | 6 | For more information on this file, see 7 | https://docs.djangoproject.com/en/3.0/howto/deployment/wsgi/ 8 | """ 9 | 10 | import os 11 | 12 | from django.core.wsgi import get_wsgi_application 13 | 14 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TodoList.settings') 15 | 16 | application = get_wsgi_application() 17 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/manage.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | """Django's command-line utility for administrative tasks.""" 3 | import os 4 | import sys 5 | 6 | 7 | def main(): 8 | os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'TodoList.settings') 9 | try: 10 | from django.core.management import execute_from_command_line 11 | except ImportError as exc: 12 | raise ImportError( 13 | "Couldn't import Django. Are you sure it's installed and " 14 | "available on your PYTHONPATH environment variable? Did you " 15 | "forget to activate a virtual environment?" 16 | ) from exc 17 | execute_from_command_line(sys.argv) 18 | 19 | 20 | if __name__ == '__main__': 21 | main() 22 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/pass.txt: -------------------------------------------------------------------------------- 1 | https://127.0.0.1:8000/admin - to access admin panel 2 | 3 | user- todolist 4 | email - todolist@django.com 5 | pass - todolist -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Web and Automation and Networking/todolist/TodoList/tasks/__init__.py -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/admin.py: -------------------------------------------------------------------------------- 1 | from django.contrib import admin 2 | 3 | # Register your models here. 4 | from .models import * 5 | 6 | admin.site.register(Task) -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/apps.py: -------------------------------------------------------------------------------- 1 | from django.apps import AppConfig 2 | 3 | 4 | class TasksConfig(AppConfig): 5 | name = 'tasks' 6 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/forms.py: -------------------------------------------------------------------------------- 1 | from django import forms 2 | from django.forms import ModelForm 3 | 4 | from .models import * 5 | 6 | class TaskForm(forms.ModelForm): 7 | title = forms.CharField(widget=forms.TextInput(attrs={'placeholder':'Add new task...'})) 8 | 9 | class Meta: 10 | model = Task 11 | fields = '__all__' -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/migrations/0001_initial.py: -------------------------------------------------------------------------------- 1 | # Generated by Django 3.0 on 2022-09-08 10:19 2 | 3 | from django.db import migrations, models 4 | 5 | 6 | class Migration(migrations.Migration): 7 | 8 | initial = True 9 | 10 | dependencies = [ 11 | ] 12 | 13 | operations = [ 14 | migrations.CreateModel( 15 | name='Task', 16 | fields=[ 17 | ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), 18 | ('title', models.CharField(max_length=200)), 19 | ('complete', models.BooleanField(default=False)), 20 | ('created', models.DateTimeField(auto_now_add=True)), 21 | ], 22 | ), 23 | ] 24 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/migrations/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Web and Automation and Networking/todolist/TodoList/tasks/migrations/__init__.py -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/models.py: -------------------------------------------------------------------------------- 1 | from django.db import models 2 | 3 | # Create your models here. 4 | class Task(models.Model): 5 | title = models.CharField(max_length=200) 6 | complete = models.BooleanField(default=False) 7 | created = models.DateTimeField(auto_now_add=True) 8 | 9 | def __str__(self): 10 | return self.title -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/templates/tasks/delete.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | Title 6 | 7 | 8 | 9 |

Are you sure you want to delete "{{item}}"?

10 | 11 | Cancle 12 | 13 |
14 | {% csrf_token %} 15 | 16 |
17 | 18 | 19 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/templates/tasks/update_task.html: -------------------------------------------------------------------------------- 1 |

Update Task

2 | 3 |
4 | {% csrf_token %} 5 | 6 | {{form}} 7 | 8 |
9 | 10 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/tests.py: -------------------------------------------------------------------------------- 1 | from django.test import TestCase 2 | 3 | # Create your tests here. 4 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/urls.py: -------------------------------------------------------------------------------- 1 | from django.urls import path 2 | from . import views 3 | 4 | urlpatterns = [ 5 | path('', views.index, name="list"), 6 | path('update_task//', views.updateTask, name="update_task"), 7 | path('delete//', views.deleteTask, name="delete"), 8 | 9 | ] -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/TodoList/tasks/views.py: -------------------------------------------------------------------------------- 1 | from django.shortcuts import render, redirect 2 | from django.http import HttpResponse 3 | 4 | from .models import * 5 | from .forms import * 6 | 7 | def index(request): 8 | tasks = Task.objects.all() 9 | 10 | form = TaskForm() 11 | 12 | if request.method == 'POST': 13 | form = TaskForm(request.POST) 14 | if form.is_valid(): 15 | form.save() 16 | return redirect('/') 17 | 18 | context = {'tasks':tasks, 'form':form} 19 | return render(request, 'tasks/list.html', context) 20 | 21 | def updateTask(request, pk): 22 | task = Task.objects.get(id=pk) 23 | 24 | form = TaskForm(instance=task) 25 | 26 | if request.method == 'POST': 27 | form = TaskForm(request.POST, instance=task) 28 | if form.is_valid(): 29 | form.save() 30 | return redirect('/') 31 | 32 | context = {'form':form} 33 | 34 | return render(request, 'tasks/update_task.html', context) 35 | 36 | def deleteTask(request, pk): 37 | item = Task.objects.get(id=pk) 38 | 39 | if request.method == 'POST': 40 | item.delete() 41 | return redirect('/') 42 | 43 | context = {'item':item} 44 | return render(request, 'tasks/delete.html', context) 45 | 46 | 47 | -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/preview.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/Web and Automation and Networking/todolist/preview.jpg -------------------------------------------------------------------------------- /Web and Automation and Networking/todolist/requirements.txt: -------------------------------------------------------------------------------- 1 | asgiref==3.5.2 2 | Django==3.1.14 3 | pytz==2022.2.1 4 | sqlparse==0.4.2 5 | -------------------------------------------------------------------------------- /Web and Automation and Networking/twitter url extracter.py: -------------------------------------------------------------------------------- 1 | url = "https://twitter.com/abipravi1" 2 | 3 | username = url.split('/') 4 | 5 | print(f'Extraced username => {username[3]}') -------------------------------------------------------------------------------- /Web and Automation and Networking/webscraping.py: -------------------------------------------------------------------------------- 1 | import requests 2 | from bs4 import BeautifulSoup 3 | news = [] 4 | shotnews = [] 5 | image = [] 6 | link = [] 7 | for i in range(0, 15): 8 | URL = "https://www.indiatoday.in/india/?page=" + str(i) 9 | page = requests.get(URL) 10 | soup = BeautifulSoup(page.content, "html.parser") 11 | results = soup.find(id="content") 12 | elements = results.find_all("div", class_="catagory-listing") 13 | for job_element in elements: 14 | title_element = job_element.find("h2") 15 | news.append(title_element.text.strip()) 16 | image1 = job_element.find("img") 17 | image.append(image1['src']) 18 | location_element = "" 19 | if job_element.find("a", href=True): 20 | location_element = job_element.find("a", href=True) 21 | if location_element == "": 22 | link.append("none") 23 | else: 24 | link1 = 'https://www.indiatoday.in' + location_element['href'] 25 | link.append(link1) 26 | if job_element.find("p"): 27 | location_element = job_element.find("p") 28 | l1 = location_element.text.strip() 29 | location_element = l1 30 | shotnews.append(location_element) 31 | x = [{'news': a, 'image': s, 'link': t, 'shortnews': l} 32 | for a, s, t, l in zip(news, image, link, shotnews)] 33 | 34 | print(x) 35 | -------------------------------------------------------------------------------- /Web and Automation and Networking/whatsapp-scheduler.py: -------------------------------------------------------------------------------- 1 | """ 2 | Author - Richmond Nyamekye 3 | 4 | install requirements: python -m pip install pywhatkit 5 | 6 | Schedule a whatsapp message to be sent at your convenience 7 | 8 | """ 9 | import pywhatkit 10 | 11 | 12 | def send_msg(phone: str, msg: str, hour: int, minute: int) -> None: 13 | pywhatkit.sendwhatmsg(phone, msg, hour, minute) 14 | 15 | 16 | def send_whatmsg_to_group(group: str, msg: str, hour: int, minute: int) -> None: 17 | pywhatkit.sendwhatmsg_to_group(group, msg, hour, minute) 18 | 19 | 20 | def main(): 21 | msg_type = int(input("Enter 1 to send a message to a USER and 2 to a GROUP: ")) 22 | if msg_type == 1: 23 | phone = input("Enter phone number: ") 24 | # make changes to suit your needs 25 | if phone[0] == "0": 26 | phone = phone[1::] 27 | while True: 28 | if len(phone) < 9: 29 | raise ValueError("Invalid phone number: ") 30 | else: 31 | break 32 | phone = f"+233{phone}" 33 | elif msg_type == 2: 34 | group = input("Enter group to send message: ") 35 | msg = str(input("Enter message: ")) 36 | hour = int(input("Enter the time in hour: ")) 37 | minute = int(input("Enter the time in minute: ")) 38 | 39 | if msg_type == 1: 40 | send_msg(phone, msg, hour, minute) 41 | elif msg_type == 2: 42 | send_whatmsg_to_group(group, msg, hour, minute) 43 | 44 | 45 | if __name__ == "__main__": 46 | main() 47 | -------------------------------------------------------------------------------- /Web and Automation and Networking/youtube_downloader/youtube_downloader.py: -------------------------------------------------------------------------------- 1 | # Please install pytube using "pip install pytube" for this to work 2 | from pytube import YouTube 3 | 4 | url = input("YouTube link to download: ") 5 | 6 | try: 7 | print("Checking YouTube link...") 8 | yt = YouTube(url) 9 | print("Video is available! Downloading...") 10 | # This downloads the highest resolution video stream 11 | yt.streams.filter(progressive=True, file_extension='mp4').order_by('resolution').desc().first().download() 12 | print("Done downloading video!") 13 | except: 14 | print("Video at the provided link is unavailable!") 15 | -------------------------------------------------------------------------------- /anagrams.py: -------------------------------------------------------------------------------- 1 | #from itertools import permutations 2 | class Solution: 3 | def countAnagrams(self, s: str) -> int: 4 | mod= 10**9 + 7 5 | #splitting the words of string s in list w 6 | w=s.split(" ") 7 | a=[] 8 | #then iterating the words in list and appending the permutation of the word to list a 9 | for i in w: 10 | a.append(Solution.perm(i)) 11 | #multiplying the elements of list to return the total count of Anagrams 12 | result = 1 13 | for num in a: 14 | result *= num 15 | return result % mod 16 | 17 | #function to calculate the permutation of a given string 18 | def perm(inputt): 19 | char_counts = Counter(inputt) 20 | total_permutations = factorial(len(inputt)) 21 | denominator = 1 22 | for i in char_counts.values(): 23 | denominator *= factorial(i) 24 | return total_permutations // denominator 25 | -------------------------------------------------------------------------------- /data_structures/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/data_structures/__init__.py -------------------------------------------------------------------------------- /data_structures/binary_tree/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/data_structures/binary_tree/__init__.py -------------------------------------------------------------------------------- /data_structures/binary_tree/diameter_of_binary_tree.py.py: -------------------------------------------------------------------------------- 1 | class TreeNode: 2 | ''' 3 | Tree Node 4 | ''' 5 | def __init__(self, val=0, left=None, right=None): 6 | self.val = val 7 | self.left = left 8 | self.right = right 9 | 10 | class Solution: 11 | def __init__(self): 12 | self.max = 0 13 | def Diameter(self, root: TreeNode) -> int: 14 | if root is None: return 0 15 | def traverse(root): 16 | if root is None: return 0 17 | left = traverse(root.left) 18 | right = traverse(root.right) 19 | if left + right > self.max: 20 | self.max = left+right 21 | return max(left, right) + 1 22 | traverse(root) 23 | return self.max 24 | 25 | if __name__ == '__main__': 26 | root = TreeNode(10) 27 | root.left = TreeNode(11) 28 | root.left.left = TreeNode(2) 29 | root.left.right = TreeNode(31) 30 | root.right = TreeNode(12) 31 | 32 | print(Solution().Diameter(root)) -------------------------------------------------------------------------------- /data_structures/bubblesort.py: -------------------------------------------------------------------------------- 1 | # Python program for implementation of Bubble Sort 2 | 3 | def bubbleSort(arr): 4 | n = len(arr) 5 | 6 | # Traverse through all array elements 7 | for i in range(n): 8 | 9 | # Last i elements are already in place 10 | for j in range(0, n-i-1): 11 | 12 | # traverse the array from 0 to n-i-1 13 | # Swap if the element found is greater 14 | # than the next element 15 | if arr[j] > arr[j+1] : 16 | arr[j], arr[j+1] = arr[j+1], arr[j] 17 | 18 | # Driver code to test above 19 | arr = [64, 34, 25, 12, 22, 11, 90] 20 | 21 | bubbleSort(arr) 22 | 23 | print ("Sorted array is:") 24 | for i in range(len(arr)): 25 | print ("%d" %arr[i]), 26 | -------------------------------------------------------------------------------- /data_structures/dfs_Python/dfs.py: -------------------------------------------------------------------------------- 1 | # Python program to print DFS traversal for complete graph 2 | from collections import defaultdict 3 | 4 | # This class represents a directed graph using adjacency 5 | # list representation 6 | class Graph: 7 | 8 | # Constructor 9 | def __init__(self): 10 | 11 | # default dictionary to store graph 12 | self.graph = defaultdict(list) 13 | 14 | # function to add an edge to graph 15 | def addEdge(self,u,v): 16 | self.graph[u].append(v) 17 | 18 | # A function used by DFS 19 | def DFSUtil(self, v, visited): 20 | 21 | # Mark the current node as visited and print it 22 | visited[v]= True 23 | print v, 24 | 25 | # Recur for all the vertices adjacent to 26 | # this vertex 27 | for i in self.graph[v]: 28 | if visited[i] == False: 29 | self.DFSUtil(i, visited) 30 | 31 | 32 | # The function to do DFS traversal. It uses 33 | # recursive DFSUtil() 34 | def DFS(self): 35 | V = len(self.graph) #total vertices 36 | 37 | # Mark all the vertices as not visited 38 | visited =[False]*(V) 39 | 40 | # Call the recursive helper function to print 41 | # DFS traversal starting from all vertices one 42 | # by one 43 | for i in range(V): 44 | if visited[i] == False: 45 | self.DFSUtil(i, visited) 46 | 47 | 48 | # Driver code 49 | # Create a graph given in the above diagram 50 | g = Graph() 51 | g.addEdge(0, 1) 52 | g.addEdge(0, 2) 53 | g.addEdge(1, 2) 54 | g.addEdge(2, 0) 55 | g.addEdge(2, 3) 56 | g.addEdge(3, 3) 57 | 58 | print "Following is Depth First Traversal" 59 | g.DFS() 60 | 61 | 62 | -------------------------------------------------------------------------------- /data_structures/diamond_asterisk.py: -------------------------------------------------------------------------------- 1 | s=6 2 | k=3*s-3 3 | for i in range(0,s): 4 | for j in range(0,k): 5 | print(end=" ") 6 | k-=1 7 | for j in range(0,i+1): 8 | print("*",end=" ") 9 | print(" ") 10 | print(" HACKTOBERFEST") 11 | for i in range(s,-1,-1): 12 | for j in range(k+1,0,-1): 13 | print(end=" ") 14 | k+=1 15 | for j in range(1,i+1): 16 | print("*",end=" ") 17 | print(" ") 18 | -------------------------------------------------------------------------------- /data_structures/linked_list/from_sequence.py: -------------------------------------------------------------------------------- 1 | # Recursive Prorgam to create a Linked List from a sequence and 2 | # print a string representation of it. 3 | 4 | 5 | class Node: 6 | def __init__(self, data=None): 7 | self.data = data 8 | self.next = None 9 | 10 | def __repr__(self): 11 | """Returns a visual representation of the node and all its following nodes.""" 12 | string_rep = "" 13 | temp = self 14 | while temp: 15 | string_rep += f"<{temp.data}> ---> " 16 | temp = temp.next 17 | string_rep += "" 18 | return string_rep 19 | 20 | 21 | def make_linked_list(elements_list): 22 | """Creates a Linked List from the elements of the given sequence 23 | (list/tuple) and returns the head of the Linked List.""" 24 | 25 | # if elements_list is empty 26 | if not elements_list: 27 | raise Exception("The Elements List is empty") 28 | 29 | # Set first element as Head 30 | head = Node(elements_list[0]) 31 | current = head 32 | # Loop through elements from position 1 33 | for data in elements_list[1:]: 34 | current.next = Node(data) 35 | current = current.next 36 | return head 37 | 38 | 39 | list_data = [1, 3, 5, 32, 44, 12, 43] 40 | print(f"List: {list_data}") 41 | print("Creating Linked List from List.") 42 | linked_list = make_linked_list(list_data) 43 | print("Linked List:") 44 | print(linked_list) 45 | -------------------------------------------------------------------------------- /data_structures/linked_list/linkedlist.py: -------------------------------------------------------------------------------- 1 | # Python program to detect loop in the linked list using slow and fast pointers 2 | 3 | # Node class 4 | 5 | 6 | class Node: 7 | 8 | # Constructor to initialize the node object 9 | def __init__(self, data): 10 | self.data = data 11 | self.next = None 12 | 13 | 14 | class LinkedList: 15 | 16 | # Function to initialize head 17 | def __init__(self): 18 | self.head = None 19 | 20 | # Function to insert a new node at the beginning 21 | def push(self, new_data): 22 | new_node = Node(new_data) 23 | new_node.next = self.head 24 | self.head = new_node 25 | 26 | # Utility function to print it the linked LinkedList 27 | def printList(self): 28 | temp = self.head 29 | while(temp): 30 | print temp.data, 31 | temp = temp.next 32 | 33 | def detectLoop(self): 34 | slow_p = self.head 35 | fast_p = self.head 36 | while(slow_p and fast_p and fast_p.next): 37 | slow_p = slow_p.next 38 | fast_p = fast_p.next.next 39 | if slow_p == fast_p: 40 | return 1 41 | return 0 42 | 43 | 44 | # Driver program for testing 45 | llist = LinkedList() 46 | llist.push(20) 47 | llist.push(4) 48 | llist.push(15) 49 | llist.push(10) 50 | 51 | # Create a loop for testing 52 | llist.head.next.next.next.next = llist.head 53 | if(llist.detectLoop()): 54 | print "Found Loop" 55 | else: 56 | print "No Loop" 57 | -------------------------------------------------------------------------------- /data_structures/linked_list/swap_nodes.py: -------------------------------------------------------------------------------- 1 | from typing import Any 2 | 3 | 4 | class Node: 5 | def __init__(self, data: Any): 6 | self.data = data 7 | self.next = None 8 | 9 | 10 | class LinkedList: 11 | def __init__(self): 12 | self.head = None 13 | 14 | def print_list(self): 15 | temp = self.head 16 | while temp is not None: 17 | print(temp.data, end=" ") 18 | temp = temp.next 19 | print() 20 | 21 | # adding nodes 22 | def push(self, new_data: Any): 23 | new_node = Node(new_data) 24 | new_node.next = self.head 25 | self.head = new_node 26 | 27 | # swapping nodes 28 | def swap_nodes(self, node_data_1, node_data_2): 29 | if node_data_1 == node_data_2: 30 | return 31 | else: 32 | node_1 = self.head 33 | while node_1 is not None and node_1.data != node_data_1: 34 | node_1 = node_1.next 35 | 36 | node_2 = self.head 37 | while node_2 is not None and node_2.data != node_data_2: 38 | node_2 = node_2.next 39 | 40 | if node_1 is None or node_2 is None: 41 | return 42 | 43 | node_1.data, node_2.data = node_2.data, node_1.data 44 | 45 | 46 | if __name__ == "__main__": 47 | ll = LinkedList() 48 | for i in range(5, 0, -1): 49 | ll.push(i) 50 | 51 | ll.print_list() 52 | 53 | ll.swap_nodes(1, 4) 54 | print("After swapping") 55 | ll.print_list() 56 | -------------------------------------------------------------------------------- /data_structures/printAGivenDoublyLinkedListInReverseOrder.py: -------------------------------------------------------------------------------- 1 | class Node(object): 2 | # Singly linked node 3 | def __init__(self, data=None, next=None, prev=None): 4 | self.data = data 5 | self.next = next 6 | self.prev = prev 7 | 8 | class doubly_linked_list(object): 9 | def __init__(self): 10 | self.head = None 11 | self.tail = None 12 | self.count = 0 13 | 14 | def append_item(self, data): 15 | # Append an item 16 | new_item = Node(data, None, None) 17 | if self.head is None: 18 | self.head = new_item 19 | self.tail = self.head 20 | else: 21 | new_item.prev = self.tail 22 | self.tail.next = new_item 23 | self.tail = new_item 24 | self.count += 1 25 | 26 | def iter(self): 27 | # Iterate the list 28 | current = self.head 29 | while current: 30 | item_val = current.data 31 | current = current.next 32 | yield item_val 33 | 34 | def print_foward(self): 35 | for node in self.iter(): 36 | print(node) 37 | 38 | def reverse(self): 39 | """ Reverse linked list. """ 40 | current = self.head 41 | while current: 42 | temp = current.next 43 | current.next = current.prev 44 | current.prev = temp 45 | current = current.prev 46 | temp = self.head 47 | self.head = self.tail 48 | self.tail = temp 49 | 50 | items = doubly_linked_list() 51 | items.append_item('PHP') 52 | items.append_item('Python') 53 | items.append_item('C#') 54 | items.append_item('C++') 55 | items.append_item('Java') 56 | items.append_item('SQL') 57 | 58 | print("Reverse list ") 59 | items.reverse() 60 | items.print_foward() 61 | -------------------------------------------------------------------------------- /data_structures/queue/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/data_structures/queue/__init__.py -------------------------------------------------------------------------------- /data_structures/queue/queue_on_list.py: -------------------------------------------------------------------------------- 1 | """Queue represented by a Python list""" 2 | 3 | 4 | class Queue: 5 | def __init__(self): 6 | self.entries = [] 7 | self.length = 0 8 | self.front = 0 9 | 10 | def __str__(self): 11 | printed = "<" + str(self.entries)[1:-1] + ">" 12 | return printed 13 | 14 | """Enqueues {@code item} 15 | @param item 16 | item to enqueue""" 17 | 18 | def put(self, item): 19 | self.entries.append(item) 20 | self.length = self.length + 1 21 | 22 | """Dequeues {@code item} 23 | @requirement: |self.length| > 0 24 | @return dequeued 25 | item that was dequeued""" 26 | 27 | def get(self): 28 | self.length = self.length - 1 29 | dequeued = self.entries[self.front] 30 | # self.front-=1 31 | # self.entries = self.entries[self.front:] 32 | self.entries = self.entries[1:] 33 | return dequeued 34 | 35 | """Rotates the queue {@code rotation} times 36 | @param rotation 37 | number of times to rotate queue""" 38 | 39 | def rotate(self, rotation): 40 | for i in range(rotation): 41 | self.put(self.get()) 42 | 43 | """Enqueues {@code item} 44 | @return item at front of self.entries""" 45 | 46 | def get_front(self): 47 | return self.entries[0] 48 | 49 | """Returns the length of this.entries""" 50 | 51 | def size(self): 52 | return self.length 53 | -------------------------------------------------------------------------------- /data_structures/queue/queue_on_pseudo_stack.py: -------------------------------------------------------------------------------- 1 | """Queue represented by a pseudo stack (represented by a list with pop and append)""" 2 | 3 | 4 | class Queue: 5 | def __init__(self): 6 | self.stack = [] 7 | self.length = 0 8 | 9 | def __str__(self): 10 | printed = "<" + str(self.stack)[1:-1] + ">" 11 | return printed 12 | 13 | """Enqueues {@code item} 14 | @param item 15 | item to enqueue""" 16 | 17 | def put(self, item): 18 | self.stack.append(item) 19 | self.length = self.length + 1 20 | 21 | """Dequeues {@code item} 22 | @requirement: |self.length| > 0 23 | @return dequeued 24 | item that was dequeued""" 25 | 26 | def get(self): 27 | self.rotate(1) 28 | dequeued = self.stack[self.length - 1] 29 | self.stack = self.stack[:-1] 30 | self.rotate(self.length - 1) 31 | self.length = self.length - 1 32 | return dequeued 33 | 34 | """Rotates the queue {@code rotation} times 35 | @param rotation 36 | number of times to rotate queue""" 37 | 38 | def rotate(self, rotation): 39 | for i in range(rotation): 40 | temp = self.stack[0] 41 | self.stack = self.stack[1:] 42 | self.put(temp) 43 | self.length = self.length - 1 44 | 45 | """Reports item at the front of self 46 | @return item at front of self.stack""" 47 | 48 | def front(self): 49 | front = self.get() 50 | self.put(front) 51 | self.rotate(self.length - 1) 52 | return front 53 | 54 | """Returns the length of this.stack""" 55 | 56 | def size(self): 57 | return self.length 58 | -------------------------------------------------------------------------------- /data_structures/stacks/__init__.py: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/data_structures/stacks/__init__.py -------------------------------------------------------------------------------- /data_structures/stacks/balanced_parentheses.py: -------------------------------------------------------------------------------- 1 | from .stack import Stack 2 | 3 | 4 | def balanced_parentheses(parentheses: str) -> bool: 5 | """Use a stack to check if a string of parentheses is balanced. 6 | >>> balanced_parentheses("([]{})") 7 | True 8 | >>> balanced_parentheses("[()]{}{[()()]()}") 9 | True 10 | >>> balanced_parentheses("[(])") 11 | False 12 | >>> balanced_parentheses("1+2*3-4") 13 | True 14 | >>> balanced_parentheses("") 15 | True 16 | """ 17 | stack: Stack[str] = Stack() 18 | bracket_pairs = {"(": ")", "[": "]", "{": "}"} 19 | for bracket in parentheses: 20 | if bracket in bracket_pairs: 21 | stack.push(bracket) 22 | elif bracket in (")", "]", "}"): 23 | if stack.is_empty() or bracket_pairs[stack.pop()] != bracket: 24 | return False 25 | return stack.is_empty() 26 | 27 | 28 | if __name__ == "__main__": 29 | from doctest import testmod 30 | 31 | testmod() 32 | 33 | examples = ["((()))", "((())", "(()))"] 34 | print("Balanced parentheses demonstration:\n") 35 | for example in examples: 36 | not_str = "" if balanced_parentheses(example) else "not " 37 | print(f"{example} is {not_str}balanced") 38 | -------------------------------------------------------------------------------- /data_structures/stacks/evaluate_postfix_notations.py: -------------------------------------------------------------------------------- 1 | """ 2 | The Reverse Polish Nation also known as Polish postfix notation 3 | or simply postfix notation. 4 | https://en.wikipedia.org/wiki/Reverse_Polish_notation 5 | Classic examples of simple stack implementations 6 | Valid operators are +, -, *, /. 7 | Each operand may be an integer or another expression. 8 | """ 9 | from __future__ import annotations 10 | 11 | from typing import Any 12 | 13 | 14 | def evaluate_postfix(postfix_notation: list) -> int: 15 | """ 16 | >>> evaluate_postfix(["2", "1", "+", "3", "*"]) 17 | 9 18 | >>> evaluate_postfix(["4", "13", "5", "/", "+"]) 19 | 6 20 | >>> evaluate_postfix([]) 21 | 0 22 | """ 23 | if not postfix_notation: 24 | return 0 25 | 26 | operations = {"+", "-", "*", "/"} 27 | stack: list[Any] = [] 28 | 29 | for token in postfix_notation: 30 | if token in operations: 31 | b, a = stack.pop(), stack.pop() 32 | if token == "+": 33 | stack.append(a + b) 34 | elif token == "-": 35 | stack.append(a - b) 36 | elif token == "*": 37 | stack.append(a * b) 38 | else: 39 | if a * b < 0 and a % b != 0: 40 | stack.append(a // b + 1) 41 | else: 42 | stack.append(a // b) 43 | else: 44 | stack.append(int(token)) 45 | 46 | return stack.pop() 47 | 48 | 49 | if __name__ == "__main__": 50 | import doctest 51 | 52 | doctest.testmod() 53 | -------------------------------------------------------------------------------- /data_structures/stacks/prefix_evaluation.py: -------------------------------------------------------------------------------- 1 | """ 2 | Python3 program to evaluate a prefix expression. 3 | """ 4 | 5 | calc = { 6 | "+": lambda x, y: x + y, 7 | "-": lambda x, y: x - y, 8 | "*": lambda x, y: x * y, 9 | "/": lambda x, y: x / y, 10 | } 11 | 12 | 13 | def is_operand(c): 14 | """ 15 | Return True if the given char c is an operand, e.g. it is a number 16 | 17 | >>> is_operand("1") 18 | True 19 | >>> is_operand("+") 20 | False 21 | """ 22 | return c.isdigit() 23 | 24 | 25 | def evaluate(expression): 26 | """ 27 | Evaluate a given expression in prefix notation. 28 | Asserts that the given expression is valid. 29 | 30 | >>> evaluate("+ 9 * 2 6") 31 | 21 32 | >>> evaluate("/ * 10 2 + 4 1 ") 33 | 4.0 34 | """ 35 | stack = [] 36 | 37 | # iterate over the string in reverse order 38 | for c in expression.split()[::-1]: 39 | 40 | # push operand to stack 41 | if is_operand(c): 42 | stack.append(int(c)) 43 | 44 | else: 45 | # pop values from stack can calculate the result 46 | # push the result onto the stack again 47 | o1 = stack.pop() 48 | o2 = stack.pop() 49 | stack.append(calc[c](o1, o2)) 50 | 51 | return stack.pop() 52 | 53 | 54 | # Driver code 55 | if __name__ == "__main__": 56 | test_expression = "+ 9 * 2 6" 57 | print(evaluate(test_expression)) 58 | 59 | test_expression = "/ * 10 2 + 4 1 " 60 | print(evaluate(test_expression)) 61 | -------------------------------------------------------------------------------- /data_structures/stacks/stock_span_problem.py: -------------------------------------------------------------------------------- 1 | """ 2 | The stock span problem is a financial problem where we have a series of n daily 3 | price quotes for a stock and we need to calculate span of stock's price for all n days. 4 | 5 | The span Si of the stock's price on a given day i is defined as the maximum 6 | number of consecutive days just before the given day, for which the price of the stock 7 | on the current day is less than or equal to its price on the given day. 8 | """ 9 | 10 | 11 | def calculateSpan(price, S): 12 | 13 | n = len(price) 14 | # Create a stack and push index of fist element to it 15 | st = [] 16 | st.append(0) 17 | 18 | # Span value of first element is always 1 19 | S[0] = 1 20 | 21 | # Calculate span values for rest of the elements 22 | for i in range(1, n): 23 | 24 | # Pop elements from stack while stack is not 25 | # empty and top of stack is smaller than price[i] 26 | while len(st) > 0 and price[st[0]] <= price[i]: 27 | st.pop() 28 | 29 | # If stack becomes empty, then price[i] is greater 30 | # than all elements on left of it, i.e. price[0], 31 | # price[1], ..price[i-1]. Else the price[i] is 32 | # greater than elements after top of stack 33 | S[i] = i + 1 if len(st) <= 0 else (i - st[0]) 34 | 35 | # Push this element to stack 36 | st.append(i) 37 | 38 | 39 | # A utility function to print elements of array 40 | def printArray(arr, n): 41 | for i in range(0, n): 42 | print(arr[i], end=" ") 43 | 44 | 45 | # Driver program to test above function 46 | price = [10, 4, 5, 90, 120, 80] 47 | S = [0 for i in range(len(price) + 1)] 48 | 49 | # Fill the span values in array S[] 50 | calculateSpan(price, S) 51 | 52 | # Print the calculated span values 53 | printArray(S, len(price)) 54 | -------------------------------------------------------------------------------- /drinking/drink.py: -------------------------------------------------------------------------------- 1 | from socket import timeout 2 | import time 3 | from turtle import title 4 | from pip import main 5 | from plyer import notification 6 | 7 | if __name__ == "__main__": 8 | while True: 9 | notification.notify( 10 | title = "Please Drink Water!!", 11 | message = '''Health experts commonly recommend eight 8-ounce glasses, which equals about 2 liters, or half a gallon a day. This is called the 8x8 rule and is very easy to remember.''', 12 | app_icon = ("C:\\Users\\jaymin\\Desktop\\Python Projects\\Water notification system\\icon.ico"), 13 | timeout = 10 14 | ) 15 | time.sleep(60*60) -------------------------------------------------------------------------------- /drinking/icon.ico: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Abipravi1/Hacktoberfest2022-python/fe69482d8dc67372efd397e2e2877a85aacfc884/drinking/icon.ico -------------------------------------------------------------------------------- /dynamic_sort.py: -------------------------------------------------------------------------------- 1 | 2 | #Name: Srishti Chauhan 3 | #Problem: Hackerrank Dynamic-sort 4 | 5 | from numpy import sort 6 | #!/bin/python3 7 | 8 | import math 9 | import os 10 | import random 11 | import re 12 | import sys 13 | 14 | # 15 | # Complete the 'dynamicArray' function below. 16 | # 17 | # The function is expected to return an INTEGER_ARRAY. 18 | # The function accepts following parameters: 19 | # 1. INTEGER n 20 | # 2. 2D_INTEGER_ARRAY queries 21 | # 22 | 23 | def dynamicArray(n, queries): 24 | # Write your code here 25 | 26 | if __name__ == '__main__': 27 | fptr = open(os.environ['OUTPUT_PATH'], 'w') 28 | 29 | first_multiple_input = input().rstrip().split() 30 | 31 | n = int(first_multiple_input[0]) 32 | 33 | q = int(first_multiple_input[1]) 34 | 35 | queries = [] 36 | 37 | for _ in range(q): 38 | queries.append(list(map(int, input().rstrip().split()))) 39 | 40 | result = dynamicArray(n, queries) 41 | 42 | fptr.write('\n'.join(map(str, result))) 43 | fptr.write('\n') 44 | 45 | fptr.close() 46 | -------------------------------------------------------------------------------- /gps/coordinates.py: -------------------------------------------------------------------------------- 1 | latitude = 2818.647579 2 | longitude = 07700.768767 3 | 4 | def convertDMtoDD(value): 5 | value = value%100 6 | value_fraction = value 7 | value_dd = value_fraction*100/60 8 | print(value_dd) 9 | return value_dd 10 | convertDMtoDD(latitude) 11 | print("\n") 12 | convertDMtoDD(longitude) 13 | -------------------------------------------------------------------------------- /gps/findonmap.py: -------------------------------------------------------------------------------- 1 | import folium 2 | 3 | map = folium.Map(location=[28.18, 77.00]) 4 | folium.Marker(location=[28.18, 77.00]).add_to(map) 5 | 6 | map.save('display.html') 7 | 8 | -------------------------------------------------------------------------------- /gps/gps.py: -------------------------------------------------------------------------------- 1 | import socket 2 | import time 3 | 4 | host = "0.0.0.0" 5 | port = 5555 6 | # socket will work on UDP protocol 7 | # initializing the socket 8 | soc = socket.socket(socket.AF_INET, socket.SOCK_DGRAM) 9 | # bind the host and the port to communicate 10 | soc.bind((host, port)) 11 | # the file where the gps data will go 12 | filestr = open('gps_data.txt', 'w') 13 | 14 | try: 15 | # loop which will continuously get the gps data 16 | while True: 17 | print("waiting...") 18 | # this is used to receive the message UDP protocol 19 | message, address = soc.recvfrom(4200) # number of bytes needed to read = 4200 20 | # writing the gps coordinates in this file 21 | filestr.write(str(message) + "\n") 22 | time.sleep(1) 23 | print("received message: ", str(message)) 24 | 25 | finally: 26 | filestr.close() 27 | -------------------------------------------------------------------------------- /gps/visual_track/requirements.txt: -------------------------------------------------------------------------------- 1 | folium~=0.12.1.post1 -------------------------------------------------------------------------------- /gps/visual_track/track_visu.py: -------------------------------------------------------------------------------- 1 | import folium 2 | 3 | gps_list = [] 4 | vib_red_list = [] 5 | i = 0 6 | with open("track1.txt" ,"r" )as file: 7 | for elem in file: 8 | 9 | #print(elem) 10 | raw_str = elem.strip() 11 | raw_list = list(raw_str.split(",")) 12 | time_data = (raw_list[0:4]) 13 | lat = raw_list[4].replace("Latitude: ","").strip() 14 | lon = raw_list[5].replace("Longitude: ","").strip() 15 | alt = raw_list[6].replace("Altitude: ","").strip() 16 | vib = raw_list[14].strip() 17 | #gps_data = time_data, lat,lon,alt,vib 18 | gps_data = (float(lat), float(lon))#,float(vib)) 19 | gps_list.append(gps_data) 20 | if float(vib) > 1.3: 21 | data = (float(lat), float(lon),str("red"),vib) 22 | vib_red_list.append(data) 23 | 24 | 25 | i +=1 26 | 27 | 28 | #print(gps_list) 29 | 30 | m = folium.Map(location=gps_list[0], 31 | zoom_start=15) 32 | #make route 33 | loc = gps_list 34 | folium.PolyLine(loc, 35 | color= 'blue', 36 | weight=10, 37 | opacity=0.8).add_to(m) 38 | m 39 | 40 | for elem in vib_red_list: #add circle to bad points 41 | print(elem) 42 | marker = folium.CircleMarker(elem[:2],radius= 4,color=elem[2], popup="Attention" ) 43 | marker.add_to(m) 44 | 45 | 46 | m.save('route.html') -------------------------------------------------------------------------------- /merge_sort.py: -------------------------------------------------------------------------------- 1 | # Python program for implementation of MergeSort 2 | def mergeSort(arr): 3 | if len(arr) > 1: 4 | 5 | # Finding the mid of the array 6 | mid = len(arr)//2 7 | 8 | # Dividing the array elements 9 | L = arr[:mid] 10 | 11 | # into 2 halves 12 | R = arr[mid:] 13 | 14 | # Sorting the first half 15 | mergeSort(L) 16 | 17 | # Sorting the second half 18 | mergeSort(R) 19 | 20 | i = j = k = 0 21 | 22 | # Copy data to temp arrays L[] and R[] 23 | while i < len(L) and j < len(R): 24 | if L[i] <= R[j]: 25 | arr[k] = L[i] 26 | i += 1 27 | else: 28 | arr[k] = R[j] 29 | j += 1 30 | k += 1 31 | 32 | # Checking if any element was left 33 | while i < len(L): 34 | arr[k] = L[i] 35 | i += 1 36 | k += 1 37 | 38 | while j < len(R): 39 | arr[k] = R[j] 40 | j += 1 41 | k += 1 42 | 43 | # Code to print the list 44 | 45 | 46 | def printList(arr): 47 | for i in range(len(arr)): 48 | print(arr[i], end=" ") 49 | print() 50 | 51 | 52 | # Driver Code 53 | if __name__ == '__main__': 54 | arr = [12, 11, 13, 5, 6, 7] 55 | print("Given array is", end="\n") 56 | printList(arr) 57 | mergeSort(arr) 58 | print("Sorted array is: ", end="\n") 59 | printList(arr) 60 | -------------------------------------------------------------------------------- /pattern.py: -------------------------------------------------------------------------------- 1 | import turtle 2 | colors=['red','yellow','green','purple','blue','orange'] 3 | 4 | t= turtle.Pen() 5 | t.speed(10) 6 | turtle.bgcolor("black") 7 | 8 | for x in range(200): 9 | t.pencolor(colors[x%6]) 10 | t.width(x/100+1) 11 | t.forward(x) 12 | t.left(59) 13 | 14 | turtle.done() 15 | -------------------------------------------------------------------------------- /python zip file brute forcer: -------------------------------------------------------------------------------- 1 | import zipfile 2 | 3 | def crack_password(password_list, obj): 4 | // tracking line no. at which password is found 5 | idx = 0 6 | 7 | // open file in read byte mode only as "rockyou.txt" 8 | // file contains some special characters and hence 9 | // UnicodeDecodeError will be generated 10 | with open(password_list, 'rb') as file: 11 | for line in file: 12 | for word in line.split(): 13 | try: 14 | idx += 1 15 | obj.extractall(pwd=word) 16 | print("Password found at", idx) 17 | print("Password ", word.decode()) 18 | return True 19 | except: 20 | continue 21 | return False 22 | 23 | 24 | password_list = "rockyou.txt" 25 | 26 | zip_file = "adm.zip" 27 | 28 | // ZipFile object initialised 29 | obj = zipfile.ZipFile(zip_file) 30 | 31 | // count of number of words present in file 32 | cnt = len(list(open(password_list, "rb"))) 33 | 34 | print("There are total", cnt, 35 | "number of passwords to test") 36 | 37 | if crack_password(password_list, obj) == False: 38 | print("Password not found in this file") 39 | -------------------------------------------------------------------------------- /requirements.txt: -------------------------------------------------------------------------------- 1 | APScheduler==3.9.1 2 | async-generator==1.10 3 | attrs==22.1.0 4 | beautifulsoup4==4.11.1 5 | bs4==0.0.1 6 | certifi==2022.12.7 7 | cffi==1.15.1 8 | charset-normalizer==2.1.1 9 | colorama==0.4.5 10 | distlib==0.3.5 11 | filelock==3.7.1 12 | h11==0.13.0 13 | idna==3.4 14 | lxml==4.9.1 15 | oauthlib==3.2.1 16 | outcome==1.2.0 17 | platformdirs==2.5.2 18 | pycparser==2.21 19 | pygame==2.1.2 20 | PySocks==1.7.1 21 | python-dotenv==0.21.0 22 | pytz==2022.2.1 23 | pytz-deprecation-shim==0.1.0.post0 24 | requests==2.28.1 25 | requests-oauthlib==1.3.1 26 | selenium==4.4.3 27 | simpletwitter==1.2.8 28 | six==1.16.0 29 | sniffio==1.3.0 30 | sortedcontainers==2.4.0 31 | soupsieve==2.3.2.post1 32 | tqdm==4.64.1 33 | trio==0.21.0 34 | trio-websocket==0.9.2 35 | tweepy==4.10.1 36 | tzdata==2022.2 37 | tzlocal==4.2 38 | urllib3==1.26.12 39 | virtualenv==20.16.3 40 | virtualenvwrapper-win==1.2.7 41 | webdriver-manager==3.8.3 42 | wsproto==1.2.0 43 | -------------------------------------------------------------------------------- /resize.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | import argparse 4 | import imutils 5 | 6 | ap = argparse.ArgumentParser() 7 | ap.add_argument('-i', '--image', required=True, help='Path to the Image') 8 | 9 | args = vars(ap.parse_args()) 10 | 11 | image = cv2.imread(args['image']) 12 | cv2.imshow('Original Image', image) 13 | 14 | r = 300.0 / image.shape[1] 15 | dim = (300, int(image.shape[0] * r)) 16 | 17 | resized = imutils.resize(image, height=300) 18 | cv2.imshow('Resized (Height = 300)', resized) 19 | 20 | resized = imutils.resize(image, width=300) 21 | cv2.imshow('Resized (Width = 300)', resized) 22 | 23 | # resized = cv2.resize(image, dim, interpolation=cv2.INTER_AREA) 24 | # cv2.imshow('Reszed (Width) to 300', resized) 25 | # 26 | # r = 300.0 / image.shape[0] 27 | # dim = (int(image.shape[1] * r), 300) 28 | # 29 | # resized = cv2.resize(image, dim, interpolation=cv2.INTER_AREA) 30 | # cv2.imshow('Resized (Height) to 300', resized) 31 | 32 | cv2.waitKey(0) 33 | -------------------------------------------------------------------------------- /rock_paper_scissor.py: -------------------------------------------------------------------------------- 1 | import random 2 | 3 | user_action = input("Enter a choice (rock, paper, scissors): ") 4 | possible_actions = ["rock", "paper", "scissors"] 5 | computer_action = random.choice(possible_actions) 6 | print(f"\nYou chose {user_action}, computer chose {computer_action}.\n") 7 | 8 | if user_action == computer_action: 9 | print(f"Both players selected {user_action}. It's a tie!") 10 | elif user_action == "rock": 11 | if computer_action == "scissors": 12 | print("Rock smashes scissors! You win!") 13 | else: 14 | print("Paper covers rock! You lose.") 15 | elif user_action == "paper": 16 | if computer_action == "rock": 17 | print("Paper covers rock! You win!") 18 | else: 19 | print("Scissors cuts paper! You lose.") 20 | elif user_action == "scissors": 21 | if computer_action == "paper": 22 | print("Scissors cuts paper! You win!") 23 | else: 24 | print("Rock smashes scissors! You lose.") 25 | -------------------------------------------------------------------------------- /rotation.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import cv2 3 | import argparse 4 | import imutils 5 | 6 | ap = argparse.ArgumentParser() 7 | ap.add_argument('-i', '--image', required=True, help="Path to the Image") 8 | 9 | args = vars(ap.parse_args()) 10 | 11 | image = cv2.imread(args['image']) 12 | cv2.imshow('Original Image', image) 13 | 14 | rotated = imutils.rotate(image, 45) 15 | cv2.imshow('Rotated by 45 Degrees', rotated) 16 | 17 | 18 | (h, w) = image.shape[:2] 19 | center = (w // 2, h // 2) 20 | rotated = imutils.rotate(image, 45, center=(0, h), scale=0.5) 21 | cv2.imshow('Scaled to half & Rotated by 45 Degrees at Bottom Left', rotated) 22 | 23 | # M = cv2.getRotationMatrix2D(center, 45, 1.0) 24 | # rotated = cv2.warpAffine(image, M, (w, h)) 25 | # cv2.imshow('Rotated by 45 Degrees', rotated) 26 | # 27 | # M = cv2.getRotationMatrix2D(center, -90, 1.0) 28 | # rotated = cv2.warpAffine(image, M, (w, h)) 29 | # cv2.imshow('Rotated by -90 Degrees', rotated) 30 | # 31 | # M = cv2.getRotationMatrix2D((0, h), 45, 0.5) 32 | # rotated = cv2.warpAffine(image, M, (w, h)) 33 | # cv2.imshow('Resized by half and Rotated by 45 Degrees from Bottom Left', rotated) 34 | 35 | cv2.waitKey(0) 36 | -------------------------------------------------------------------------------- /translation.py: -------------------------------------------------------------------------------- 1 | import numpy as np 2 | import argparse 3 | import imutils 4 | import cv2 5 | 6 | ap = argparse.ArgumentParser() 7 | ap.add_argument("-i", '--image', required=True, help='Path to the Image') 8 | 9 | args = vars(ap.parse_args()) 10 | 11 | image = cv2.imread(args['image']) 12 | cv2.imshow('Original Image', image) 13 | 14 | shifted = imutils.translate(image, 0, 100) 15 | cv2.imshow('Shifted Down', shifted) 16 | 17 | # M = np.float32([[1, 0, 25], [0, 1, 50]]) 18 | # shifted = cv2.warpAffine(image, M, (image.shape[1], image.shape[0])) 19 | # cv2.imshow('Shifted Down and Right', shifted) 20 | # 21 | # M = np.float32([[1, 0, -50], [0, 1, -90]]) 22 | # shifted = cv2.warpAffine(image, M, (image.shape[1], image.shape[0])) 23 | # cv2.imshow('Shifted Up and Left', shifted) 24 | 25 | cv2.waitKey(0) 26 | -------------------------------------------------------------------------------- /translator.py: -------------------------------------------------------------------------------- 1 | from translate import Translator 2 | 3 | def translate(from_language, to_language, input_text): 4 | translator= Translator(from_lang=from_language,to_lang=to_language) 5 | translation = translator.translate(input_text) 6 | return translation 7 | 8 | from_language = input("Enter base language: ") 9 | to_language = input("Enter translated language: ") 10 | source_text = input("Enter text to translate: ") 11 | print("Tranlated test is: ", translate(from_language, to_language, source_text)) 12 | --------------------------------------------------------------------------------