blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
608309973a1b4917b47c610e571f5c14b0fe521b | gurmeetkhehra/python-practice | /list after removing.py | 383 | 4.3125 | 4 | # 7. Write a Python program to print a specified list after removing the 0th, 4th and 5th elements.
# Go to the editor
# Sample List : ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
# Expected Output : ['Green', 'White', 'Black']
colors = ['Red', 'Green', 'White', 'Black', 'Pink', 'Yellow']
colors.remove('Red... | true |
f25df7963a9a9c81d8b28186b223350cf8d9ba87 | wudizhangzhi/leetcode | /medium/merge-two-binary-trees.py | 2,296 | 4.40625 | 4 | # -*- coding:utf8 -*-
"""
Given two binary trees and imagine that when you put one of them to cover the other, some nodes of the two trees are overlapped while the others are not.
You need to merge them into a new binary tree. The merge rule is that if two nodes overlap, then sum node values up as the new value of th... | true |
2c8eea9be7b8b5de96a5c44cf1d3c8e365eda746 | ChrisMatthewLee/Lab-9 | /lab9-70pt.py | 847 | 4.25 | 4 | ############################################
# #
# 70pt #
# #
############################################
# Create a celcius to fahrenheit calculator.
# Multiply by 9, then divide by 5, then add 32 t... | true |
93ed0f3ceef0a0fa18cb59080ff6542697db2335 | KyleKing/dash_charts | /dash_charts/equations.py | 2,691 | 4.4375 | 4 | """Equations used in scipy fit calculations."""
import numpy as np
def linear(x_values, factor_a, factor_b):
"""Return result(s) of linear equation with factors of a and b.
`y = a * x + b`
Args:
x_values: single number of list of numbers
factor_a: number, slope
factor_b: number,... | true |
6f1d5c730e20841150ac7b491b56cb52d28b221e | zingpython/december | /day_four/Exercise2.py | 1,322 | 4.28125 | 4 |
def intToBinary(number):
#Create empty string to hold the binary number
binary = ""
#To find a binary number divide by 2 untill the number is 0
while number > 0:
#Find the remainder to find the binary digit
remainder = number % 2
#Add the binary digit to the left of the current binary number
binary = str(... | true |
8cb15496c6ef28903d1ea910ab0abb964522d3d9 | missbanks/pythoncodes | /21062018.py | 359 | 4.125 | 4 | # TASK
# print(51 % 48)
name = input ("Hi what is your name")
add_time = 51
current_time = int(input("What is your current time"))
alarm_time = 5
extra_time = 3
if current_time == "2pm":
print("your alarm will go off at 5pm you have {} extra hours to go".format(extra_time))
else:
print("sorry you entered the wron... | true |
75e03f156082c03a2170993e90c2507dff58721a | ge01/StartingOut | /Python/chapter_03/programming_exercises/pe_0301/pe_0301/pe_0301.py | 1,107 | 4.65625 | 5 | #########################################################
# Kilometer Converter #
# This program asks the user to enter a distance in #
# kilometers, and then converts that distance to miles. #
# The conversion formula is as follows: #
# Miles = Kilometers * 0.6214 ... | true |
abdd052b5d57d6181e0d12a28283889354f045e5 | jjsanabriam/JulianSanabria | /Taller_1/palindromo.py | 410 | 4.4375 | 4 | '''It reads a word and it validates if word is a palindrome
Args:
PALABRA (string): word to validate
Returns (print):
resultado (string): Result of validate word (False or True)
+ word validate
'''
print("Ingrese Palabra: ")
PALABRA = input()
PALABRA_MAYUSCULA = PALABRA.upper()
if PALABRA_MAYUSCULA != ... | true |
facc0ddf980a825b8587cc05e4caf70ff85415b8 | bdllhdrss3/fizzbuzz | /fizzbuzz.py | 556 | 4.1875 | 4 | #making a fizz buzz app
#creating input of list
list1 = input("Enter list one : ")
list2 = input("Enter list two : ")
length1 = len(list(list1))
length2 = len(list(list2))
sumation = length1 + length2
fizz = sumation%3
buzz = sumation%5
#now creating the fizzbuzz function
def fizzbuzz():
if buzz == 0 and fizz == ... | true |
a8b0b1306df3c42d9333f9d979b494a39ca79d96 | Resham1458/Max_Min_Number | /max_min_nums.py | 520 | 4.34375 | 4 | total=int(input("How many numbers you want to enter?")) #asks user the total number he/she wants to enter
numbers = [int(input("Enter any whole number:")) for i in range(total)] # lets the user to enter desired number of numbers
print("The list of numbers you entered is:",numb... | true |
0cc4375b4bdce67644fa9a56784738b057b847f5 | kathytuan/CoffeeMachine | /main.py | 2,606 | 4.125 | 4 | MENU = {
"espresso": {
"ingredients": {
"water": 50,
"coffee": 18,
},
"cost": 1.5,
},
"latte": {
"ingredients": {
"water": 200,
"milk": 150,
"coffee": 24,
},
"cost": 2.5,
},
"cappuccino": {
... | true |
a87fa54c7333f4b517a7c4daf7883b6d463a6234 | kayanpang/champlain181030 | /week5-2_functions_181129/function.py | 684 | 4.34375 | 4 | # example: repetition
print("this is line 1")
print("---------------")
print("this is line 2")
print("---------------")
print("this is line 3")
print("---------------")
# so create a function to do this repetition
def print_underscores():
print("---------------")
# function needs to be defined before used
print("th... | true |
e4754d3dce75fe063cd24ecfc5dc2d543cdf0932 | kayanpang/champlain181030 | /190225_revision/different-kinds-of-array.py | 1,524 | 4.5625 | 5 | # list is ordered and changeable. Allows duplicate members. it uses [] square brackets
# – Use lists if you have a collection of data that does not need random access.
# Try to choose lists when you need a simple, iterable collection that is modified frequently.
mylist = [1, 2, 'Brendan']
print(mylist[1])
# tuple is o... | true |
c8b21caf9356d06471480f3488522d6ca31b01ed | kayanpang/champlain181030 | /week7-2_private-contribution/encapsulation.py | 859 | 4.375 | 4 | # worker - employee - contractor initializer in child Classes (slide15)
# read everything about class he whole chapter
class Worker:
"""this class represents a worker"""
def __init__(self, worker_name=""):
self.name = worker_name
def set_name(self, new_name):
self.__name - new_name
def ... | true |
6c01d290efd21c4d689c0c102398550d308dda30 | adesanyaaa/ThinkPython | /fermat.py | 941 | 4.46875 | 4 | """
Fermat's Last Theorem says that there are no positive integers a, b, and c such that
a^n=b^n=c^n
Write a function named check_fermat that takes four parameters-a, b, c
and n-and that checks to see if Fermat's
theorem holds. If n is greater than 2 and it turns out to be true
the program should print, "Holy smokes, F... | true |
32c8fe672f6a6127973b4b28a62ab056321249bf | adesanyaaa/ThinkPython | /lists10.py | 862 | 4.15625 | 4 | """
To check whether a word is in the word list, you could use the in operator, but it
would be slow because it searches through the words in order.
Because the words are in alphabetical order, we can speed things up with a bisection search (also
known as binary search), which is similar to what you do when you look a ... | true |
3f7e4990a911eabae25c224a4d9454f1196d4e4e | adesanyaaa/ThinkPython | /VolumeOfSphere.py | 300 | 4.375 | 4 | """ The volume of a sphere with radius r is (4/3)*pi*r^3
What is the volume of a sphere with the radius 5
Hint: 392.7 is wrong
"""
# For this we will be using the math.pi function in python
# first we need to import the math class
import math
r = 5
volume = (4 / 3) * math.pi * r ** 3
print(volume)
| true |
712e3c920965f9a21bedcdd7df712a7f79cd9dbd | adesanyaaa/ThinkPython | /dictionary2.py | 502 | 4.34375 | 4 | """
Dictionaries have a method called keys that returns the keys of the dictionary, in
no particular order, as a list.
Modify print_hist to print the keys and their values in alphabetical order.
"""
hist = {1: 2, 3: 4, 5: 6, 7: 8}
mydict = {'carl': 40,
'alan': 2,
'bob': 1,
'danny': 3}
d... | true |
88140b85b4cbc6075b2f18b09f12beb48eacc55a | adesanyaaa/ThinkPython | /store_anagrams.py | 1,116 | 4.1875 | 4 | """
Write a module that imports anagram_sets and provides two new functions: store_anagrams
should store the anagram dictionary in a "shelf;" read_anagrams should look up a word and return
a list of its anagrams.
"""
import shelve
import sys
from anagram_set import *
def store_anagrams(filename, ad):
"""Stores ... | true |
a6ae696b7ffe00652f7ef0d1c5ab8c4a7de0b474 | adesanyaaa/ThinkPython | /lists3.py | 570 | 4.21875 | 4 | """
Write a function that takes a list of numbers and returns the cumulative sum
that is, a new list where the ith element is the sum of the
first i + 1 elements from the original list. For
example, the cumulative sum of [1, 2, 3] is [1, 3, 6]
"""
def nested_sum():
a = int(input("Enter the number of Elements you ... | true |
481095e995d267d95df513b8deace98d3492090a | adesanyaaa/ThinkPython | /VariableAndValues.py | 849 | 4.6875 | 5 | """ Assume that we execute the following statements
width= 17
height=12.0
delimiter='.'
for each of the expressions below write down the expression and the type
1. width/2
2. width/2.0
3. height/3
4. 1+2*5
5. delimiter*5
"""
width = 17
height = 12.0
delimiter = '.'
# 1. Width /2 should give an integer value of 8.5-f... | true |
97914bc6f8c62c76aa02de1bd5c5f2a82e02e6db | nuria/study | /EPI/11_real_square_root.py | 748 | 4.1875 | 4 | #!usr/local/bin
import sys
import math
def inner_square_root(_max, _min, n):
tolerance = 0.05
middle = (_max - _min) *0.5
middle = _min + middle
print "max: {0}, min:{1}, middle:{2}".format(_max, _min, middle)
if abs(middle* middle -n) < tolerance:
return middle
elif middle * middle ... | true |
fd5abb56732e9ddf37f093fe007c6c848d414b44 | nuria/study | /misc/five-problems/problem3.py | 714 | 4.25 | 4 | #!/usr/local/bin/python
'''
Write a function that computes the list of the first 100 Fibonacci numbers. By definition, the first two numbers in the Fibonacci sequence are 0 and 1, and each subsequent number is the sum of the previous two. As an example, here are the first 10 Fibonnaci numbers: 0, 1, 1, 2, 3, 5, 8, 13... | true |
d929b25cb329d8a2c6589856e48e660c372b7aae | nuria/study | /crypto/xor.py | 1,748 | 4.46875 | 4 | #!/usr/local/bin/python
import sys
import bitstring
import virtualenv
# snipet given in coursera crypto course
# note xor of 11 and 001 will be 11, chops the last '1' at the longer string
def strxor(a, b): # xor two strings of different lengths
if len(a) > len(b):
return "".join([chr(ord(x) ^ ord(y)... | true |
352b8196d758694512da5c5105977cf6d4e76ce4 | nuria/study | /EPI/tmp_linked_list_flatten.py | 1,957 | 4.1875 | 4 | #!usr/local/bin
# define each node with two pointers
class llNode:
def __init__(self, value, _next = None, head = None):
self.value = value
# next node
self.next = _next
self.head = head
def __str__(self):
if self.value is None:
return 'None ->'
ret... | true |
cc3c31b09a402b7637ed05d98a01476620f26280 | nuria/study | /misc/five-problems/problem6.py | 1,726 | 4.25 | 4 | #!/usr/local/bin/python
import sys
def main():
'''
Given a sorted array and a target value, return the index
if the target is found. If not, return the index where
it would be if it were inserted in order. There won't be duplicate values in the array.
For example:
[1, 3, 5, 6] with target v... | true |
e37aeda0aa6f7d493dd27b2715d362a25138392a | maike-hilda/pythonLearning | /Ex2_5.py | 469 | 4.28125 | 4 | #Exercise 2.5
#Write a program that prompts the user for a Celsius temperature,
#convert the temperature to Fahrenheit, and print out the converted
#temperature
#Note: 0 deg C equals 32 deg F and 1 C increase equals 9/5 F increase
C = raw_input('Enter the current temperature in Degree Celcius:\n')
try:
C = f... | true |
767d08be4e912dd1824c4431dc5a4a047b53f805 | maike-hilda/pythonLearning | /Ex6_3.py | 326 | 4.21875 | 4 | #Exercise 6.3
#Write a function named count that accepts a string and a letter to
#be counted as an argument
def count(word, countLetter):
count = 0
for letter in word:
if letter == countLetter:
count = count + 1
print 'The letter', countLetter, 'appeared', count, 'times.'
... | true |
14e0fa9c2a493870a09bd9be0818e2c0d0766ca2 | priya510/Python-codes | /01.10.2020 python/min.py | 419 | 4.125 | 4 |
num1=int(input("Enter the first number: "));
num2=int(input("Enter the second number: "));
num3=int(input("Enter the Third number: "));
def find_Min():
if(num1<=num2) and (num1<=num2):
smallest=num1
elif(num2<=num1) and (num2<=num3):
smallest=num2
elif(num3<=num1) and (n... | true |
886ab87338fe873257b61abdb90971044bfb1db1 | jdn8608/Analysis_of_Algo_hw_2 | /src/sphere.py | 2,341 | 4.1875 | 4 | import math
'''
Name: Joseph Nied
Date: 2/12/20
Class: CSC-261
Question: 3
Description: Algorithm to see if given a points, if any would lie on a sphere together
'''
def main() -> None:
SIZE = int(input())
#Create an empty array with size SIZE
Magnitude = [None] * SIZE
#Get the input coordinates
... | true |
61af3f82b452f1e0402cafc2a5797e3ffbb399be | Tamabcxyz/Python | /th2/dictionariescollectioninpython.py | 371 | 4.15625 | 4 | #A dictionary is a collection unordered can changeable, index. In python dictionary are written with curly brackets
#the have keys and values
a={"name":"Tran Minh Tam", "age":22}
print(a)
for x in a.values():
print(x)
for x in a.keys():
print(x)
for x,y in a.items():
print(f"a have key {x} values is {y}")
#... | true |
d5438545ead5bb2d41c7791b6e86c72c4f93aa66 | LuannaLeonel/data-structures | /src/python/InsertionSort.py | 314 | 4.125 | 4 | def insertionSort(value):
for i in range(len(value)):
j = i
while (j > 0 and value[j] <= value[j-1]):
value[j], value[j-1] = value[j-1], value[j]
j -= 1
return value
a = [1,3,7,9,5]
b = [5,5,7,3,0,2,1,52,10,6,37]
print insertionSort(a)
print insertionSort(b)
| true |
37679aa5f19d56a0cd004f0349fb566d902f9464 | nara-l/100pythonexcercises | /Ex66basic_translator.py | 299 | 4.125 | 4 |
def translator(word):
d = dict(weather="clima", earth="terra", rain="chuva")
try:
return d[word.lower()]
except KeyError:
return "We don't understand your choice."
word = input("Please enter a word to translate, weather, earth, rain etc. \n ")
print(translator(word))
| true |
7d614f93d73dae587402e28e85e31062bafbdfa6 | matthewosborne71/MastersHeadstartPython | /Programs/Exercise1.py | 411 | 4.125 | 4 | # Write a program that generates a random integer between 1 and 100
# and then has the user guess the number until they get it correct.
import random
Number = random.randint(1,100)
Guess = -99
print "I thought of a number, want to guess? "
while Guess != Number:
Guess = int(raw_input())
if Guess != Number:
... | true |
b68ed99d0e68860f0ccdff2b272babe8ab836381 | InFamousGeek/PythonBasics | /ProgramToFindTheLngthOfAString1.py | 276 | 4.375 | 4 | # Python Program to find the length of a String (2nd way)
# using for loop
# Returns length of string
def findLen(str):
counter = 0
for i in str:
counter += 1
return counter
str = str(input("Enther the string : "))
print(findLen(str))
| true |
cf0fcc053e157beaa2b6eee2a78fa788d7cb2b8c | jonathan-murmu/ds | /data_structure/leetcode/easy/344 - Reverse String/reverse_string.py | 991 | 4.3125 | 4 | '''
Write a function that reverses a string. The input string is given as an array of characters s.
You must do this by modifying the input array in-place with O(1) extra memory.
Example 1:
Input: s = ["h","e","l","l","o"]
Output: ["o","l","l","e","h"]
Example 2:
Input: s = ["H","a","n","n","a","h"]
Output: ["h","a... | true |
05a2eece1e470e7324b753635da58de637b61b7c | Descent098/schulich-ignite-winter-2021 | /Session 3/Solutions/Exercise 1.py | 1,266 | 4.34375 | 4 | """Exercise 1: Country Roads
Steps:
1. Fill out fill_up() so that it fills the fuel level to the gas tank size (line 18)
2. Fill out drive() so that it removes the amount of fuel it should for how far you drove(line 22)
3. Fill out kilometres_available so that it returns the amount of kilometers left based... | true |
4b88131b589761baf17e03992be46cb9742c0a62 | praemineo/backpropagation | /backpropagation.py | 1,720 | 4.15625 | 4 | import numpy as np
#define sigmoid function
def sigmoid(x):
return 1 / (1 + np.exp(-x))
# X is a unit vector
x = np.array([0.5, 0.1, -0.2])
# target that we want to predict
target = 0.6
#learning rate or alpha
learnrate = 0.5
#weight that we initialize
weights_input_hidden = np.array([[0.5, -0.6],
... | true |
5a47d18b0353a71db8c6d177beed9cbda00ab3b6 | birdcar/exercism | /python/scrabble-score/scrabble_score.py | 584 | 4.1875 | 4 | from typing import Dict
# Generates a mapping of letters to their scrabble score e.g.
#
# { 'A': 1, ..., 'Z': 10 }
#
SCORE_SHEET: Dict[str, int] = dict(
[(x, 1) for x in 'AEIOULNRST'] +
[(x, 2) for x in 'DG'] +
[(x, 3) for x in 'BCMP'] +
[(x, 4) for x in 'FHVWY'] +
[(x, 5) for x in 'K'] +
... | true |
d7025c13f88527f24d10fc1a9b131f0c7e7bd627 | TheAughat/Setting-Out | /Python Practice/app4.py | 641 | 4.15625 | 4 | # The following block of code writes the times table for anything till times 10. Users can enter 'please stop' to quit
print('Writes the times table for anything till times 10. Enter "please stop" to quit.')
while True:
print()
tables = input("Which number do you want to see the tables of? ")
number ... | true |
9208bc3b8e1ef3b6ef3e291d410057f926b0a2ac | kenedilichi1/calculator | /main.py | 917 | 4.15625 | 4 |
def add(x, y):
''' Adds 2 numbers '''
return x + y
def subtract(x, y):
return x - y
def multiply(x, y):
return x * y
def divide(x, y):
return x / y
isRunning = True
while isRunning:
choice = input("operator: ")
if choice in ('add', 'subtract', 'multiply', 'divide'):
num1 = fl... | true |
8a4a09865d205160bc4fdbcbedbd77e8d1f48124 | Prithvi103/code-with-me | /Longest Mountain in Array {Medium}.py | 2,314 | 4.125 | 4 | """
Let's call any (contiguous) subarray B (of A) a mountain if the following properties hold:
B.length >= 3
There exists some 0 < i < B.length - 1 such that B[0] < B[1] < ... B[i-1] < B[i] > B[i+1] > ... > B[B.length - 1]
(Note that B could be any subarray of A, including the entire array A.)
Given an array A of int... | true |
9be5923a412b0d78f7a283c93f5acb80b52ac9b8 | musicakc/NeuralNets | /Tutorial/threelayernn.py | 1,701 | 4.15625 | 4 | '''
Neural Networks Tutorial 1:
https://iamtrask.github.io/2015/07/12/basic-python-network/
3 input nodes, 4 training examples
'''
import numpy as np
'''
Nonlinearity or sigmoid function used to map a value to a
value between 0 and 1
'''
def nonlin(x,deriv=False):
#ouput can be used to create derivative
if(deriv ... | true |
ca5d631772a998607acba42ead0af35f7956b6ee | nonstoplearning/python_vik | /ex13.py | 1,135 | 4.125 | 4 | from sys import argv
script, first, second, third = argv
fourth = input("Enter your fourth variable: ")
fifth = input("Enter your fifth variable: ")
print ("Together, your first variable is %r, your second variable is %r, your third variable is %r, "
"your fourth variable is %r, your fifth variable is %r" % (... | true |
db7f21092dc6cba286f2c1270129f7c56b706d25 | cheokjw/Pytkinter-study | /tkinter/Codes/tk button.py | 849 | 4.3125 | 4 | from tkinter import *
# Initializing Tk class OOP(Object-Oriented Programming)
root = Tk()
# A function that shows the text "Look! I clicked a Button"
def myClick():
myLabel = Label(root, text = "Look! I clicked a Button !")
myLabel.pack()
# Button(root, text) = having a button for user to click
# state = DI... | true |
ac6b346fd9f0262cfd9381e374236955ee972a5e | bfakhri/deeplearning | /mini-1/bfakhri_fakhri/regressor.py | 1,365 | 4.28125 | 4 | """
Author: Bijan Fakhri
Date: 2/3/17
CSE591 - Intro to Deep Learning
This file implements the regressor class which performs a linear regression given some data
"""
import numpy as np
class regressor(object):
"""
Class that implements a regressor. After training, it will have weights that can be exported.
Ar... | true |
4c483c108073d56208c7d1e56497e2dca3e6588a | NewAwesome/Fundamental-algorithms | /LeetCode/21. Merge Two Sorted Lists/Solution.py | 1,321 | 4.1875 | 4 | from ListNode import ListNode
class Solution:
# Iteration
def mergeTwoLists(self, l1: ListNode, l2: ListNode) -> ListNode:
# create a var named 'head' node, used for point to head of the result LinkedList
# create a var named 'cur' node, used for iteration point to the smaller node of l1 and ... | true |
5e8d193c0a21c3c3dfafcb0fb94419777359e9ca | jjunsheng/learningpython | /mosh python/quiz(comparison operators).py | 438 | 4.46875 | 4 | #if name is less than 3 characters long
#name must be at least 3 characters
#otherwise if it's more than 50 characters long
#name can be a maximum of 50 chatacters
#otherwise
#name looks good
name = input('Name : ')
if len(name) < 3:
print("Name must be a minumum of 3 characters. Please try again.")
elif len(nam... | true |
ba2ce236426a14d35f10540770106ef7e14735a2 | maheboob76/ML | /Basics/Perceptron_vs_Sigmoid.py | 1,077 | 4.25 | 4 | # -*- coding: utf-8 -*-
"""
http://neuralnetworksanddeeplearning.com/chap1.html#exercise_263792
Small example to show difference between a perceptron and sigmoid neuron
For a Machine Learning model to learn we need a mechanism to adjust output of model by small adjustments in input. This example shows
why a percpt... | true |
4fe62261defaeed3b3dcc21aff9d1bebdca21225 | MarcusDMelv/Summary-Chatbot | /voice.py | 1,395 | 4.125 | 4 | # Code based on https://www.geeksforgeeks.org/text-to-speech-changing-voice-in-python/
# Python program to show
# how to convert text to speech
import pyttsx3
# Initialize the converter
converter = pyttsx3.init()
# Set properties before adding
# Things to say
# Sets speed percent
# Can be more than 100
converter.se... | true |
4f3f602373b166d9a2a9af94c5a33befa671208c | grantthomas/project_euler | /python/p_0002.py | 955 | 4.1875 | 4 | # Even Fibonacci numbers
# Problem 2
# Each new term in the Fibonacci sequence is generated by adding the previous two terms. By starting with 1 and 2, the first 10 terms will be:
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
# By considering the terms in the Fibonacci sequence whose values do not exceed four million, find... | true |
64b527ed4f5a3a18da10ee421e7b88b06e90bed7 | kkbaweja/CS303 | /Hailstone.py | 2,487 | 4.4375 | 4 | # File: Hailstone.py
# Description: A program that computes the hailstone sequence for every number in a user defined range
# Student Name: Keerat Baweja
# Student UT EID: kkb792
# Course Name: CS 303E
# Unique Number: 50860
# Date Created: 2/7/2016
# Date Last Modified: 2/9/2016
def ma... | true |
81603ced0143981ee6540c89ee829ff663547c2f | v-erse/pythonreference | /Science Libraries/Numpy/arraymath.py | 1,033 | 4.34375 | 4 | import numpy as np
print("Array Math:")
# Basic mathematical functions operate on ndarrays in an elementwise fashion
a = np.arange(10).reshape(2, 5)
b = np.arange(10).reshape(2, 5)
print(a + b)
print(a*b)
# We can use the dot function to find dot products of vectors and multiply
# matrices (the matrixmultiplication.j... | true |
afe6d64552f6328412a7129f7a2fad6eadc8c554 | andres-zibula/geekforgeeks-problems-solved | /basic/twisted_prime_number.py | 554 | 4.15625 | 4 | """
Author: Andres Zibula
Github: https://github.com/andres-zibula/geekforgeeks-problems-solved
Problem link: http://practice.geeksforgeeks.org/problems/twisted-prime-number/0
Description: A number is said to be twisted prime if it is a prime number and reverse of the number is also a prime number.
"""
import math
... | true |
8f9692a0be3836b363adc733511e4addbfc12292 | coder2000-kmj/Python-Programs | /numprime.py | 595 | 4.34375 | 4 | '''
This is a program to print prime numbers starting from a number which will be given by the user
and the number of prime numbers to be printed will also be specified by the user
'''
def isprime(n,i=2):
if n<=2:
return True if n==2 else False
if n%i==0:
return False
if i*i>n:
... | true |
ecc4d29375e3c6200c6ac3b8f9f3b4f4c0769ca7 | alphashooter/python-examples | /homeworks-2/homework-2/task2.py | 574 | 4.125 | 4 | import calendar
from datetime import datetime
target: int
while True:
day_name = input(f'Enter day name ({calendar.day_name[0]}, etc.): ')
for day, name in enumerate(calendar.day_name):
if name == day_name:
target = day
break
else:
print('invalid input')
con... | true |
eca16d3794404a3659a448df344b120d26e9fe2e | mey1k/PythonPratice | /PythonPriatice/InsertionSort.py | 252 | 4.15625 | 4 | def insertionSort(x):
for size in range(1, len(x)):
val = x[size]
i = size
while i > 0 and x[i-1] > val:
x[i] = x[i-1]
i -= 1
x[i] = val
print(x)
insertionSort([3,23,14,123,124,123,12,3]) | true |
bd40b86f7639ce864d19963092c1535a68118866 | kulvirvirk/list_methods | /main.py | 1,619 | 4.6875 | 5 |
# The list is a collection that is ordered and changeable. Allows duplicate members.
# List can contain other lists
# 1. create a list of fruits
# 2. using append(), add fruit to the list
# 3. use insert(), to insert another fruit in the list
# 4. use extend() method to add elements to the list
# 5. use pop() method ... | true |
a232c1dbe330abefd09cb6c54916776cfae04c2b | darkscaryforest/example | /python/classes.py | 1,316 | 4.21875 | 4 | #!/usr/bin/python
class TestClass:
varList = []
varEx1 = 12
def __init__(self):
print "Special init function called."
self.varEx2 = 13
self.varEx3 = 14
def funcEx(self):
print self.varEx2
return "hello world"
x = TestClass()
print "1. Classes, like functions, must be declared before use.\n" \
"Calling... | true |
0d3ea4123385980f8b24ecc5b59397e5e813372d | SnakeTweaker/PyStuff | /module 6 grocery list.py | 1,490 | 4.125 | 4 |
'''
Author: CJ Busca
Class: IT-140
Instructor: Lisa Fulton
Project: Grocery List Final
Date: 20284
'''
#Creation of empty data sctructures
grocery_item = {}
grocery_history = []
#Loop function for the while loop
stop = 'go'
while stop !='q':
#This block asks the user to input name, quantity, ... | true |
0c4f077fa6e50d24ad81f1e7de30b08e60ac34f6 | radishmouse/2019-11-function-demo | /adding-quiz.py | 437 | 4.3125 | 4 | def add(a, b):
return a + b
# print(a + b)
# if you don't have a `return`
# your function automatically
# returns `None`
# Write a function that can be called like so:
add(1, 1)
# I expect the result to be 2
num1 = int(input("first number: "))
num2 = int(input("second number: "))
num3 = int(input(... | true |
21e783fc5101c5cc328ec3fb5ea750e4f3773f72 | Sushmitha2708/Python | /Data Modules/JSONModulesFromFiles.py | 926 | 4.21875 | 4 | #this progam deals with how to load JSON files into python objects and then write those
# objects back to JSON files
import json
# to load a JSON file into a python object we use JSON 'load' method
#load method--> loads a file into python object
#loads method --> loads a string into a python object
# to l... | true |
b6d0f2e9b62f82970b371114f8734acc87026c0a | Sushmitha2708/Python | /Loops and Conditionals/ForLoop.py | 236 | 4.125 | 4 | #SET COMPREHENSIONS
# set is similar to list but with unique values
nums=[1,1,1,2,3,5,5,5,4,6,7,7,8,9,9] #list
my_set=set()
for n in nums:
my_set.add(n)
print(my_set)
#comprehension
my_set={n for n in nums}
print(my_set) | true |
7da4fa2f89f95532f15bf6e442d8d83af17f3bb4 | XanderEagle/unit6 | /unit6.py | 1,349 | 4.3125 | 4 | # by Xander Eagle
# November 6, 2019
# this program displays the Birthday Paradox showing the percent of people that have the sme birthday based on the
# amount of simulations
import random
def are_duplicates(nums):
"""finds the duplicates
:return: true if there is a duplicate
false if no duplica... | true |
2865d43f5210b945eadc07481a14436f34b3ad23 | Mike7P/python-projects | /Guessing_game/guessing_game.py | 1,147 | 4.125 | 4 |
print("Welcome to Kelly's Number Guessing Game!")
print("I'm thinking of a number between 1 and 100.")
attempts = 0
difficulty_choosing = False
random_num = randint(1, 100)
# print(f"Pssst, the correct answer is {random_num}")
def guessing_func(guess, random_num):
global attempts
attempts -= 1
if guess == rando... | true |
d7dd96224064d98e702d82a4b781989d265e0fcb | nathanhwyoung/code_wars_python | /find_the_parity_outlier.py | 910 | 4.4375 | 4 | # https://www.codewars.com/kata/5526fc09a1bbd946250002dc
# You are given an array (which will have a length of at least 3, but could be very large) containing integers.
# The array is either entirely comprised of odd integers or entirely comprised of even integers except for a
# single integer N. Write a method that ... | true |
78f52eed0d2426d52462b9467f6224ead214b4fb | pavankumarNama/PythonLearnig | /Ex_Files_Python_Standard_Library_EssT/Exercise Files/Chapter 5/05_01/datetime_start.py | 810 | 4.34375 | 4 | # Basics of dates and times
from datetime import date, time, datetime
# TODO: create a new date object
tdate = date.today()
print(tdate)
# TODO: create a new time object
t = time(15, 20, 20)
print(t)
# TODO: create a new datetime object
dt = datetime.now()
dt1 = datetime.today()
print(dt)
print(dt1)
# TODO: access... | true |
6c506a5b929738c7bfe76797f93923041020f061 | okeonwuka/PycharmProjects | /ProblemSolvingWithAlgorithmsAndDataStructures/Chapter_1_Introduction/pg29_selfcheck_practice.py | 2,996 | 4.15625 | 4 | import random
# create alphabet characters including 'space' character
alphabet_list = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l',
'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', ' ']
# create empty list to house character matches from target s... | true |
8c40de2b5d9cfbb59af3428537caac07ed102c99 | okeonwuka/PycharmProjects | /Horizons/pythonPracticeNumpyArrays.py | 1,687 | 4.40625 | 4 | # The numpy module gives users access to numpy arrays and several computation tools.
# Numpy arrays are list-like objects intended for computational use.
from pprint import pprint
import numpy as np
my_array = np.array([1, 2, 3])
pprint(my_array)
# Operations on a numpy array are made element by element (unlike fo... | true |
fa7839e158a42655a6bbdab05620c5fa0d1e7aa7 | wp-lai/xpython | /code/kthlargest.py | 922 | 4.21875 | 4 | """
Task:
Find the kth largest element in an unsorted array. Note that it is the kth
largest element in the sorted order, not the kth distinct element.
>>> find_kth_largest([3, 2, 1, 5, 6, 4], 2)
5
"""
from random import randint
def find_kth_largest(nums, k):
# find a random pivot
length = len(nums)
... | true |
7d17cbaddef7f2dad0a85adad69a2d838c7f2936 | wp-lai/xpython | /code/int2binary.py | 1,431 | 4.1875 | 4 | """
Task:
Converting decimal numbers to binary numbers
>>> convert_to_binary(25)
'0b11001'
>>> convert_to_binary(233)
'0b11101001'
>>> convert_to_binary(42)
'0b101010'
>>> convert_to_binary(0)
'0b0'
>>> convert_to_binary(1)
'0b1'
"""
# Solution 1:
# keep dividing by 2, store the remainder in a stack
# read in re... | true |
c65b02fc056b996dacd941e299fe558d47785d6d | erinnlebaron3/python | /partitionstr.py | 2,573 | 4.78125 | 5 | # partition function works in Python is it's going to look inside the string for whatever you pass in as the argument.
# once it finds that it then partitions the entire string and separates it into three elements and so it is going to take python and it is going to be the first element.
# whenever you call partiti... | true |
dd552daf2cf44e1a08733c54e31204750afc4f43 | erinnlebaron3/python | /List.py | 2,563 | 4.875 | 5 | # like an array. It is a collection of values and that collection can be added to. You can remove items. You can query elements inside of it.
# Every time that you want a new database query what it's going to do is it's going to look at its set of data structures and it's going to go and it's going to put them in that.... | true |
9673ae62285d1caf5117a936bb1e05b7699a76a6 | erinnlebaron3/python | /PackageProject.py | 2,385 | 4.4375 | 4 | # will help you on the entire course capstone project
# Technically you have learned everything that you need to know in order to build out this project.
# helps to be familiar with some of the libraries that can make your life a little bit easier and
# make your code more straightforward to implement
# web scrape... | true |
077bbfec6567508594cadabda71238de6829b41c | erinnlebaron3/python | /NegativeIndexStr.py | 777 | 4.15625 | 4 | # In review the first value here is zero. The next one is one and it counts all the way up in successive values.
# However if you want to get to the very back and you actually want to work backwards then we can work with negative index
sentence = 'The quick brown fox jumped over the lazy dog'
print(sentence[-1])
a... | true |
ad51a4b6182415c29a404f0457b9d168f2ced94d | erinnlebaron3/python | /decimalVSfloat.py | 2,791 | 4.46875 | 4 | # in python all decimals are floating numbers unless decimal is called
# you can create a decimal is to copy decimal it has to be all like this with it titled with the capital D and decimal spelled out and then because it's a
# function we're going to call decimal.
# when it comes to anything that is finance related o... | true |
f3566a6b295b511718e3fac82156d6bad58b52a0 | erinnlebaron3/python | /FuncConfigFallBck.py | 1,356 | 4.40625 | 4 | # syntax for doing is by performing something like this where I say teams and then put in the name of the key and then that is going to perform the query.
# want to have a featured team so I can say featured team store this in a variable.
teams = {
"astros": ["Altuve", "Correa", "Bregman"],
"angels": ["Trout", "... | true |
023d47ee8dced82d994b1660c359715d72761482 | erinnlebaron3/python | /lenNegIndex.py | 1,462 | 4.46875 | 4 | # LENGTH
# the length function and it's actually called the L E N which is short for length
# this is going to give you the count for the full number of elements in a list
# there is a difference between length and index
# LENGTH
# remember the counter starts and the index starts at 0.
# even though we have four el... | true |
6a88efb4a656dfda208f49f561d287175734e755 | erinnlebaron3/python | /FilesinPy.py/Create&WriteFile.py | 1,659 | 4.625 | 5 | # very common use case for working with the files system is to log values
# gonna see how we can create a file, and then add it to it.
# create a variable here where I'm going to open up a file.
# I'm going to show you here in the console that if I type ls, you can see we do not have a file called logger.
# functi... | true |
0ae57c234dc5a9daa688426e8c4953980f510f65 | erinnlebaron3/python | /Slice2StoreSlice.py | 2,968 | 4.78125 | 5 | # here are times where you may not know or you may not want to hard code in this slice range.
# And so in cases like that Python actually has a special class called slice which we can call and store whatever these ranges we want
# biggest reasons why you'd ever use this slice class over using just this explicit versi... | true |
987adf3d6c77ee903e0cf74b398c8cfdcb2d54f3 | jibinsamreji/Python | /MIni_Projects/carGameBody.py | 964 | 4.15625 | 4 | print("Welcome player! Type 'help' for more options..!")
user_input = input(">")
i = 0
start = False
stop = False
while user_input.upper() == "HELP":
if i < 1:
print("""
start - to start the car
stop - to stop the car
quit - to exit""")
i += 1
game_option = input(">").upper()... | true |
3d8b2938eed4cd2d299218d4dd787d80518e8154 | victorsibanda/python-basics | /102_python_data_types.py | 1,696 | 4.59375 | 5 | #Strings
#Text and Characters
#Syntax
#"" and ''
#Define a string
#Anything that is text is a string
my_string = 'Hey I am a cool string B)'
print(my_string)
type(my_string)
#Concatenation
joint_string = 'Hey I am another' + ' cool string, ' + my_string
print (joint_string)
#example two of concatenation
name = 'M... | true |
faa0ffceb30031674446ed24efdb4e6085fa9873 | victorsibanda/python-basics | /101_python_variables_print_type.py | 531 | 4.1875 | 4 | # Variables
# it is like a box, you give it a name, and put stuff inside
book = 'Rich dad poor dad'
## Print function
#Outputs content to the terminal (makes it visible)
print(book)
# Type function
#Allows us to check data types
data_type_of_book = type(book)
print (data_type_of_book)
#input() - prompt for user... | true |
d6320818cdbf2b26bcffb410c1cad8e27ef9477f | devionb/MIM_Software_code_sample | /Part_A.py | 642 | 4.375 | 4 | # Devion Buchynsky
# Part A - Reverse the string if its length is a multiple of 4.
# multiples of 4: 4,8,12,16......
multiple_of_4_string_letter = 'abcd'
multiple_of_5_string_letter = 'abcde'
print('Before function is ran.')
print(multiple_of_4_string_letter)
print(multiple_of_5_string_letter)
def reverse_string(s... | true |
064a088d379dc1010eaa365e9857615bcd8f4d56 | diallog/PY4E | /assignment5.2/assignment5.2_noIntTest.py | 1,133 | 4.1875 | 4 | # Assignment 5.2 Write a program that repeatedly prompts a user for integer numbers until the user enters 'done'. Once 'done' is entered, print out the largest and smallest of the numbers. If the user enters anything other than a valid number catch it with a try/except and put out an appropriate message and ignore the ... | true |
4b0ec224525c1b9e584710cbe2456aa7c2f9000d | diallog/PY4E | /assignment2.3/assignment2.3.py | 606 | 4.21875 | 4 | # This assignment will obtain two pieces of data from the user and perform a calculation.
# This script begins with a hint from the course...but lets do a little over-achievement.
print("Alright, let's do our first calculation in Python using information obtained from the user.\r")
# This first line is provided for ... | true |
7c023a7743c6f76a6f4c5b2bd46535ccae3d2efe | priyanshu3666/my-lab-practice-codes | /if_else_1.py | 237 | 4.21875 | 4 | #Program started
num = int(input("Enter a number")) #input taking from user
if (num%2) == 0 : #logic start
print("The inputted muber",num," is Even")
else :
print("The inputted muber",num," is Odd") #logic ends
#Program Ends
| true |
1f3007154c8734dce197638aae123261f4fd3eca | iamdoublewei/Leetcode | /Python3/125. Valid Palindrome.py | 983 | 4.28125 | 4 | '''
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
Note: For the purpose of this problem, we define empty string as valid palindrome.
Example 1:
Input: "A man, a plan, a canal: Panama"
Output: true
Example 2:
Input: "race a car"
Output: false
'''
#Orig... | true |
336f4764f1208ed1e8cea45946a6e097187ec098 | iamdoublewei/Leetcode | /Python3/1507. Reformat Date.py | 1,545 | 4.375 | 4 | '''
Given a date string in the form Day Month Year, where:
Day is in the set {"1st", "2nd", "3rd", "4th", ..., "30th", "31st"}.
Month is in the set {"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}.
Year is in the range [1900, 2100].
Convert the date string to the format YYYY-MM-DD, ... | true |
38e0976de0b8376345610a411550df8ca5639293 | iamdoublewei/Leetcode | /Python3/680. Valid Palindrome II.py | 1,005 | 4.15625 | 4 | '''
Given a non-empty string s, you may delete at most one character. Judge whether you can make it a palindrome.
Example 1:
Input: "aba"
Output: True
Example 2:
Input: "abca"
Output: True
Explanation: You could delete the character 'c'.
Note:
The string will only contain lowercase characters a-z. The maximum length o... | true |
84a99ce38f0a9fa7e7456be2ec28f70c54b8d41d | iamdoublewei/Leetcode | /Python3/849. Maximize Distance to Closest Person.py | 1,464 | 4.25 | 4 | '''
In a row of seats, 1 represents a person sitting in that seat, and 0 represents that the seat is empty.
There is at least one empty seat, and at least one person sitting.
Alex wants to sit in the seat such that the distance between him and the closest person to him is maximized.
Return that maximum distance to... | true |
98ceacd32d0924643b4f6caa745e67c3f754951e | iamdoublewei/Leetcode | /Python3/417. Pacific Atlantic Water Flow.py | 2,184 | 4.40625 | 4 | '''
There is an m x n rectangular island that borders both the Pacific Ocean and Atlantic Ocean. The Pacific Ocean touches the island's left and top edges, and the Atlantic Ocean touches the island's right and bottom edges.
The island is partitioned into a grid of square cells. You are given an m x n integer matrix he... | true |
06603409c216e418a50c655532a82a17429f040c | iamdoublewei/Leetcode | /Python3/2000. Reverse Prefix of Word.py | 1,366 | 4.40625 | 4 | '''
Given a 0-indexed string word and a character ch, reverse the segment of word that starts at index 0 and ends at the index of the first occurrence of ch (inclusive). If the character ch does not exist in word, do nothing.
For example, if word = "abcdefd" and ch = "d", then you should reverse the segment that start... | true |
e3b81970fb6473a49d9a480991999a110605927d | kirakrishnan/krishnan_aravind_coding_challenge | /TLS/turtle_simulator.py | 2,218 | 4.125 | 4 | import turtle
import time
def setup_simulator_window():
"""
set up a window with default settings to draw Traffic Lights
:param:
:return t: turtle object
"""
t = turtle.Turtle()
t.speed(0)
t.hideturtle()
screen = turtle.Screen()
screen.screensize()
screen.setup(width = 1.0,... | true |
91c081afcb0ca54068bd1a38049c3da5ddd73c6a | evantarrell/AdventOfCode | /2020/Day 2/day2.py | 1,622 | 4.21875 | 4 | # Advent of Code 2020 - Day 2: Password Philosophy
# Part 1, read input file with each line containing the password policy and password. Find how many passwords are valid based on their policies
# Ex: 1-3 a: abcde is valid as there is 1 a in abcde
# but 3-7 l: ablleiso is not valid as there are only 2 l's in ablleiso
... | true |
684f9a65b6c72684f2355958751ae8d4b1de97a5 | kaushikram29/python1 | /character.py | 220 | 4.21875 | 4 | X=input("Enter your character")
if((X>="a" and X<="z) or (X>="A" and X<="Z")):
print(X, "it is an alphabet")
elif ((X>=0 and Z<=9)):
print(X ,"it is a number or digit")
else:
print(X,"it is not alphabet or digit")
| true |
14a4ed8730578aa3a1fcf7bf32b3096835ac221c | Clearymac/Integer-division-and-list | /task 2.py | 864 | 4.28125 | 4 | #LIST RETARRD
list = ['Evi', 'Madeleine', 'Cool guy', 'Kelsey', 'Cayden', 'Hayley', 'Darian']
#sorts and prints the list
list.sort()
print('Sorted list:', list)
#asks the user to input their name
name = input("What is your name? ")
name = name.title()
#checks if name is in list and gives option to add to list
if na... | true |
451af1ea328f3331078e6271fb0a7dcb24e8c2fd | mentalclear/autobots-fastapi-class | /typing_playground/funcs/random_stuff.py | 485 | 4.1875 | 4 | def greeting(name: str) -> str:
""" This function expects to have argument name of type string"""
return 'Hello ' + name
print(greeting('Tester'))
# A type alias is defined by assigning the type to the alias. In this example,
# Vector and list[float] will be treated as interchangeable synonyms
Vector = lis... | true |
609b61bab4602df7434e12d207ae1ff5862534cb | ChristyLeung/Python_Green | /Green/5.3.1-2 voting.py | 487 | 4.1875 | 4 | # 5.3
# 5.3.1
if conditional_test:
do something
age = 19
if age >= 18:
print("You are old enough to vote!")
age = 19
if age >= 18:
print("You are old enough to vote!")
print("Have you registered to vote yet?")
# 5.3.2
age = 17
if age >= 18:
print("You are old enough to vote!"... | true |
1f8acbbc0af62fdf18d8408eade076fce2d59931 | KShaz/Machine-Learning-Basics | /python code/ANN 3-1 Supervised Simoid training.py | 1,725 | 4.125 | 4 | # https://iamtrask.github.io/2015/07/12/basic-python-network/
#X Input dataset matrix where each row is a training example
#y Output dataset matrix where each row is a training example
#l0 First Layer of the Network, specified by the input data
#l1 Second Layer of the Network, otherwise known as the hidden layer
#S... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.