├── .gitignore ├── LICENSE ├── README.md ├── fizzbuzz.py ├── reverse-word-and-swap-case.py └── string-representation-of-objects.py /.gitignore: -------------------------------------------------------------------------------- 1 | .idea 2 | out 3 | venv 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2020 anishLearnsToCode 2 | 3 | Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated 4 | documentation files (the "Software"), to deal in the Software without restriction, including without limitation the 5 | rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit 6 | persons to whom the Software is furnished to do so, subject to the following conditions: 7 | 8 | The above copyright notice and this permission notice shall be included in all copies or substantial portions of the 9 | Software. 10 | 11 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE 12 | WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR 13 | COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR 14 | OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 15 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # HackerRank Python (Basic) Skill Certification Test 2 | 3 | ![problems-solved](https://img.shields.io/badge/Problems%20Solved-2/2-1abc9c.svg) 4 | [![cp](https://img.shields.io/badge/also%20see-Competitve%20Programming-1f72ff.svg)](https://github.com/anishLearnsToCode/competitive-programming) 5 | [![cp](https://img.shields.io/badge/also%20see-Other%20Certifications-1f72ff.svg)](https://github.com/anishLearnsToCode/competitive-programming#certifications) 6 | 7 | Took this test on HackerRank [here](https://www.hackerrank.com/skills-verification) 8 | on __14th July 2020__. 9 | Certificate can be viewed [here](https://www.hackerrank.com/certificates/306084b1c4cc) 10 | 11 | ## Programs 12 | - [FizzBuzz (Practice Question - Ungraded)](fizzbuzz.py) 13 | - [Reverse Word & Swap Case](reverse-word-and-swap-case.py) 14 | - [String Representations of Objects](string-representation-of-objects.py) 15 | -------------------------------------------------------------------------------- /fizzbuzz.py: -------------------------------------------------------------------------------- 1 | #!/bin/python3 2 | 3 | import math 4 | import os 5 | import random 6 | import re 7 | import sys 8 | 9 | 10 | # 11 | # Complete the 'fizzBuzz' function below. 12 | # 13 | # The function accepts INTEGER n as parameter. 14 | # 15 | 16 | def fizzBuzz(n): 17 | for number in range(1, n + 1): 18 | if number % 3 == 0 and number % 5 == 0: 19 | print('FizzBuzz') 20 | elif number % 3 == 0: 21 | print('Fizz') 22 | elif number % 5 == 0: 23 | print('Buzz') 24 | else: 25 | print(number) 26 | 27 | 28 | if __name__ == '__main__': 29 | n = int(input().strip()) 30 | 31 | fizzBuzz(n) 32 | -------------------------------------------------------------------------------- /reverse-word-and-swap-case.py: -------------------------------------------------------------------------------- 1 | def swap_case(word): 2 | return ''.join([character.lower() if character.isupper() else character.upper() for character in word]) 3 | 4 | 5 | def reverse_words_order_and_swap_cases(sentence): 6 | words = sentence.split(' ')[::-1] 7 | return ' '.join([swap_case(word) for word in words]) 8 | 9 | 10 | print(swap_case('hello')) 11 | -------------------------------------------------------------------------------- /string-representation-of-objects.py: -------------------------------------------------------------------------------- 1 | class Car: 2 | def __init__(self, max_speed, unit): 3 | self.max_speed = max_speed 4 | self.unit = unit 5 | 6 | def __str__(self): 7 | return 'Car with the maximum speed of ' + str(self.max_speed) + ' ' + str(self.unit) 8 | 9 | 10 | class Boat: 11 | def __init__(self, max_speed): 12 | self.max_speed = max_speed 13 | 14 | def __str__(self): 15 | return 'Boat with the maximum speed of ' + str(self.max_speed) + ' knots' 16 | 17 | 18 | car = Car(120, 'km/h') 19 | print(car) 20 | --------------------------------------------------------------------------------