blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
003d5d307e18c53534ff299db8922400f1324409 | Asunqingwen/LeetCode | /easy/Pascal's Triangle.py | 750 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/8/6 0006 15:15
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Pascal's Triangle.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given a non-negative integer numRows, generate the first numRo... | true |
4d42e180640b99d5da994d6020a52d8f54a85866 | Asunqingwen/LeetCode | /hard/Wildcard Matching.py | 1,821 | 4.15625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/10/16 0016 16:17
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Wildcard Matching.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given an input string (s) and a pattern (p), implement wildca... | true |
279f14a391ecdf9ef7de06885c350a60c6a07ce6 | Asunqingwen/LeetCode | /easy/Quad Tree Intersection.py | 2,798 | 4.125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/9/3 0003 14:36
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Quad Tree Intersection.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
A quadtree is a tree data in which each internal node has ... | true |
d766d7a9b5aa0930ac7a76a6839b801830679829 | Asunqingwen/LeetCode | /easy/Maximum Depth of N-ary Tree.py | 1,161 | 4.125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/8/23 0023 15:41
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Maximum Depth of N-ary Tree.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given a n-ary tree, find its maximum depth.
The ma... | true |
d6927193176ccedc82875fa6614e44be20495d03 | Asunqingwen/LeetCode | /medium/Minimum Moves to Equal Array Elements II.py | 960 | 4.25 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/10/10 0010 16:41
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Minimum Moves to Equal Array Elements II.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given a non-empty integer array, find ... | true |
2a451848c07eab332b0e52c676f7dc9c45a9e181 | Asunqingwen/LeetCode | /easy/Flood Fill.py | 2,511 | 4.375 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/9/2 0002 13:44
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Flood Fill.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
An image is represented by a 2-D array of integers, each integer repre... | true |
e14a216338c74133aced7258e4e170db5c6f3856 | Asunqingwen/LeetCode | /easy/Number of Equivalent Domino Pairs.py | 1,222 | 4.3125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/9/24 0024 15:48
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Number of Equivalent Domino Pairs.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given a list of dominoes, dominoes[i] = [a, b]... | true |
4fbaab2328fd0e2fb0c439c4d83a41f9d86bb18c | Asunqingwen/LeetCode | /medium/Convert to Base -2.py | 786 | 4.15625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/8/26 0026 15:49
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Convert to Base -2.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given a number N, return a string consisting of "0"s and "1"... | true |
5fd091722fb919ac160ee0f6d443dbaf0f296654 | Asunqingwen/LeetCode | /medium/Path With Maximum Minimum Value.py | 1,931 | 4.4375 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/10/11 0011 15:36
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Path With Maximum Minimum Value.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given a matrix of integers A with R rows and C ... | true |
4aaef49551a246c67ce7de4f0e01bd9f6e0c0748 | Asunqingwen/LeetCode | /medium/Number of Dice Rolls With Target Sum.py | 1,997 | 4.25 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/10/16 0016 9:36
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Number of Dice Rolls With Target Sum.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
You have d dice, and each die has f faces n... | true |
32ade4dd6de91b9e2fe826fd0337de839d1f6ce3 | Asunqingwen/LeetCode | /medium/Rectangle Area.py | 1,036 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/8/26 0026 15:16
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Rectangle Area.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Find the total area covered by two rectilinear rectangles in a 2... | true |
47bc6fe67589143a869b308917095179d2c9f265 | Asunqingwen/LeetCode | /medium/Number of Longest Increasing Subsequence.py | 1,421 | 4.125 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/10/25 0025 13:59
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Number of Longest Increasing Subsequence.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given an unsorted array of integers, f... | true |
faeb5730387565077af9e946d84d0411bb78bd53 | Asunqingwen/LeetCode | /easy/Check If a Number Is Majority Element in a Sorted Array.py | 1,392 | 4.46875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/11/15 0015 10:35
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Check If a Number Is Majority Element in a Sorted Array.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given an array nums sor... | true |
0ac5276c169b1fd18144ab00311031a571e61f3b | Asunqingwen/LeetCode | /easy/Degree of an Array.py | 1,564 | 4.15625 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/10/18 0018 9:20
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Degree of an Array.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Given a non-empty array of non-negative integers nums, the de... | true |
08bf03355f9364d3e9a05cb8640a53b8ddc78fed | Asunqingwen/LeetCode | /medium/Kth Largest Element in an Array.py | 888 | 4.1875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/9/4 0004 10:21
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Kth Largest Element in an Array.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
Find the kth largest element in an unsorted arra... | true |
94c0dc5786a935ab7522209dc18cb434dfed64f2 | Asunqingwen/LeetCode | /easy/Climbing Stairs.py | 990 | 4.1875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2019/8/19 0019 15:43
# @Author : 没有蜡笔的小新
# @E-mail : sqw123az@sina.com
# @FileName: Climbing Stairs.py
# @Software: PyCharm
# @Blog :https://blog.csdn.net/Asunqingwen
# @GitHub :https://github.com/Asunqingwen
"""
You are climbing a stair case. It takes n steps to reach to the... | true |
a57ab3452a03a7dd136103ce3de19f64c9ff6acb | turpure/py_algo | /algorithms/arrays/limit.py | 862 | 4.5 | 4 | """
Sometimes you need to limit array result to use. Such as you only need the value over
10 or, you need value under than 100. By use this algorithms, you can limit your array
to specific value
If array, Min, Max value was given, it returns array that contains values of given array
which was larger than Min, and lowe... | true |
59e2103fc82191a152545d39adb046e58f3ea347 | Burner999/Python | /car_class_electric.py | 2,151 | 4.3125 | 4 | class Car():
"""A simple attempt to model a car"""
def __init__ (self, make, model, year, colour, odometer_reading):
"""initialize name and age"""
self.make = make
self.model = model
self.year = year
self.colour = colour
self.odometer_reading = odometer_reading
self.category = 'combustion'
def descri... | true |
9d6a56a31533bf402ec3486ccc7a746c50c20efc | meganskrobacz/CCIS | /Othello_Project_Dec_2019/main.py | 1,573 | 4.1875 | 4 |
from board import Board
# PURPOSE
# Sorts the items in a list
# SIGNATURE
# bubble_sort :: List[[Str, Int]] => List[[String, Int]]
def bubble_sort(lst):
length = len(lst)
for i in range(length):
for j in range(length - i - 1):
if lst[j][1] < lst[(j + 1)][1]:
t... | true |
aada4d834a321b2cfb1d73b35d6ccfa6de213fb3 | nik24g/Python | /No. camparison and BMI calculator.py | 1,266 | 4.21875 | 4 | a = 1
b = 2
if a < b:
print("A is less than B")
print("Not sured if A is less than B")
print("_______________________________________________________")
c = 6
d = 4
if c < d:
print("C is less than d")
else:
print("C is not less than D")
print("I don't think C is less than D")
print("out side the if block... | true |
52652edd95e7fbd2578c4bbde05d5547b86e45b4 | nik24g/Python | /write a file.py | 772 | 4.40625 | 4 | file = open("info.txt", "wt") # when we open a file in write mode it will overwrite the content
print(file.write("Hello ")) # write method is used to write a content in a file
file.close()
# note-- write mode and write method both are different
file = open("info.txt", "a") # if file open in a append mode it add con... | true |
a5eba3faa434bda523cccc6bfe7b54493323b67a | David92p/Python-workbook | /repetition/Exercise67.py | 743 | 4.21875 | 4 | #Compute the Perimeter of a Polygon
from math import sqrt
p = 0
while True:
x1 = input('Enter the first point X (blank to quit) ')
if x1 != " ":
y1 = input('Enter the first point Y ')
x2 = input('Enter the second point X ')
y2 = input('Enter the second point Y ')
x1 = int(x1)
... | true |
7a8bba9915a602d9ef0b264ff271a022152af943 | David92p/Python-workbook | /lists/Exercise111.py | 201 | 4.125 | 4 | #Reverse Order
n = int(input("Enter an integer, 0 to exit "))
list = []
while n != 0:
list.append(n)
n = int(input("Enter an integer, 0 to exit "))
list.reverse()
for i in list:
print(i) | true |
22f585ad90401187a828c463f22d6596213be5b3 | David92p/Python-workbook | /function/Exercise87.py | 339 | 4.125 | 4 | #Shipping Calculator
def express_shipping(item):
shipping = 10.95
if item >1:
plus = 2.95*(item-1)
return shipping + plus
else:
return shipping
quantity = int(input('How many items did you buy? '))
total_price = round(express_shipping(quantity),2)
print('The total shipping price ... | true |
748855c73991e8374c8a9d7466550aa7cf623d3b | Huijuan2015/leetcode_Python_2019 | /143. Reorder List.py | 2,488 | 4.1875 | 4 | # Definition for singly-linked list.
# class ListNode(object):
# def __init__(self, x):
# self.val = x
# self.next = None
class Solution(object):
def reorderList(self, head):
"""
:type head: ListNode
:rtype: None Do not return anything, modify head in-place instead.
... | true |
919535fb51afd455532001e63c855ebbc9c7abac | ndpage/py4e-course2-python-data-structures | /Week6/graded_10-2.py | 1,229 | 4.25 | 4 | # 10.2 Write a program to read through the mbox-short.txt
# and figure out the distribution by hour of the day for each of the messages.
# You can pull the hour out from the 'From ' line by finding the time
# and then splitting the string a second time using a colon.
# From stephen.marquard@uct.ac.za Sat J... | true |
111380ba18fb06d7ea17e6672023249be83e9ae9 | dlehdgus99/CS-30 | /P1/rps.py | 1,916 | 4.21875 | 4 | '''
Written By: Dong Hyun Lee
Description: This is a version of rock-paper-scissors where the computer cheats and always wins.
pChoice is the person's choice of a move: either 'rock', 'paper', or 'scissors'.
This will always return 'computer wins'.
Date : 10/10/2018
'''
def rpsCheat(pChoice):
return (pri... | true |
ebf475d27ffcdc884b662dc2c536abe6011c1a38 | raserhin/project-euler | /Problem001.py | 634 | 4.34375 | 4 | """
If we list all the natural numbers below 10 that are multiples of 3 or 5, we get 3, 5, 6 and 9. The sum of these multiples is 23.
Find the sum of all the multiples of 3 or 5 below 1000
"""
import time
pair_of_numbers = [3, 5]
N = 1000 # This is the number that we have to find its divisibles
def sum_of_numbers(... | true |
64d5fc382927f3c400f230451b3ba37b37811865 | szazyczny/MIS3640 | /Session08/quiz1.py | 2,356 | 4.15625 | 4 | #Sarah Zazyczny Quiz 1 9/15/18
"""
Question 1:
If the number, n, is divisible by 4, return True;
return False otherwise. Return False if n is divisible by 100
(for example, 1900); the only exception is when n is divisible
by 400(for example, 2000), return True.
"""
def is_special(n):
"""
If the number, n,... | true |
48013e20619c10fbc1dc2005e9db1cdcf83ebb6d | szazyczny/MIS3640 | /Session15OOP/OOP/OOP3/Exercise5.py | 1,205 | 4.4375 | 4 | # Exercise 5 (group work)
# Write a definition for a class of anything you want. You have to use the following methods:
# __init__ method that initializes some attributes. One of the attributes has to be an empty list.
# __str__ method that returns a string that reasonably represent the thing.
# A special method tha... | true |
9cf62006554b0ec5ea34a7773ed659973ceb0b9e | archerImagine/myNewJunk | /my2015Code/myGithubCode/6.00SC/Misc/src/montyHall.py | 1,091 | 4.1875 | 4 | """ This program provides a simulation for a monty hall
problem of n doors, showing the expected value as well as
the experimental. This program assumes always switching. """
import random
won = 0
lost = 0
num = int(input("Number of Doors? "))
n = int(input("How many iterations? \n"))
def setup(): #creates random... | true |
9b9c7418eec5c8875b671f8c7af71847b79ee1ba | archerImagine/myNewJunk | /my2015Code/myGithubCode/PythonLearning/AByteOfPython/Chapter_12/src/example04.py | 1,140 | 4.125 | 4 | class Robot(object):
"""Represent a Robot with a string"""
# A class variable, counting the number of robots.
population = 0
def __init__(self, name):
"""Initalize the data"""
self.name = name
print "(Initalizing {})".format(self.name)
# When this person is created, the robot
# adds to the population
... | true |
29d7635ec3bdaffb7897ee402fd9b2a2f75e8b7e | archerImagine/myNewJunk | /my2015Code/myGithubCode/PythonLearning/AByteOfPython/Chapter_13/src/example01.py | 239 | 4.40625 | 4 | def reverse(text):
return text[::-1]
def is_palindrome(text):
return text == reverse(text)
something = raw_input("Enter a Text: ")
if is_palindrome(something):
print "Yes, its is a palindrome"
else:
print "No, It is not a palindrome" | true |
e37991880160d0543d2b43b84706239e64cf1cbc | Fr4nc3/code-hints | /leetcode/mergeLexicography.py | 2,711 | 4.5 | 4 | # You are implementing your own programming language and you've decided to add support for merging strings. A typical merge function would take two strings s1 and s2, and return the lexicographically smallest result that can be obtained by placing the symbols of s2 between the symbols of s1 in such a way that maintains... | true |
aa2baff7bc5b202e93430b7ea531cdd6080c39f1 | Fr4nc3/code-hints | /leetcode/stringNumberConv.py | 1,357 | 4.125 | 4 | # You are given a string s. Your task is to count the number of ways of splitting s into three non-empty
# parts a, b and c (s = a + b + c) in such a way that a + b, b + c and c + a are all different strings.
# NOTE: + refers to string concatenation.
# For s = "xzxzx", the output should be solution(s) = 5.
# Conside... | true |
b56cdc80cba76eb9ae47589464ade47a6de469f8 | KR1410/Pyhton-Projects | /guess_game.py | 387 | 4.15625 | 4 | import random
random_num = random.randint(1,100)
#print(random_num)
chances = 0
while(True):
guess = int(input("Enter your number: "))
chances += 1
if(guess == random_num):
print(f"you guessed the correct number in {chances} chances")
break
elif(guess < random_num):
print("your g... | true |
0ab0673b2c67f6263abf2773b63dd890a1f1fcb2 | silkaitis/project_euler | /Problem01.py | 541 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Jun 29 09:11:13 2016
@author: Danius.silkaitis
"""
#Problem 1
#If we list all the natural numbers below 10 that are multiples of 3 or 5,
#we get 3, 5, 6 and 9. The sum of these multiples is 23.
#
#Find the sum of all the multiples of 3 or 5 below 1000.
def multiples(m1,m2,... | true |
3e0ef1485ffad7b68cc733f64f90f37f05cbb948 | btatkerson/CIS110 | /Excercises/Ch2/ch2ex10.py | 266 | 4.125 | 4 | def main():
print("This Program converts kilometers to miles.")
print()
kilo=eval(input("Enter the distance in kilometers: "))
miles = kilo *0.62
print("This distance in miles is: ",miles)
input("Press the <Enter> key to quit.")
main()
| true |
4595ab0f1b07e7cb244b8651c436b9195a590495 | DrSJBauman/SEMO-Python-Coursework | /futval.py | 432 | 4.125 | 4 | #futval.py
# A program to compute the value of an investment
# carried 10 years into the future
def futval():
print("This program calculates the future value")
print("of a 10-year investment")
principal= input("Enter the initial principal: ")
apr= input("Enter the annual interest rate: ")
... | true |
8f3017f8acf08452e016860866e589225e807c2a | TayeeChang/algorithm | /前缀树/trie.py | 1,319 | 4.21875 | 4 | # -*- coding: utf-8 -*-
# @Time : 2021/4/29 14:38
# @Author : haojie zhang
import collections
class Trie(object):
def __init__(self):
"""
Initialize your data structure here.
"""
self.root = {}
def insert(self, word):
"""
Inserts a word into the trie.
... | true |
b5c833193fb30c837e594431dc4e91da6dde8bfd | Harshit-Raj-2000/Algorithms-and-Data-Structures | /coding interview practice/arrays/wave array.py | 628 | 4.1875 | 4 | #User function Template for python3
class Solution:
#Complete this function
#Function to sort the array into a wave-like array.
def convertToWave(self,arr,N):
for i in range(0,N-1,2):
arr[i],arr[i+1] = arr[i+1],arr[i]
return
#{
# Driver Code Starts
#Initial Template for Pytho... | true |
a8bf9f9cd7321a0b319efdd6830941287888fc8c | mangalagb/Leetcode | /Medium/BuildingsWithAnOceanView.py | 1,532 | 4.34375 | 4 | #There are n buildings in a line. You are given an integer array heights of size n that represents the
# heights of the buildings in the line.
# The ocean is to the right of the buildings. A building has an ocean view if the building can see the ocean
# without obstructions. Formally, a building has an ocean view ... | true |
c2b83ee100b31f77d52a8986aad0c809b00c854f | mangalagb/Leetcode | /Medium/GraphValidTree.py | 2,502 | 4.15625 | 4 | # Given n nodes labeled from 0 to n-1 and a list of undirected edges (each edge is a pair of nodes),
# write a function to check whether these edges make up a valid tree.
#According to the definition of tree on Wikipedia: “a tree is an undirected graph in which any two vertices
# are connected by exactly one path. In ... | true |
6d4d678865a0e1c7862a33bd9698deaa08f7e4f0 | mangalagb/Leetcode | /Medium/ValidateBinarySearchTree.py | 1,520 | 4.3125 | 4 | # Given a binary tree, determine if it is a valid binary search tree (BST).
#
# Assume a BST is defined as follows:
#
# The left subtree of a node contains only nodes with keys less than the node's key.
# The right subtree of a node contains only nodes with keys greater than the node's key.
# Both the left ... | true |
4eeaa6cb753a1ffc1374f29d8b21bea9cdd111c7 | mangalagb/Leetcode | /Easy/Merge2SortedLists.py | 1,183 | 4.25 | 4 | # Merge two sorted linked lists and return it as a new list.
# The new list should be made by splicing together the nodes of the first two lists.
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def mergeTwoLists(self, l1... | true |
777fe0bf787608dc89a7da7000eec2ada7f3411f | jelena-vk-itt/jvk-tudt-notes | /swd1-pt/res/files/python/lab_solutions/a3e2.py | 226 | 4.125 | 4 | i = int(input("Please enter a whole number: "))
j = int(input("Please enter another whole number: "))
if i % j:
print("{0} is not a factor of {1}".format(j, i))
else:
print("{0} is a factor of {1}".format(j, i))
| true |
c5807c7fa56a6b953c643f8c93a83165b0721587 | jelena-vk-itt/jvk-tudt-notes | /swd1-pt/res/files/python/conditionals/cond_elif.py | 211 | 4.3125 | 4 | x = 2
if x > 10:
print("x is greater than 10")
elif x > 3:
print("x is greater than 3 but not greater than 10")
elif x > 0:
print("x is 1, 2 or 3")
else:
print("x is not a positive number") | true |
f2fe054fe0c999b0dd0fea65361e2e5e5c98262d | Tanner-Mindrum/some-school-python-projects | /Discrete Structures with Computing Applications II (CECS 229)/Number Theory & Cryptography/Programming Assignment 2.py | 1,490 | 4.1875 | 4 | import math
# Question 1
# Write afunction that will take in three inputs: base, exponent, and divisor. The output would be the values of the
# modulus operations such that when multiplied and then taken the modulus of the divisor, you will get the problem’s
# remainder. The output should bea list data type.
def modul... | true |
8be16767e05a1beade190790ae2581f6d2a7279b | m-ali-ubit/PythonProgramming | /zip.py | 612 | 4.59375 | 5 |
# According to Python documentation:
# zip(*iterables) returns an iterator of tuples, where the i-th tuple contains the i-th element
# from each of the argument sequences or iterables.
obtainedMarks = [22, 26, 21, 15, 19]
maxMarks = [25, 30, 25, 20, 25]
print(list(zip(obtainedMarks, maxMarks))) # like map, zip als... | true |
1d1ea098b8d0c4f30e46f288a14d8566b238d081 | m-ali-ubit/PythonProgramming | /DataStructures/SortingAlgorithms/shellSort.py | 844 | 4.125 | 4 |
# shell sort starts by sorting pairs of elements far apart from each other
# then progressively reducing the gap between elements to be compared
# time complexity ; worst case O(size^2), best case O(nLogn)
def shell_sort(lst): # start with a big gap then reduce the gap
size = len(l... | true |
b6bf3475f64b476892066461d7a600ec632a4db7 | m-ali-ubit/PythonProgramming | /identityOperator.py | 627 | 4.1875 | 4 |
# identity operators compare the memory locations of two objects and returns TRUE or False
x = 10
y = 10
z = 20
print(id(x)) # print the memory location of x
print(id(y)) # print the memory location of y
print(id(z)) # print the memory location of z
print(x is y) # true because x and y have same memo... | true |
ba51c71673a2cfe3ac27ae35370b3b5dd873e3fb | shermanash/dsp | /python/q8_parsing.py | 1,209 | 4.34375 | 4 | # -*- coding: utf-8 -*-
#The football.csv file contains the results from the English Premier League.
# The columns labeled ‘Goals’ and ‘Goals Allowed’ contain the total number of
# goals scored for and against each team in that season (so Arsenal scored 79 goals
# against opponents, and had 36 goals scored against t... | true |
33098574cb11ed8198389a18f6bd1cc211013fda | zulsb/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/8-uppercase.py | 254 | 4.15625 | 4 | #!/usr/bin/python3
def uppercase(str):
for count in str:
character = ord(count)
if (character >= ord("a") and character <= ord("z")):
character = character - 32
print("{:c}".format(character), end="")
print()
| true |
d67627dd68e45c4c5a0c66e2736ad359d9274cdd | Duenwege2312/CTI110 | /P3T1_AreasOfRectangles_EthanDuenweg.py | 922 | 4.53125 | 5 | # Rectangle Area Calculator
# 2/25/20
# CTI-110 P3T1- Areas of Rectangles
# Ethan Duenweg
# First we need to get the rectangle dimensions from the user
print("Rectangle Area Calculator")
h1 = int(input("What's the height of the rectangle 1?"))
w1 = int(input("Whats the width of rectangle 1?"))
h2 = int(inp... | true |
3d6da0c7838ae7e14ae0b41370deaf324cf4c7a4 | sarahdomanti/CP1404_Pracs | /Prac2/asciiTable.py | 288 | 4.21875 | 4 | lower = 10
upper = 100
print("Enter a number between {} and {} : ".format(str(lower), str(upper)))
for i in range(1, 10):
ASCII = int(input("> "))
if ASCII < lower or ASCII > upper:
print("Invalid number.")
else:
print("{:<5} {:>5}".format(ASCII, chr(ASCII)))
| true |
74a7346aadeb1dcc3ea320dff132e4241828d6a7 | arnnav/rts-labs | /q1.py | 1,218 | 4.25 | 4 | '''
Print the number of integers in an array that are above the given input and the number that are below.
default inpArr = [1,5,2,1,10], k = 6
RUNNING INSTRUCTIONS:
- python q1.py [--inpArr InputArray ] [--k valueOfGivenNumber]
EXAMPLE:
- python q1.py
- python q1.py --inpArr 1,5,2,1,10 --k 6
... | true |
3babe6335bcb4033e5a37e32fad3e552456ca09d | airosent/Rock-Paper-Scissor-Game | /rockpaperscissors.py | 1,019 | 4.15625 | 4 | #Ariel Rosenthal
# Rock, Paper, Scissor game in Python
import random
while True:
user_choice= input("Enter a choice (rock, paper, scissors): ")
possible_choices = ["rock", "paper", "scissors"]
computer_choice = random.choice(possible_choices)
if user_choice == computer_choice:
print(f"Both pla... | true |
e84c0d6cb432bc6ca4e51d92f2251e4f58184a03 | Andrew-Ng-s-number-one-fan/Python-for-Everybody-Specialization | /01 - Programming for Everybody (Getting Started with Python)/Assignment3-1.py | 830 | 4.25 | 4 | # Write a program to prompt the user for hours and rate per hour using input to compute gross pay.
# Pay the hourly rate for the hours up to 40 and 1.5 times the hourly rate for all hours worked above 40 hours.
# Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75).
# You shoul... | true |
fb5923bc37e890d05963cbd07204fce1a2d6db6a | rslindee/daily-coding-problem | /004_missing_int.py | 1,228 | 4.15625 | 4 | """ Given an array of integers, find the first missing positive integer in linear time and constant space. In other words, find the lowest positive integer that does not exist in the array. The array can contain duplicates and negative numbers as well.
For example, the input [3, 4, -1, 1] should give 2. The input [1, ... | true |
8832e6b16e6244f1f9e39e8c595882ba6b2ed298 | Myles-Trump/ICS3U-Unit3-03 | /random_guessing_game.py | 742 | 4.40625 | 4 | #!/usr/bin/env python3
# Created by: Myles Trump
# Created on: May 2021
# This program lets the user guess a number between 1-10
# with a randomized integer and tells them if they are correct or not
import random
def main():
# this function lets the user pick a number between 1-10
# and randomizes sai... | true |
0641899e253f1da658099bf086df14e46d744e6d | peterhsprenger/VuRProjects | /TrainingResources/03workingsnippets/Assignment33.py | 781 | 4.5625 | 5 | # 3.3 Write a program to prompt for a score between 0.0 and 1.0.
# If the score is out of range, print an error. If the score is between 0.0 and 1.0, print a grade using the following table:
# Score Grade
# >= 0.9 A
# >= 0.8 B
# >= 0.7 C
# >= 0.6 D
# < 0.6 F
# If the user enters a value out of range, print a s... | true |
9d65c9e1e04307b286c22fce473b3a7172e45c08 | emmanuelepp/design-patterns-examples | /Creational-Patterns/factory.py | 602 | 4.21875 | 4 | # Factory:
# Provides an interface for creating objects in a superclass,
# but allows subclasses to alter the type of objects that will be created.
class Dog:
def __init__(self, name):
self.name = name
def speak(self):
return "Woof"
class Cat:
def __init__(self, name):
self.name ... | true |
69c097d36db51056d942e09c0c388912bd5d056c | DrChrisLevy/python_intro_udemy | /book/_build/jupyter_execute/content/chapter2/more_basic_operators.py | 2,349 | 4.78125 | 5 | #!/usr/bin/env python
# coding: utf-8
# # More Basic Python Operators
# We have already learned multiple Python operators such as
# `+,=,-,*,/,>,<,>=,<=,and,or,not,in,not in` and so on.
# In this section we will learn some more. Create a new Jupyter Notebook
# and name it **more_basic_operators** to follow along.
#
#... | true |
e9bd7479e8a0a141c6e9a609465dbe7700bda901 | DrChrisLevy/python_intro_udemy | /book/_build/jupyter_execute/content/chapter6/truthy_falsy_values.py | 2,942 | 4.75 | 5 | #!/usr/bin/env python
# coding: utf-8
# # Truthy and Falsy Values
#
# In previous chapters we have used the boolean values `True` and `False`.
# We already know that expressions with operators can evaluate to True or False.
# In[1]:
10 > 2
# In[2]:
if 10 > 2:
print('Hello World!')
# We use these express... | true |
c906aed12ea6cd0b6d7d230576485b4eabe1783f | Christochi/Udemy-Python-Course | /Ex_08_loops.py | 1,136 | 4.15625 | 4 | import random
print( "Program asks the user 8 names of people and stores them in a list.",
"Picks a random name and prints it." )
#count = 1 # loop counter
nameList = [] # list of names
#while count <= 8: (alternative with while loop )
for count in range( 0, 8 ):
names = input( "Please enter 8 names: ... | true |
8d63eb0ff55726a16433d50decd5ced5043240ad | ivaturi/pythonthehardway | /ex38.py | 1,267 | 4.34375 | 4 | #! /usr/bin/env python
# create a list of things
ten_things = "car bus rocket phone chair stool pen"
print ten_things
# are these really ten things?
print "Hm. There are supposed to be ten things in that list..."
# let's keep a bunch of things on hand, to add to our list
more_things = ["bowl", "box", "zebra", "hyen... | true |
88699b417bed774791fe5399cf7150ba7497b9d4 | ivaturi/pythonthehardway | /ex37/lambda.py | 1,221 | 4.21875 | 4 | #! /usr/bin/python
# Lambdas
# ------
# A lambda (or an anonymous function) is a function that is not bound to any identifier
# Lambdas are often used when we want to return a function as an argument
#
# Unlike in other functional programming languages, python does not let us define
# normal functions anonymously; a l... | true |
199344d0412d63f84bc9d7eae6f148822bfafcd1 | ivaturi/pythonthehardway | /ex42/study_drill.py | 1,596 | 4.25 | 4 | # Study drills
# Why does Python include 'object' in class definitions?
"""
This is the 'new-style' definition of a class in Python.
This was introduced in PEP 252 and PEP 253, see [1], [2], and [3].
Basically, this model is intended to unify the 'class' and 'type' concepts.
In the old-style (classic) classes, instan... | true |
62f17f576c26c85d4ca97782d05fe451a69982b9 | Rushi03/robot_motion_planning | /robot.py | 2,726 | 4.28125 | 4 | import numpy as np
import random
from q_learning import QLearning
from maze import Maze
import sys
class Robot(object):
def __init__(self, maze_dim):
'''
Use the initialization function to set up attributes that your robot
will use to learn and navigate the maze. Some initial attributes ar... | true |
f092ac1d9e561590587b555e44f21271cccd9119 | Vinnu1/python3-crashcourse | /python.py | 1,647 | 4.3125 | 4 | # Welcome to Python 3 crash course
#Contents
#variables - declaration,user input
num = 5;
country = "India";
user_input = input("Enter a number:")
print("The num you've entered is:",user_input)
#operators - arithmetic, comparison, relational, logical
# +, - , /, *, **
# ==
# <, >, <=, >=
# and, or, not
print(5+6,5*... | true |
28bdd05182c11e1c1612a40169ee581d6859b1d5 | KristenLinkLogan/PythonClass | /playtime4_csvtodict.py | 2,803 | 4.5 | 4 | # Challenge Level: Advanced
# Group exercise!
# Scenario: Your organization has put on three events and you have a CSV with details about those events
# You have the event's date, a brief description, its location, how many attended, how much it cost, and some brief notes
# File: https://github.co... | true |
922abafb7564bd1057ad1af8682e2d18fdab81d7 | KristenLinkLogan/PythonClass | /playtime4_csvtolist.py | 877 | 4.6875 | 5 | # Goal: Using the code from Lesson 3: File handling and dictionaries, create a function that will open a CSV file and return the result as a nested list.
def csv_to_list(filename,delimiter=","):
"""
Returns a nested list of records from a delimited file
"""
with open(filename,'r') as csv_file:
records = csv_... | true |
30ea17dc959102908da13adb272a0eb1c37b5352 | aucan/LeetCode-problems | /461.HammingDistance.py | 824 | 4.21875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sun Jul 5 21:59:05 2020
@author: nenad
"""
"""
Problem URL: https://leetcode.com/problems/hamming-distance/
Problem description:
Hamming Distance
The Hamming distance between two integers is the number of positions at which the corresponding bits are di... | true |
6bd5297aaa64794dc4be44a39a1867b21d6f1b2c | aucan/LeetCode-problems | /468.ValidateIPAddress.py | 2,968 | 4.1875 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Tue Jun 16 15:27:26 2020
@author: nenad
"""
"""
Problem URL: https://leetcode.com/problems/validate-ip-address/
Problem description:
Validate IP Address
Write a function to check whether an input string is a valid IPv4 address or IPv6 address or neither.... | true |
487d989df874130d886b3ab2071441b1787cc628 | aucan/LeetCode-problems | /328.OddEvenLinkedList.py | 2,136 | 4.28125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat May 16 19:53:13 2020
@author: nenad
"""
"""
Problem URL: https://leetcode.com/problems/odd-even-linked-list/
Problem description:
Odd Even Linked List
Given a singly linked list, group all odd nodes together followed by the even nodes. Please note h... | true |
fa1100db45a4e6619d5c20a9b6e874e458745e2f | joojie/python01 | /Assignments/Assignment_5.2_Massawa_Lawson.py | 460 | 4.125 | 4 | smallest = None
largest = None
while True:
num = raw_input('Enter two or more different numbers: ')
if num == 'done':
break
print num
try:
num = float(num)
except:
print 'Invalid input'
continue
if smallest == None or num < smallest:
... | true |
d9de99c457ade5eb394b0e606235ba9ba27accfd | sockduct/Presentations | /Concurrency Talk/fibonacci.py | 744 | 4.1875 | 4 | #
# Simple non-recursive Fibonacci
#
# Created for Concurrent Python presentation
#
# Based on examples/code from a blog/YouTube video
# * Apologies but I don't remember which one...
#
def fibonacci(n, verbose=False):
values = []
count = 0
#
if n < 0:
sys.exit('Error: Fibonacci term must be >= ... | true |
876709d0d1af697eb7309aa23cff5a67184e739b | barbaramchd/one_coding_challenge_a_day | /202104 - April_2021/20210422.py | 1,256 | 4.15625 | 4 | digits = '123456789'
rows = 'ABCDEFGHI'
columns = digits
def cross(X, Y):
""""
Creates cross product of elements in X and in Y.
"""
# stores the cross products
combinations = []
for x in X:
for y in Y:
combinations.append(x + y)
# return a list of all the cross prod... | true |
6c14fc629cda546a15bdf8772f47df6b7f53eb9f | slambert67/techAndTools | /python/finalHangman.py | 1,332 | 4.21875 | 4 | # declare and initialise variables
choice = ''
print ('You are about to play some games of Hangman!\n')
while (1 == 1): # infinite loop. 1 always = 1
# show user menu
print('New Game: 1')
print('Exit : 2')
choice = input('Enter your selection: ')
# exit program if user selects choice 2
if choice ==... | true |
ac06083d77c5f001d0b47d5c1b2c4bffd25e463a | softscienceprojects/python-algorithms | /is_even.py | 224 | 4.25 | 4 | """that will take a number x as input.
If x is even, then return True.
Otherwise, return False
"""
def is_even(x):
if x %2 == 0:
return True
else:
return False
print is_even(900)
| true |
1d54c945db6c7666fe0fb10acb27f3ec8c60f828 | softscienceprojects/python-algorithms | /digit_sum.py | 358 | 4.3125 | 4 | """takes a positive integer n as input and returns
the sum of all that number’s digits. For example:
digit_sum(1234) should return 10 which is 1 + 2 + 3 + 4.
(Assume that the number you are given will always be positive.)
"""
def digit_sum(x):
total = 0
while x > 0:
total += x % 10
x = x // ... | true |
2e77e40e8bc32a8a979d034a802c21c8c2ba67e8 | radekBednarik/this-and-that | /sum_up_integers.py | 934 | 4.25 | 4 | '''
Sum up integers up to provided integer,
see https://realpython.com/python\
-practice-problems/#python-practice\
-problem-1-sum-of-a-range-of-integers
if no integer provided, return 0
'''
TEST_VALUES = [0, 1, 2, 5, 9, 22, 100, 55, 1.5, None, "hello"]
def add_it_up(input_: int) -> int:
"""Adds up intege... | true |
aaef36d1dbeff212de9769d8f427048e4eb1c64d | matthannan1/pynet | /wk6-ex1.py | 453 | 4.34375 | 4 | def multiply(x,y,z=1):
product = float(x) * float(y) * float(z)
return product
print
print "Part A: Three values"
print "3.124, 22.5, 6"
print multiply(3.124, 22.5, 6)
print
print "Part B: Three named arguments"
x = 3.124
y = 22.5
z= 6
print multiply(x,y,z)
print
print "Part C: A mix of three named and posit... | true |
03f86b27ea4d84184b8fed37d746c6d7c29b501b | bavalia/scripts | /python/rollDiceN.py | 900 | 4.1875 | 4 | #! /usr/bin/python3
'''
Gives the rolling of a dice with N face, default is N=6
usage: ./rollDiceN [N]
'''
import argparse
import random
class NotAnInteger(Exception):
pass
def rollDiceN (N=6):
'''
returns a tuple with 1st value as rolled dice and 2nd value as total face of dice
'''
if (isinstance(N, in... | true |
264633e3a07f7422f30dfb5ef619d71d0642c021 | sumanamoothedath/hello-world | /Calc check.py | 1,048 | 4.21875 | 4 | #!/usr/bin/env python
def add(a, b):
"""Adds a and b and returns the sum."""
return(a + b)
def subtract(a, b):
"""Subtracts a and b and returns the difference."""
return a - b
def multiply(a, b):
"""Multiplies a and b and returns the product."""
return a * b
def divide(... | true |
84925c7d4baf3b12014919abe9bd6b8031e90b16 | sam-d007/python | /functions/args.py | 304 | 4.3125 | 4 | def sum(*args):
'''The *args parameter is a special parameter that can take multiple arguments and store it in a tuple'''
print(args)
sum=0
for num in args:
sum+=num
return sum
sum1 = sum(5,10,15,20)
print(sum1)
#unpacking tuple
v = (10,20,30,40,50)
s2 = sum(*v)
print(s2) | true |
679ca2c5368136b076009a98e1a9ade5d6a3c37a | JulCesWhat/problems_vs_algorithms | /problem_1.py | 515 | 4.40625 | 4 |
def sqrt(number):
"""
Calculate the floored square root of a number
Args:
number(int): Number to find the floored squared root
Returns:
int: Floored Square Root
"""
if number < 0:
return None
x_num = number
y_num = (x_num + 1) // 2
while y_num < x_num:
... | true |
b1737104fb917260b5cb2069b2f0e82e87a12597 | strehlmatthew/workspace | /arrays from class.py | 573 | 4.15625 | 4 | # Array without Numpy
matrix = [[1,2,3],[4,5,6],[7,8,9]]
#print the item in row 2 column 2
print(matrix)
print(matrix[2][2])
for row in matrix:
for item in row:
pass
print(item)
import numpy as np
arrayn = np.array([[1,2,3],[4,5,6] ,[8,9,10]])
print(arrayn)
print (arrayn.sh... | true |
2259524cfc484d2d7fcfd12c30af1f6a27eb20eb | bitpit/CS112-Spring2012 | /classcode/day06--code_formating/broken1.py | 616 | 4.3125 | 4 | #!/usr/bin/env python
input_list=[] ##inits list to store all inputs,
input_number=None #and place to immediately store entry
while input_number != "": #while input isnt not a number
input_number=raw_input() #get input
if input_number.isdigit(): #if input is a number
input_list.append(float(input... | true |
69f1422059462a1a39ecf129e03edc6e1c9242cc | bitpit/CS112-Spring2012 | /hw04/sect2_while.py | 758 | 4.53125 | 5 | #!/usr/bin/env python
from hwtools import *
print "Section 2: Loops"
print "-----------------------------"
# 1. Keep getting a number from the input (num) until it is a multiple of 3.
num = int(raw_input("Please enter a multiple of 3: "))
while (num%3!=0):
print "That's not a multiple of 3! Try again!"
... | true |
6756b063a1aeb7079dab45ff5b913a2fc6481b41 | bitpit/CS112-Spring2012 | /hw10/rects.py | 1,646 | 4.3125 | 4 | #!/usr/bin/env python
"""
rects.py
Pygame Rectangles
=========================================================
The following section will test your knowledge of how to
use pygame Rect, arguably pygame's best feature. Define
the following functions and test to make sure they
work with `python run_tests.py`
Make sure... | true |
de92cd990ab9adac8afb59a36cea506b36917f3d | bitpit/CS112-Spring2012 | /hw03/prissybot.py | 1,862 | 4.15625 | 4 | #!/usr/bin/env python
"""
prissybot.py
Evan Ricketts
for CS112
ps - if i forgot some requirement, i apologize. simply let me know
and i will add it posthaste.
"""
name=raw_input("Enter your name: ") #assigns input to variable 'name'
print ""
print "Prissybot: Hello there, "+name+"."
print "(you can respond ... | true |
fea565f05a291ce98ab6140986cdc77200f45331 | adstr123/ds-a-in-python-goodrich | /chapter-1/c15_is_distinct.py | 691 | 4.21875 | 4 | def is_distinct(integer_list):
"""Takes a list and determines if all elements are unique
:param list integer_list: list of integers
:return boolean: conditional on evaluation of the input
"""
index = 0
for i in integer_list:
for j in integer_list:
if i != index and i == j:
return False
... | true |
4e1e4110fb9a9a8a0dd8a988299bb598ff512f81 | adstr123/ds-a-in-python-goodrich | /chapter-1/r4_cumulative_square.py | 575 | 4.15625 | 4 | def cumulative_square(limit):
"""Sums the square of all integers up to the given limit
:param int limit: exclusive limit of the cumulative squares
:return int: accumulation of the square of all integers up to limit
"""
accumulation = 0
for i in range(limit):
accumulation += i ** 2
return accumulatio... | true |
8373e0bce23ce312f67b473b32fb789ed6f93464 | bipintatkare2/PythonTutorial | /Files/file_basic_command.py | 436 | 4.34375 | 4 | # Program to demonstrate files and their functions in python .
# To open a file in a particular mode , Here is the command :-
open_file = open("sample.txt", "r")
# To get the name of file , Here is the command :-
print(open_file.name)
# To get the mode of file is be , Here is the command :-
print(open_file.mode)
# ... | true |
4260b175d6757c1b064173f9787acb838e24dd3a | BhagyashreeKarale/if-else | /ques5.py | 725 | 4.4375 | 4 | # Take user input in a variable named varx.
# Convert it to an integer.
# Check if this number is divisible by 2.
# You can achieve this by using the modulus operator``.
# Remember, modulus operator returns the remainder of the division of first operand by the second operand.
# Example:
# 6 % 2 returns 0 as the outpu... | true |
ce0832075f90560db3586e536b3d7305266b9260 | BhagyashreeKarale/if-else | /ques9.py | 1,438 | 4.375 | 4 | # Question 9
# Consider the following rules:
# People 5 years and above in age can go to school.
# People 18 years and above in age can vote in elections.
# People 21 years and above in age can drive a car.
# People 24 years and above in age can marry.
# People 25 years and above in age can legally drink.
# Create a f... | true |
f7338151697bef111a36199e1dff7dcc8116f6e7 | Sujan0rijal/PythonLab | /main.py | 323 | 4.3125 | 4 | '''1. write a program that takes three numbers and prints their sum.
Every number is given on separate lines. '''
num1 = int(input("enter the first number;"))
num2 = int(input("enter the second number;"))
num3 = int(input("enter the third number;"))
sum = num1+num2+num3
print(sum)
print(f"the value of sum is {sum}")10... | true |
71b85955cab76e63cd13c937502feb879941047c | spoonsandhangers/ALevel_GUIBook | /3.1 labels.py | 2,383 | 4.3125 | 4 | """
Label widgets added to Frames.
padx and pady are parameters that set the interior distance from text in a label to the edge of the label.
when used in a frame it sets the distance from the edges of the frame to the internal widgets.
"""
import tkinter as tk
class ExampleFrame(tk.Frame):
def __init__(self, the_wi... | true |
492945d52ff99ce673b666781a6472e6d3536dba | mahinsagotra/Python | /Itertools/product.py | 251 | 4.1875 | 4 | # itertools: product, permutations, combinations, accumulate, groupby,
# and iterators
from itertools import product
a = [1, 2]
b = [3, 4]
prod = product(a, b) # cartesian product
print(list(prod))
prod = product(a, b, repeat=2)
print(list(prod))
| true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.