Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/psingh12354/hackerrank-certification
HackerRank Certification Question
https://github.com/psingh12354/hackerrank-certification
adder anagram average class code gaming hackerrank-certification hackerrank-solutions java laptop problem-solving python python-shape python3 reverse shape solution sql string test
Last synced: 6 days ago
JSON representation
HackerRank Certification Question
- Host: GitHub
- URL: https://github.com/psingh12354/hackerrank-certification
- Owner: Psingh12354
- Created: 2020-06-20T13:17:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2023-09-06T04:17:14.000Z (over 1 year ago)
- Last Synced: 2024-12-11T10:21:39.301Z (14 days ago)
- Topics: adder, anagram, average, class, code, gaming, hackerrank-certification, hackerrank-solutions, java, laptop, problem-solving, python, python-shape, python3, reverse, shape, solution, sql, string, test
- Language: Python
- Homepage:
- Size: 32.2 KB
- Stars: 93
- Watchers: 6
- Forks: 117
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
### Python average function
```python
import math
import os
import random
import re
import sysdef avg(*nums):
return sum(nums)/len(nums)if __name__ == '__main__':
```### Python Reverse Word and Swap Cases
```python
#!/bin/pythonimport math
import os
import random
import re
import sys#
# Complete the 'reverse_words_order_and_swap_cases' function below.
#
# The function is expected to return a STRING.
# The function accepts STRING sentence as parameter.
#def reverse_words_order_and_swap_cases(sentence):
word_list = sentence.split()
reversed_list = word_list[:: -1]
reversed_sentence = " ".join(reversed_list)
return reversed_sentence.swapcase()if __name__ == '__main__':
fptr = open(os.environ['OUTPUT_PATH'], 'w')sentence = raw_input()
result = reverse_words_order_and_swap_cases(sentence)
fptr.write(result + '\n')
fptr.close()
```
### Python Shape Classes with Area Method
```python
#!/bin/python3import math
import os
import random
import re
import sysclass Rectangle:
def __init__(self,breadth,length):
self.breadth=breadth
self.length=length
def area(self):
return self.breadth*self.lengthpass
class Circle:
def __init__(self,radius):
self.radius=radius
def area(self):
return math.pi*(self.radius**2)
pass
if __name__ == '__main__':
```## Problem Solving
### Gaming laptop battery life
```python
def getBattery(events):
c=50
for i in events:
if (i<0):
c+=i
else:
c+=i
if c>100:
c=100
print(c)
return c
```### String Anagram
```python
from collections import Counter
def stringAnagram(dictionary, query):
# Write your code here
dict = ["".join(sorted(word)) for word in dictionary]
q = ["".join(sorted(word)) for word in query]
result = []
count = Counter(dict)
for word in q:
if word in count.keys():
result.append(count[word])
else:
result.append(0)return result
```## Java
### The Adder Class
```java
class Adder extends Calculator{
int add(int a,int b)
{
return a+b;
}
}
```## Sql
### Student Advisor
```sql
select std.roll_number, std.name
from student_information std, faculty_information fi
where std.advisor = fi.employee_id and (fi.gender = 'M' and fi.salary > 15000 or fi.gender = 'F' and fi.salary > 20000)
```## Sql Intermediate
### Products without sales
```sql
select sku,product_name from PRODUCT P left join INVOICE_ITEM Ii on Ii.product_id = P.id where invoice_id is NULL order by SKU;
```### Customer Spending
```sql
select b.customer_name,cast(a.total_price as decimal(10,6))amount from customer b, invoice a where a.customer_id=b.id and a.total_price<=(select (0.25*avg(a.total_price)) FROM invoice a) order by amount desc ;***or***
select customer_name,to_char(total_price,'fm9999999.900000') from customer c, Invoice i where c.id = i.customer_id and total_price < (select (0.25)*sum(total_price)/count(id) from Invoice);
```