blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
acd10df184f13bb7c54a6f4a5abac553127b27af | chittoorking/Top_questions_in_data_structures_in_python | /python_program_to_create_grade_calculator.py | 830 | 4.25 | 4 | #Python code for the Grade
#Calculate program in action
#Creating a dictionary which
#consists of the student name,
#assignment result test results
#And their respective lab results
def grade(student_grade):
name=student_grade['name']
assignment_marks=student_grade['assignment']
assignment_score=... | true |
968829ff7ec07aabb3dedfb89e390334b9b9ee57 | chittoorking/Top_questions_in_data_structures_in_python | /python_program_to_check_if_a_string_is_palindrome_or_not.py | 450 | 4.3125 | 4 | print("This is python program to check if a string is palindrome or not")
string=input("Enter a string to check if it is palindrome or not")
l=len(string)
def isPalindrome(string):
for i in range(0,int(len(string)/2)):
if string[i]==string[l-i-1]:
flag=0
continue
else :
... | true |
06132de9f0dd0dfbf3138ead23bd4a936ca4a70a | chittoorking/Top_questions_in_data_structures_in_python | /python_program_to_interchange_first_and_last_elements_in_a_list_using_pop.py | 277 | 4.125 | 4 | print("This is python program to swap first and last element using swap")
def swapList(newList):
first=newList.pop(0)
last=newList.pop(-1)
newList.insert(0,last)
newList.append(first)
return newList
newList=[12,35,9,56,24]
print(swapList(newList))
| true |
0901c75662df3c0330deb4d25087868ba0693e94 | dipesh1011/NameAgeNumvalidation | /multiplicationtable.py | 360 | 4.1875 | 4 | num = input("Enter the number to calculate multiplication table:")
while(num.isdigit() == False):
print("Enter a integer number:")
num = input("Enter the number to calculate multiplication table:")
print("***************************")
print("Multiplication table of",num,"is:")
for i in range(1, 11):
res = i... | true |
8ed94e5a5bc207a34271e2bb52029d7b6b71870d | darlenew/california | /california.py | 2,088 | 4.34375 | 4 | #!/usr/bin/env python
"""Print out a text calendar for the given year"""
import os
import sys
import calendar
FIRSTWEEKDAY = 6
WEEKEND = (5, 6) # day-of-week indices for saturday and sunday
def calabazas(year):
"""Print out a calendar, with one day per row"""
BREAK_AFTER_WEEKDAY = 6 # add a newline after ... | true |
d86ab402a950557261f140137b2771e84ceafbbe | priyankagarg112/LeetCode | /MayChallenge/MajorityElement.py | 875 | 4.15625 | 4 | '''
Given an array of size n, find the majority element. The majority element is the element that appears more than ⌊ n/2 ⌋ times.
You may assume that the array is non-empty and the majority element always exist in the array.
Example 1:
Input: [3,2,3]
Output: 3
Example 2:
Input: [2,2,1,1,1,2,2]
Output: 2
'''
from t... | true |
433027b761e728e242c5b58c11866208fe39ca23 | caesarbonicillo/ITC110 | /quadraticEquation.py | 870 | 4.15625 | 4 | #quadratic quations must be a positive number
import math
def main():
print("this program finds real solutions to quadratic equations")
a = float(input("enter a coefficient a:"))
b = float(input("enter coefficient b:"))
c = float(input("enter coefficient c:"))
#run only if code is great... | true |
12c96ea6817d91f8d488f13c119752f747971c94 | caesarbonicillo/ITC110 | /Temperature.py | 496 | 4.125 | 4 | #convert Celsius to Fehrenheit
def main(): #this is a function
#input
celsius = eval (input ("Enter the temp in Celsius ")) #must convert to number call function EVAL
#processing
fahrenheit = round(9/5 * celsius + 32, 0)
#output
print (celsius, "The Fehrenheit temp is", fahrenheit)
m... | true |
d8325a2d9e1214a72880b37b023d4af1a8d88469 | pandeesh/CodeFights | /Challenges/find_and_replace.py | 556 | 4.28125 | 4 | #!/usr/bin/env python
"""
ind all occurrences of the substring in the given string and replace them with another given string...
just for fun :)
Example:
findAndReplace("I love Codefights", "I", "We") = "We love Codefights"
[input] string originalString
The original string.
[input] string stringToFind
A string to ... | true |
5fa88d472f98e125a2dd79e2d6986630bbb28396 | pandeesh/CodeFights | /Challenges/palindromic_no.py | 393 | 4.125 | 4 | #!/usr/bin/env python
"""
You're given a digit N.
Your task is to return "1234...N...4321".
Example:
For N = 5, the output is "123454321".
For N = 8, the output is "123456787654321".
[input] integer N
0 < N < 10
[output] string
"""
def Palindromic_Number(N):
s = ''
for i in range(1,N):
s = s + str... | true |
83a2fe0e985ffa4d33987b15e6b4ed8a6eb5703b | Nbouchek/python-tutorials | /0001_ifelse.py | 836 | 4.375 | 4 | #!/bin/python3
# Given an integer, , perform the following conditional actions:
#
# If is odd, print Weird
# If is even and in the inclusive range of 2 to 5, print Not Weird
# If is even and in the inclusive range of 6 to 20, print Weird
# If is even and greater than 20, print Not Weird
# Input Format
#
# A single... | true |
a30b0e3f5120fc484cd712f932171bd322e757df | ByketPoe/gmitPandS | /week04-flow/lab4.1.3gradeMod2.py | 1,152 | 4.25 | 4 | # grade.py
# The purpose of this program is to provide a grade based on the input percentage.
# It allows for rounding up of grades if the student is 0.5% away from a higher grade bracket.
# author: Emma Farrell
# The percentage is requested from the user and converted to a float.
# Float is appropriate in this occa... | true |
6f16bc65643470b2bca5401667c9537d88187656 | ByketPoe/gmitPandS | /week04-flow/lab4.1.1isEven.py | 742 | 4.5 | 4 | # isEven.py
# The purpose of this program is to use modulus and if statements to determine if a number is odd or even.
# author: Emma Farrell
# I prefer to use phrases like "text" or "whole number" instead of "string" and "integer" as I beleive they are more user friendly.
number = int(input("Enter a whole number: "))... | true |
5901b1fcabefe69b1ecc24f2e15ffe2d3daed18b | MaurizioAlt/ProgrammingLanguages | /Python/sample.py | 454 | 4.125 | 4 |
#input
name = input("What is your name? ")
age = input("What is your age? ")
city = input("What is your city ")
enjoy = input("What do you enjoy? ")
print("Hello " + name + ". Your age is " + age )
print("You live in " + city)
print("And you enjoy " + enjoy)
#string stuff
text = "Who dis? "
print(text*3)
#or for lis... | true |
e91613869c1751c8bb3a0a0abaeb1dfb9cafa5c3 | MingCai06/leetcode | /7-ReverseInterger.py | 1,118 | 4.21875 | 4 | """
Given a 32-bit signed integer, reverse digits of an integer.
Example 1:
Input: 123
Output: 321
Example 2:
Input: -123
Output: -321
Example 3:
Input: 120
Output: 21
Note:
Assume we are dealing with an environment which could only store integers within the 32-bit signed integer range: [−231, 231 − 1]. For the pu... | true |
169aab304dfd600a169822c65e448b7e4a4abeb3 | simgroenewald/Variables | /Details.py | 341 | 4.21875 | 4 | # Compulsory Task 2
name = input("Enter your name:")
age = input ("Enter your age:")
house_number = input ("Enter the number of your house:")
street_name = input("Enter the name of the street:")
print("This is " + name + " he/she is " + age + " years old and lives at house number " + house_number + " on " + stree... | true |
4e8834fd82ae0c6b78a0d134058afbdb11d2da95 | MaxiFrank/calculator-2 | /new_arithmetic.py | 1,560 | 4.28125 | 4 | """Functions for common math operations."""
def add(ls):
sum = 0
for num in ls:
sum = sum + num
return sum
def subtract(ls):
diff = 0
for num in ls:
diff = num - diff
return diff
# def multiply(num1, num2):
def multiply(ls):
"""Multiply the two inputs together."""
res... | true |
3264f6baf0939442a45689f1746d62d6be07eece | aacampb/inf1340_2015_asst2 | /exercise2.py | 2,014 | 4.5 | 4 | #!/usr/bin/env python
""" Assignment 2, Exercise 2, INF1340, Fall, 2015. DNA Sequencing
This module converts performs substring matching for DNA sequencing
"""
__author__ = 'Aaron Campbell, Sebastien Dagenais-Maniatopoulos & Susan Sim'
__email__ = "aaronl.campbell@mail.utoronto.ca, sebastien.maniatopoulos@mail.utoron... | true |
bb81d71014e5d45c46c1c34f10ee857f5763c75a | sicou2-Archive/pcc | /python_work/part1/ch03/c3_4.py | 1,813 | 4.125 | 4 | #Guest list
dinner_list = ['Sam Scott', 'Tyler Jame', 'Abadn Skrettn', 'Sbadut Reks']
def invites():
print(f'You want food {dinner_list[0]}? Come get food!')
print(f'Please honor me {dinner_list[1]}. Dine and talk!')
print(f'Hunger gnaws at you {dinner_list[2]}. Allow me to correct that.')
print(f'Poi... | true |
434f69b6fd36753ac13589061bec3cd3da51124a | Alex0Blackwell/recursive-tree-gen | /makeTree.py | 1,891 | 4.21875 | 4 | import turtle as t
import random
class Tree():
"""This is a class for generating recursive trees using turtle"""
def __init__(self):
"""The constructor for Tree class"""
self.leafColours = ["#91ff93", "#b3ffb4", "#d1ffb3", "#99ffb1", "#d5ffad"]
t.bgcolor("#abd4ff")
t.... | true |
002464d45f720f95b4af89bfa30875ae2ed46f70 | spencerhcheng/algorithms | /codefights/arrayMaximalAdjacentDifference.py | 714 | 4.15625 | 4 | #!/usr/bin/python3
"""
Given an array of integers, find the maximal absolute difference between any two of its adjacent elements.
Example
For inputArray = [2, 4, 1, 0], the output should be
arrayMaximalAdjacentDifference(inputArray) = 3.
Input/Output
[execution time limit] 4 seconds (py3)
[input] array.integer in... | true |
ecaa063b18366d5248e01f5392fcb51e59612c1e | borisnorm/codeChallenge | /practiceSet/levelTreePrint.py | 591 | 4.125 | 4 | #Print a tree by levels
#One way to approach this is to bfs the tree
def tree_bfs(root):
queOne = [root]
queTwo = []
#i need some type of switching mechanism
while (queOne or queTwo):
print queOne
while(queOne):
item = queOne.pop()
if (item.left is not None):
queTwo.append(item.left... | true |
582d85050e08a6b8982aae505cdc0acc273aec74 | Kyle-Koivukangas/Python-Design-Patterns | /A.Creational Patterns/4.Prototype.py | 1,661 | 4.1875 | 4 | # A prototype pattern is meant to specify the kinds of objects to use a prototypical instance,
# and create new objects by copying this prototype.
# A prototype pattern is useful when the creation of an object is costly
# EG: when it requires data or processes that is from a network and you don't want to
# ... | true |
1d55b37fbef0c7975527cd50a4b65f2839fd873a | Kyle-Koivukangas/Python-Design-Patterns | /A.Creational Patterns/2.Abstract_Factory.py | 1,420 | 4.375 | 4 | # An abstract factory provides an interface for creating families of related objects without specifying their concrete classes.
# it's basically just another level of abstraction on top of a normal factory
# === abstract shape classes ===
class Shape2DInterface:
def draw(self): pass
class Shape3DInterface:
de... | true |
1994561a1499d77769350b55a6f32cdd111f31fa | Ajat98/LC-2021 | /easy/buy_and_sell_stock.py | 1,330 | 4.21875 | 4 | """
You are given an array prices where prices[i] is the price of a given stock on the ith day.
You want to maximize your profit by choosing a single day to buy one stock and choosing a different day in the future to sell that stock.
Return the maximum profit you can achieve from this transaction. If you cannot achieve... | true |
8e0e070279b4e917758152ea6f833a26bc56bad7 | chirag16/DeepLearningLibrary | /Activations.py | 1,541 | 4.21875 | 4 | from abc import ABC, abstractmethod
import numpy as np
"""
class: Activation
This is the base class for all activation functions.
It has 2 methods -
compute_output - this is used during forward propagation. Calculates A given Z
copute_grad - this is used during back propagation. Calculates dZ given dA and A
"... | true |
9c5afd492bc5f9a4131d440ce48636ca03fa721c | viharika-22/Python-Practice | /Problem-Set-2/prob1.py | 332 | 4.34375 | 4 | '''1.) Write a Python program to add 'ing' at the end of a given
string (length should be at least 3). If the given string
already ends with 'ing' then add 'ly' instead.
If the string length of the given string is less than 3,
leave it unchanged.'''
n=input()
s=n[len(n)-3:len(n)]
if s=='ing':
print(n[:len(n... | true |
bd512cbe3014297b8a39ab952c143ec153973495 | CarolinaPaulo/CodeWars | /Python/(8 kyu)_Generate_range_of_integers.py | 765 | 4.28125 | 4 | #Collect|
#Implement a function named generateRange(min, max, step), which takes three arguments and generates a range of integers from min to max, with the step. The first integer is the minimum value, the second is the maximum of the range and the third is the step. (min < max)
#Task
#Implement a function named
#ge... | true |
80643111235604455d6372e409fa248db684da97 | s56roy/python_codes | /python_prac/calculator.py | 1,136 | 4.125 | 4 | a = input('Enter the First Number:')
b = input('Enter the Second Number:')
# The entered value 10 is a string, not a number. To convert this into a number we can use int() or float() functions.
sum = float(a)+float(b)
print(sum)
print('The sum of {0} and {1} is {2}'.format(a, b, sum))
print('This is output to the ... | true |
9060d68c59660d4ee334ee824eda15cc49519de9 | ykcai/Python_ML | /homework/week5_homework_answers.py | 2,683 | 4.34375 | 4 | # Machine Learning Class Week 5 Homework Answers
# 1.
def count_primes(num):
'''
COUNT PRIMES: Write a function that returns the number of prime numbers that exist up to and including a given number
count_primes(100) --> 25
By convention, 0 and 1 are not prime.
'''
# Write your code here
#... | true |
e25a8fc38ef3e98e5dc34aae30fbbea316e709c2 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/LoopsPractice/3.py | 1,029 | 4.21875 | 4 | # 3. Budget Analysis
# Write a program that asks the user to enter the amount that he or she has budgeted for amonth.
# A loop should then prompt the user to enter each of his or her expenses for the month, and keep a running total.
# When the loop finishes, the program should display theamount that the user is ov... | true |
2b1cf90a6ed89d0f5162114a103397c0f2a211e8 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/More advance things/iter.py | 612 | 4.25 | 4 | # Python iterators
# mylist = [1, 2, 3, 4]
# for item in mylist:
# print(item)
# def traverse(iterable):
# it = iter(iterable)
# while True:
# try:
# item = next(it)
# print(item)
# except: StopIteration:
# break
l1 = [1, 2, 3]
it ... | true |
b62ba48d92de96b49332b094f8b34a5f5af4a6cb | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/More advance things/map.py | 607 | 4.375 | 4 | # The map() function
# Takes in at least 2 args. Can apply a function to every item in a list/iterable quickly
def square(x):
return x*x
numbers = [1, 2, 3, 4, 5]
squarelist = map(square, numbers)
print(next(squarelist))
print(next(squarelist))
print(next(squarelist))
print(next(squarelist))
print(nex... | true |
8abfe167d6fa9e524df27f0adce9f777f4e2df58 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/LoopsPractice/5.py | 1,278 | 4.5625 | 5 | # 5. Average Rainfall
# Write a program that uses nested loops to collect data and calculate the average rainfall over a period of years.
# The program should first ask for the number of years. The outer loop will iterate once for each year.
# The inner loop will iterate twelve times, once for each month. Each ite... | true |
60f890e1dfb13d2bf8071374024ef673509c58b2 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Inheritance/Practice/Inheritance Exercises - 1.py | 1,870 | 4.59375 | 5 | """
1. Employee and ProductionWorker Classes
Write an Employee class that keeps data attributes for the following pieces of information:
• Employee name
• Employee number
Next, write a class named ProductionWorker that is a subclass of the Employee class. The
ProductionWorker class sho... | true |
d5b0d5d155c1733eb1a9fa27a7dbf11902673537 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/FunctionExercise/4.py | 1,166 | 4.1875 | 4 | # 4. Automobile Costs
# Write a program that asks the user to enter the monthly costs for the following expenses incurred from operating his or her automobile:
# loan payment, insurance, gas, oil, tires, andmaintenance.
# The program should then display the total monthly cost of these expenses,and the total annual... | true |
e51cbe700da1b5305ce7dfe9c1748ad3b2369690 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/Dictionaries and Sets/Sets/notes.py | 2,742 | 4.59375 | 5 | # Sets
# A set contains a collection of unique values and works like a mathematical set
# 1 All the elements in a set must be unique. No two elements can have the same value
# 2 Sets are unordered, which means that the elements are not stored in any particular order
# 3 The elements that are stored in a set can be ... | true |
d2e06b65113045bf009e371c53cc73750f8184a7 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/Recursion/Practice/7.py | 1,181 | 4.21875 | 4 | """
7. Recursive Power Method
Design a function that uses recursion to raise a number to a power. The function should
accept two arguments: the number to be raised and the exponent. Assume that the exponent is a
nonnegative integer.
"""
# define main
def main():
# Establish vars
int1 = int... | true |
f149ee1bf7a78720f53a8688d83d226cb00dc5eb | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Practice/Cars.py | 2,383 | 4.8125 | 5 | """
2. Car Class
Write a class named Car that has the following data attributes:
• __year_model (for the car’s year model)
• __make (for the make of the car)
• __speed (for the car’s current speed)
The Car class should have an __init__ method that accept the car’s year model ... | true |
eaa53c820d135506b1252749ab50b320d11d53b5 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Practice/5 - RetailItem.py | 1,427 | 4.625 | 5 | """
5. RetailItem Class
Write a class named RetailItem that holds data about an item in a retail store. The class
should store the following data in attributes: item description, units in inventory, and price.
Once you have written the class, write a program that creates three RetailItem objects
and stores the fol... | true |
b046b95c144bbe51ac2c77b5363814b8b5d2b5cc | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/LoopsPractice/6.py | 503 | 4.46875 | 4 | # 6. Celsius to Fahrenheit Table
# Write a program that displays a table of the Celsius temperatures 0 through 20 and theirFahrenheit equivalents.
# The formula for converting a temperature from Celsius toFahrenheit is
# F = (9/5)C + 32 where F is the Fahrenheit temperature and C is the Celsius temperature.
# You... | true |
9e6bdd3adc3e850240f3c9a94dd766ecdd4abe97 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/FileExercises/9.py | 1,013 | 4.28125 | 4 | # 9. Exception Handing
# Modify the program that you wrote for Exercise 6 so it handles the following exceptions:
# • It should handle any IOError exceptions that are raised when the file is opened and datais read from it.
# Define counter
count = 0
# Define total
total = 0
try:
# Display first 5 line... | true |
2118efbe7e15e295f6ceea7b4a4c26696b22edb1 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Hard Stuff/Unit Testing and Multithreading/MultiThreading/Multithreadingclassdemo1/multithreading.py | 1,434 | 4.15625 | 4 | '''
RUnning things concurrently is known as multithreading
Running things in parallel is known as multiprocessing
I/O bound tasks - Waiting for input and output to be completed
reading and writing from file system, network
operations.
These all benefit... | true |
f1923bf1fc1a3ab94a7f5d32c929cd6914fc7605 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Test Stuff/First Test/shapes1.py | 2,305 | 4.25 | 4 | class GeometricObject:
def __init__(self, color = "green", filled = True):
self.color = color
self.filled = filled
def getColor(self):
return self.color
def setColor(self, color):
self.color = color
def isFilled(self):
... | true |
cd2b8237503c74dfc7864dd4ec64d7f334c9ecb0 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Practice/8 - trivia.py | 2,521 | 4.4375 | 4 | """
8. Trivia Game
In this programming exercise you will create a simple trivia game for two players. The program will
work like this:
• Starting with player 1, each player gets a turn at answering 5 trivia questions. (There
should be a total of 10 questions.) When a question is displayed,... | true |
8b72f14467bc40821bc0fb0c7c2ad9f05be58cd0 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Medium Stuff/Classes/Inheritance/Practice/Inheritance Exercises - 3.py | 2,460 | 4.46875 | 4 | """
3. Person and Customer Classes
Write a class named Person with data attributes for a person’s name, address, and
telephone number. Next, write a class named Customer that is a subclass of the
Person class. The Customer class should have a data attribute for a customer
number and a Boolean da... | true |
ab93e5065c94a86f8ed6c812a3292100925a1bb5 | Hackman9912/PythonCourse | /Curriculum/My Git Stuff/05PythonProgramming/Additional Stuff/Basic Stuff/IfElsePractice/5.py | 1,575 | 4.4375 | 4 | # 5. Color Mixer
# The colors red, blue, and yellow are known as the primary colors because they cannot be
# made by mixing other colors. When you mix two primary colors, you get a secondary color,
# as shown here:
# When you mix red and blue, you get purple.
# When you mix red and yellow, you get orange.
# When ... | true |
d63f59488d65ba81d647da41c15424a0901d18b4 | DimitrisMaskalidis/Python-2.7-Project-Temperature-Research | /Project #004 Temperature Research.py | 1,071 | 4.15625 | 4 | av=0; max=0; cold=0; count=0; pl=0; pres=0
city=raw_input("Write city name: ")
while city!="END":
count+=1
temper=input("Write the temperature of the day: ")
maxTemp=temper
minTemp=temper
for i in range(29):
av+=temper
if temper<5:
pl+=1
if temper>maxTe... | true |
431e4b3687f6e41381331f315f13108fc029d396 | wangyunge/algorithmpractice | /eet/Check_Completeness_of_a_Binary_Tree.py | 1,354 | 4.21875 | 4 | """
Given the root of a binary tree, determine if it is a complete binary tree.
In a complete binary tree, every level, except possibly the last, is completely filled, and all nodes in the last level are as far left as possible. It can have between 1 and 2h nodes inclusive at the last level h.
Example 1:
Input:... | true |
597bdffceea740761f6280470d81b9deaf73f400 | wangyunge/algorithmpractice | /int/517_Ugly_Number.py | 926 | 4.125 | 4 | '''
Write a program to check whether a given number is an ugly number`.
Ugly numbers are positive numbers whose prime factors only include 2, 3, 5. For example, 6, 8 are ugly while 14 is not ugly since it includes another prime factor 7.
Notice
Note that 1 is typically treated as an ugly number.
Have you met this ... | true |
2e3a39178816c77f9f212cb1629a8f17950da152 | wangyunge/algorithmpractice | /int/171_Anagrams.py | 692 | 4.34375 | 4 | '''
Given an array of strings, return all groups of strings that are anagrams.
Notice
All inputs will be in lower-case
Have you met this question in a real interview? Yes
Example
Given ["lint", "intl", "inlt", "code"], return ["lint", "inlt", "intl"].
Given ["ab", "ba", "cd", "dc", "e"], return ["ab", "ba", "cd", ... | true |
e3ee7499abf955e0662927b7341e93fa81843620 | wangyunge/algorithmpractice | /eet/Arithmetic_Slices.py | 960 | 4.15625 | 4 | """
An integer array is called arithmetic if it consists of at least three elements and if the difference between any two consecutive elements is the same.
For example, [1,3,5,7,9], [7,7,7,7], and [3,-1,-5,-9] are arithmetic sequences.
Given an integer array nums, return the number of arithmetic subarrays of nums.
A ... | true |
3859966faca648ffe0b7e83166049c07676ba93b | wangyunge/algorithmpractice | /eet/Maximum_Units_on_a_Truck.py | 2,304 | 4.125 | 4 | """
You are assigned to put some amount of boxes onto one truck. You are given a 2D array boxTypes, where boxTypes[i] = [numberOfBoxesi, numberOfUnitsPerBoxi]:
numberOfBoxesi is the number of boxes of type i.
numberOfUnitsPerBoxi is the number of units in each box of the type i.
You are also given an integer truckSize... | true |
d620071842e6003015b2a9f34c72b85a64e00a04 | wangyunge/algorithmpractice | /eet/Multiply_Strings.py | 1,183 | 4.125 | 4 | """
Given two non-negative integers num1 and num2 represented as strings, return the product of num1 and num2, also represented as a string.
Note: You must not use any built-in BigInteger library or convert the inputs to integer directly.
Example 1:
Input: num1 = "2", num2 = "3"
Output: "6"
Example 2:
Input: num1... | true |
bdfc9caa3090f7727fd227548a83aaf19bf66c14 | wangyunge/algorithmpractice | /eet/Unique_Binary_Search_Tree_II.py | 1,269 | 4.25 | 4 | '''
Given an integer n, generate all structurally unique BST's (binary search trees) that store values 1...n.
For example,
Given n = 3, your program should return all 5 unique BST's shown below.
1 3 3 2 1
\ / / / \ \
3 2 1 1 3 2
/ / ... | true |
9eba4c97143250a68995688a62b41145ab39485f | wangyunge/algorithmpractice | /int/165_Merge_Two_Sorted_Lists.py | 944 | 4.125 | 4 | '''
Merge two sorted (ascending) linked lists and return it as a new sorted list. The new sorted list should be made by splicing together the nodes of the two lists and sorted in ascending order.
Have you met this question in a real interview? Yes
Example
Given 1->3->8->11->15->null, 2->null , return 1->2->3->8->11->1... | true |
ba2b9d296a98edfb414c89aba262142b031014ea | tasver/python_course | /lab7_4.py | 782 | 4.375 | 4 |
#! /usr/bin/python3
# -*- coding: utf-8 -*-
def input_str() -> str:
""" This function make input of string data"""
input_string = str(input('Enter your string: '))
return input_string
def string_crypt(string: str) -> str:
""" This function make crypt string"""
result_string = str()
string = string.lower()
for ... | true |
e18e81c8986c383ac6d6cec86017d3bf948af5b3 | tasver/python_course | /lab6_1.py | 719 | 4.21875 | 4 | #! /usr/bin/python3
# -*- coding: utf-8 -*-
import math
def input_par() -> list:
""" This function make input of data"""
a, b, c = map(float, input('Enter 3 numbers: ').split())
return [a, b, c]
def check_triangle(a:list) -> bool:
""" This function check exists triangle"""
if (((a[0] + a[1]) > a[2]) and ((a[0] +... | true |
3a5ee700dce71d3f72eb95a8d7b5900e309270ec | ahmetYilmaz88/Introduction-to-Computer-Science-with-Python | /ahmet_yilmaz_hw6_python4_5.py | 731 | 4.125 | 4 | ## My name: Ahmet Yilmaz
##Course number and course section: IS 115 - 1001 - 1003
##Date of completion: 2 hours
##The question is about converting the pseudocode given by instructor to the Python code.
##set the required values
count=1
activity= "RESTING"
flag="false"
##how many activities
numact= int(input(" Enter ... | true |
8d07696850cc5f7371069a98351c51266b77da6b | lintangsucirochmana03/bigdata | /minggu-02/praktik/src/DefiningFunction.py | 913 | 4.3125 | 4 | Python 3.7.0 (v3.7.0:1bf9cc5093, Jun 27 2018, 04:06:47) [MSC v.1914 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> def fib(n): # write Fibonacci series up to n
"""Print a Fibonacci series up to n."""
a, b = 0, 1
while a < n:
print(a, end=' ')
a, b = b, a+b
>>... | true |
652990fdc99924c1810dddc60be12a8d81709a6e | ashwani8958/Python | /PyQT and SQLite/M3 - Basics of Programming in Python/program/module/friends.py | 379 | 4.125 | 4 | def food(f, num):
"""Takes total and no. of people as argument"""
tip = 0.1*f #calculates tip
f = f + tip #add tip to total
return f/num #return the per person value
def movie(m, num):
"""Take total and no. of the people as arguments"""
return m/num #returns the per persons value
print("The na... | true |
95e0619eeb977cefe6214f8c50017397ec35af3b | SURBHI17/python_daily | /prog fund/src/assignment40.py | 383 | 4.25 | 4 | #PF-Assgn-40
def is_palindrome(word):
word=word.upper()
if len(word)<=1:
return True
else:
if word[0]==word[-1]:
return is_palindrome(word[1:-1])
else:
return False
result=is_palindrome("MadAMa")
if(result):
print("The given word is a Palin... | true |
114dd9807e3e7a111c6e1f97e331a7a98e6e074a | KanuckEO/Number-guessing-game-in-Python | /main.py | 1,491 | 4.28125 | 4 | #number_guessing_game
#Kanuck Shah
#importing libraries
import random
from time import sleep
#asking the highest and lowest index they can guess
low = int(input("Enter lowest number to guess - "))
high = int(input("Enter highest number to guess - "))
#array
first = ["first", "second", "third", "fourth", "fifth"]
#va... | true |
9bab6ff99aa72e668524b63523c2106181049f6f | IamBiasky/pythonProject1 | /SelfPractice/function_exponent.py | 316 | 4.34375 | 4 | # Write a function called exponent(base, exp)
# that returns an int value of base raises to the power of exp
def exponent(base, exp):
exp_int = base ** exp
return exp_int
base = int(input("Please enter a base integer: "))
exp = int(input("Please enter an exponent integer: "))
print(exponent(base, exp))
| true |
2d4cf0b46c47fad8a5cc20cdf98ebf9ab379a151 | sooryaprakash31/ProgrammingBasics | /OOPS/Exception_Handling/exception_handling.py | 1,347 | 4.125 | 4 | '''
Exception Handling:
- This helps to avoid the program crash due to a segment of code in the program
- Exception handling allows to manage the segments of program which may lead to errors in runtime
and avoiding the program crash by handling the errors in runtime.
try - represents a block of code t... | true |
79dda99fe42354f17d03eb33a1aab1ee9ebe61ab | sooryaprakash31/ProgrammingBasics | /Algorithms/Sorting/Quick/quick.py | 2,027 | 4.25 | 4 | '''
Quick Sort:
- Picks a pivot element (can be the first/last/random element) from the array
and places it in the sorted position such that the elements before the pivot
are lesser and elements after pivot are greater.
- Repeats this until all the elements are placed in the right position
- Divide and conquer strateg... | true |
4bdde3d9684f505ae85c0446465aa211a012a02d | luizfirmino/python-labs | /Python I/Assigments/Module 5/Ex-2.py | 415 | 4.3125 | 4 | #
# Luiz Filho
# 3/14/2021
# Module 5 Assignment
# 2. In mathematics, the factorial of a number n is defined as n! = 1 ⋅ 2 ⋅ ... ⋅ n (as the product of all integer numbers from 1 to n).
# For example, 4! = 1 ⋅ 2 ⋅ 3 ⋅ 4 = 24. Write a recursive function for calculating n!
def calculateN(num):
if num == 1:
... | true |
7372b7c995d2302f29b8443656b50cae298a566b | luizfirmino/python-labs | /Python I/Assigments/Module 6/Ex-4.py | 742 | 4.40625 | 4 | #
# Luiz Filho
# 3/23/2021
# Module 6 Assignment
# 4. Write a Python function to create the HTML string with tags around the word(s). Sample function and result are shown below:
#
#add_html_tags('h1', 'My First Page')
#<h1>My First Page</h1>
#
#add_html_tags('p', 'This is my first page.')
#<p>This is my first page.... | true |
c13619368c38c41c0dbf8649a3ca88d7f2788ee8 | luizfirmino/python-labs | /Python Networking/Assignment 2/Assignment2.py | 564 | 4.21875 | 4 | #!/usr/bin/env python3
# Assignment: 2 - Lists
# Author: Luiz Firmino
list = [1,2,4,'p','Hello'] #create a list
print(list) #print a list
list.append(999) #add to end of list
print(list)
print(list[-1]) #print the last element
list.pop() #remove last element
pr... | true |
51d1e3a48b954c1de3362ea295d4270a884fea98 | luizfirmino/python-labs | /Python I/Assigments/Module 7/Ex-3.py | 1,042 | 4.3125 | 4 | #
# Luiz Filho
# 4/7/2021
# Module 7 Assignment
# 3. Gases consist of atoms or molecules that move at different speeds in random directions.
# The root mean square velocity (RMS velocity) is a way to find a single velocity value for the particles.
# The average velocity of gas particles is found using the root mean s... | true |
47d783748c562dd3c3f8b7644dda166f37b5f11e | luizfirmino/python-labs | /Python I/Assigments/Module 5/Ex-6.py | 238 | 4.5 | 4 | #
# Luiz Filho
# 3/14/2021
# Module 5 Assignment
# 6. Write a simple function (area_circle) that returns the area of a circle of a given radius.
#
def area_circle(radius):
return 3.1415926535898 * radius * radius
print(area_circle(40)) | true |
6ca6fbf8e7578b72164ab17030f1c01013604b04 | luizfirmino/python-labs | /Python I/Assigments/Module 5/Ex-4.py | 549 | 4.28125 | 4 | #
# Luiz Filho
# 3/14/2021
# Module 5 Assignment
# 4. Explain what happens when the following recursive functions is called with the value “alucard” and 0 as arguments:
#
print("This recursive function is invalid, the function won't execute due an extra ')' character at line 12 column 29")
print("Regardless any value... | true |
796c8bb615635d769a16ae12d9f27f2cfce4631c | luizfirmino/python-labs | /Python I/Assigments/Module 2/Ex-2.py | 880 | 4.53125 | 5 | #
# Luiz Filho
# 2/16/2021
# Module 2 Assignment
# Assume that we execute the following assignment statements
#
# length = 10.0 , width = 7
#
# For each of the following expressions, write the value of the expression and the type (of the value of the expression).
#
# width//2
# length/2.0
# length/2
# ... | true |
2dcdbed4df8b0608780c4d3a226c4f25d0de2b38 | Zetinator/just_code | /python/leetcode/binary_distance.py | 872 | 4.1875 | 4 | """
The distance between 2 binary strings is the sum of their lengths after removing the common prefix. For example: the common prefix of 1011000 and 1011110 is 1011 so the distance is len("000") + len("110") = 3 + 3 = 6.
Given a list of binary strings, pick a pair that gives you maximum distance among all possible pa... | true |
308f485babf73eec8c433821951390b8c2414750 | Zetinator/just_code | /python/leetcode/pairs.py | 966 | 4.1875 | 4 | """https://www.hackerrank.com/challenges/pairs/problem?h_l=interview&playlist_slugs%5B%5D%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D%5B%5D=search
You will be given an array of integers and a target value. Determine the number of pairs of array elements that have a difference equal to a target value.
Complete... | true |
e823b273ed44482d8c05499f66bf76e78b06d842 | Zetinator/just_code | /python/leetcode/special_string_again.py | 2,477 | 4.21875 | 4 | """https://www.hackerrank.com/challenges/special-palindrome-again/problem?h_l=interview&playlist_slugs%5B%5D%5B%5D=interview-preparation-kit&playlist_slugs%5B%5D%5B%5D=strings
A string is said to be a special string if either of two conditions is met:
All of the characters are the same, e.g. aaa.
All characters excep... | true |
e2b8fe6ba7d4d000b5ef8578aae3caf1847efc9d | Zetinator/just_code | /python/leetcode/unique_email.py | 1,391 | 4.375 | 4 | """
Every email consists of a local name and a domain name, separated by the @ sign.
For example, in alice@leetcode.com, alice is the local name, and leetcode.com is the domain name.
Besides lowercase letters, these emails may contain '.'s or '+'s.
If you add periods ('.') between some characters in the local name p... | true |
ca54ebba62347e2c3a4107872889e4746c51a922 | malbt/PythonFundamentals.Exercises.Part5 | /anagram.py | 497 | 4.375 | 4 | def is_anagram(first_string: str, second_string: str) -> bool:
"""
Given two strings, this functions determines if they are an anagram of one another.
"""
pass # remove pass statement and implement me
first_string = sorted(first_string)
second_string = sorted(second_string)
if first_string... | true |
e777115b8048caa29617b9b0e99d6fbac3beef99 | Vipulhere/Python-practice-Code | /Module 8/11.1 inheritance.py | 643 | 4.3125 | 4 | #parent class
class parent:
parentname=""
childname=""
def show_parent(self):
print(self.parentname)
#this is child class which is inherites from parent
class Child(parent):
def show_child(self):
print(self.childname)
#this object of child class
c=Child()
c.parentname="BOB"
c.childname=... | true |
347460f3edf3af4e5601a45b287d1a086e1a3bc3 | bopopescu/PycharmProjects | /Class_topic/7) single_inheritance_ex2.py | 1,601 | 4.53125 | 5 | # Using Super in Child class we can alter Parent class attributes like Pincode
# super is like update version of parent class in child class
'''class UserProfile(Profile): # Child Class
def __init__(self,name,email,address,pincode): # constructor of child Class
super(UserProfile, self).__init__(name,email... | true |
7c693a0fe73b2fe3cbeeddf1551bf3d2f0250ab2 | pjz987/2019-10-28-fullstack-night | /Assignments/pete/python/lab12/lab12-guess_the_number-v3.py | 694 | 4.34375 | 4 | '''
lab12-guess_the_number-v3.py
Guess a random number between 1 and 10.
V3
Tell the user whether their guess is above ('too high!') or below ('too low!') the target value.'''
import random
x = random.randint(1, 10)
guess = int(input("Welcome to Guess the Number v3. The computer is thinking of a number between 1 and ... | true |
82ef1519965203526bf480fc9b989e73fb955f54 | pjz987/2019-10-28-fullstack-night | /Assignments/jake/Python_Assignments/lab17-palidrome_anagramv2.py | 312 | 4.5625 | 5 | # Python Program to Check a Given String is Palindrome or Not
string = input("Please enter enter a word : ")
str1 = ""
for i in string:
str1 = i + str1
print("Your word backwards is : ", str1)
if(string == str1):
print("This is a Palindrome String")
else:
print("This is Not a Palindrome String") | true |
81ff46e99809f962f6642b33aa03dd274ac7a16e | mohasinac/Learn-LeetCode-Interview | /Strings/Implement strStr().py | 963 | 4.28125 | 4 | """
Implement strStr().
Return the index of the first occurrence of needle in haystack, or -1 if needle is not part of haystack.
Example 1:
Input: haystack = "hello", needle = "ll"
Output: 2
Example 2:
Input: haystack = "aaaaa", needle = "bba"
Output: -1
Clarification:
What should we return when needle is an empt... | true |
16cbb114d0a13ac1c2a25c4be46dd7c14db6584c | Divyendra-pro/Calculator | /Calculator.py | 761 | 4.25 | 4 | #Calculator program in python
#User input for the first number
num1 = float(input("Enter the first number: "))
#User input for the operator
op=input("Choose operator: ")
#User input for the second number
num2 = float(input("Enter the second number:" ))
#Difine the operator (How t will it show the results)
if op == '... | true |
c80bffe95bc94308989cec03948a4a91239d13aa | rbngtm1/Python | /data_structure_algorithm/array/remove_duplicate_string.py | 398 | 4.25 | 4 | # Remove duplicates from a string
# For example: Input: string = 'banana'
# Output: 'ban'
##########################
given_string = 'banana apple'
my_list = list()
for letters in given_string:
if letters not in my_list:
my_list.append(letters)
print(my_list)
print (''.join(my_list))
## poss... | true |
a6dd4e5cf972068af342c8e08e10b4c7355188e6 | DivyaRavichandr/infytq-FP | /strong .py | 562 | 4.21875 | 4 | def factorial(number):
i=1
f=1
while(i<=number and number!=0):
f=f*i
i=i+1
return f
def find_strong_numbers(num_list):
list1=[]
for num in num_list:
sum1=0
temp=num
while(num):
number=num%10
f=factorial(numbe... | true |
4f32d0b2293ff8535a870cd9730528ecf4874190 | comedxd/Artificial_Intelligence | /2_DoublyLinkedList.py | 1,266 | 4.21875 | 4 | class LinkedListNode:
def __init__(self,value,prevnode=None,nextnode=None):
self.prevnode=prevnode
self.value=value
self.nextnode=nextnode
def TraverseListForward(self):
current_node = self
while True:
print(current_node.value, "-", end=" ")
... | true |
76348acf643b1cd9764e1184949478b3b888b014 | jdipendra/asssignments | /multiplication table 1-.py | 491 | 4.15625 | 4 | import sys
looping ='y'
while(looping =='y' or looping == 'Y'):
number = int(input("\neneter number whose multiplication table you want to print\n"))
for i in range(1,11):
print(number, "x", i, "=", number*i)
else:
looping = input("\nDo you want to print another table?\npress Y/y for yes and... | true |
e6e94d3d50a56f104d1ad9993d78f8c44394b753 | jdipendra/asssignments | /check square or not.py | 1,203 | 4.25 | 4 | first_side = input("Enter the first side of the quadrilateral:\n")
second_side = input("Enter the second side of the quadrilateral:\n")
third_side = input("Enter the third side of the quadrilateral:\n")
forth_side = input("Enter the forth side of the quadrilateral:\n")
if float(first_side) != float(second_side) and flo... | true |
79b58db5b932f19b7f71f09c37c3942554507803 | RjPatil27/Python-Codes | /Sock_Merchant.py | 840 | 4.1875 | 4 | '''
John works at a clothing store. He has a large pile of socks that he must pair by color for sale.
Given an array of integers representing the color of each sock,
determine how many pairs of socks with matching colors there are.
For example, there are n = 7 socks with colors arr = [1,2,1,2,3,2,1] . There is one pa... | true |
05432b48af09dc9b89fded6fb53181df2645ee53 | Mat4wrk/Working-with-Dates-and-Times-in-Python-Datacamp | /1.Dates and Calendars/Putting a list of dates in order.py | 569 | 4.375 | 4 | """Print the first and last dates in dates_scrambled.""
# Print the first and last scrambled dates
print(dates_scrambled[0])
print(dates_scrambled[-1])
"""Sort dates_scrambled using Python's built-in sorted() method, and save the results to dates_ordered."""
"""Print the first and last dates in dates_ordered."""
# Pr... | true |
619f65ba890f6fa2e891f197581b739f02baae40 | Jmwas/Pythagorean-Triangle | /Pythagorean Triangle Checker.py | 826 | 4.46875 | 4 | # A program that allows the user to input the sides of any triangle, and then
# return whether the triangle is a Pythagorean Triple or not
while True:
question = input("Do you want to continue? Y/N: ")
if question.upper() != 'Y' and question.upper() != 'N':
print("Please type Y or N")
elif question... | true |
6273ea18be6a76f5d37c690837830f34f7c516e4 | cahill377979485/myPy | /正则表达式/命名组.py | 1,351 | 4.46875 | 4 | #!/usr/bin/python
# -*- coding: UTF-8 -*-
"""
Python 2.7的手册中的解释:
(?P<name>...)
Similar to regular parentheses, but the substring matched by the group is accessible within the rest of the regular
expression via the symbolic group name name. Group names must be valid Python identifiers, and each group name must be
defin... | true |
5c5199249efa2ba277218ed47e4ae2554a0bbf7e | Adi7290/Python_Projects | /improvise_2numeric_arithmetic.py | 660 | 4.21875 | 4 | #Write a program to enter two integers and then perform all arithmetic operators on them
num1 = int(input('Enter the first number please : \t '))
num2 = int(input('Enter the second number please :\t'))
print(f'''the addittion of {num1} and {num2} will be :\t {num1+num2}\n
the subtraction of {num1} and {num2} will b... | true |
4cc7aabb1e5e2b48cc90c607acce1b67f9fac93d | Adi7290/Python_Projects | /Herons formula.py | 350 | 4.28125 | 4 | #Write a program to calculate the area of triangle using herons formula
a= float(input("Enter the first side :\t"))
b= float(input("Enter the second side :\t"))
c= float(input("Enter the third side :\t"))
print(f"Side1 ={a}\t,Side2 = {b}\t,Side3={c}")
s = (a+b+c)/2
area=(s*(s-a)*(s-b)*(s-c))**0.5
print(f"Semi = ... | true |
ea0b627a1ee97b93acd9087b18e36c3fa5d10b4d | Adi7290/Python_Projects | /singlequantity_grocery.py | 942 | 4.1875 | 4 | '''Write a program to prepare a grocery bill , for that enter the name of items , quantity in which it is
purchased and its price per unit the display the bill in the following format
*************BILL***************
item name item quantity item price
********************************
total amount to be paid ... | true |
2b786c15f95d48b9e59555d2557cc497d922d948 | Adi7290/Python_Projects | /Armstrong_number.py | 534 | 4.40625 | 4 | """Write a program to find whether the given number is an Armstrong Number or not
Hint:An armstrong number of three digit is an integer such that the sum of the cubes of its digits is equal
to the number itself.For example 371 is the armstrong number since 3**3+7**3+1**3"""
num = int(input('Enter the number to che... | true |
503700558831bf7513fc8987bb669f0e17d144c0 | deepika7007/bootcamp_day2 | /Day 2 .py | 1,301 | 4.1875 | 4 | #Day 2 string practice
# print a value
print("30 days 30 hour challenge")
print('30 days Bootcamp')
#Assigning string to Variable
Hours="Thirty"
print(Hours)
#Indexing using String
Days="Thirty days"
print(Days[0])
print(Days[3])
#Print particular character from certin text
Challenge="I will win"
print(challenge[... | true |
5571025882b22c9211572e657dd38b1a9ecdfa74 | martinkozon/Martin_Kozon-Year-12-Computer-Science | /Python/extra_sum_of_two.py | 342 | 4.1875 | 4 | #Program which will add two numbers together
#User has to input two numbers - number1 and number2
number1 = int(input("Number a: "))
number2 = int(input("Number b: "))
#add numbers number1 and number2 together and print it out
print(number1 + number2)
#TEST DATA
#Input 1, 17 -> output 18
#Input 2, 5 -> output 7
#Inp... | true |
fa98a79e66cd7e8575c857dabad5877c3b78cd87 | martinkozon/Martin_Kozon-Year-12-Computer-Science | /Python/06_input-validation.py | 816 | 4.25 | 4 | #User has to input a number between 1 and 10
#eg. if user inputs 3, the result will be as follows: 3 -> 3*1=3, 3*2=6, 3*3=9
#ask a user to input a number
number = int(input("Input number between 1 and 10: "))
#if the input number is 99 than exit the program
if number == 99:
exit()
# end if
#if the number isn't t... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.