blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
650b9b01a3e2e8b2e4f0f794e136649794a75c4c
ADABRAMS/Quiz1
/testQuiz1.py
2,793
3.765625
4
import unittest from quiz1 import HiLo # errors?? Why? Hilo has a class defined in quiz1, not sure why. from quiz1 import Hangman # I keep getting errors from these lines, I attempted changing it to import Hangman #from quiz1 with same results. I think this is trying to get info from the quiz1.py but can't...
bdc35eef96f32edfceb54337c8905ad3db264a85
sidharthparthsarathi/IOT-Assignment-02
/IOT ASSIGNMENT-2/Part-01(Till looping)/Sum_Prod_Cons_Digit.py
106
3.765625
4
num=input(" Enter a number: ") print(sum(int (num[i]) * int (num[i + 1 ]) for i in range (0,len(num)-1)))
3855d21a7079c2c40b5145678e95334390f426c7
sidharthparthsarathi/IOT-Assignment-02
/IOT ASSIGNMENT-2/Part-01(Till looping)/Diff_Sum.py
253
3.5625
4
num=input("Enter a number: ") even=list(filter(lambda x: x in [0,4,8],map(int,num))) odd=list(filter(lambda x: x in [1,5,9], map(int,num))) print(sum([even[i]*even[i+1] for i in range(len(even)-1)]) - sum([odd[i]*odd[i+1] for i in range(len(odd)-1)]))
cd00294daad75b9f324ab7a6cf4a6a0654577f15
Mona-Arami/python-challenge
/PyPoll/main.py
2,529
3.71875
4
import os import csv # Set the path for the CSV file in PyPollcsv PyPollcsv = os.path.join("Resources","election_data.csv") # Initialize the variables and Create the empty lists for Candidates and their votes. candidates = [] num_votes = [] vote_percent = [] winner_list = [] total_votes = 0 #Creates the dictionary...
50fa98499baee91280b2cca96e8722e7cc4f0080
dlautzenheiser/WebFOCUS
/helloworld.py
717
3.890625
4
# test program called by WebFOCUS # for python system input arguments import sys # function to show arguments def show_arguments(): print ('Running Python script named %s' % (sys.argv[0])) if len(sys.argv) > 1: # in addition to program name, at least one parameter was provided print ('#Arguments= ', ...
366ca5c394a7c225ba04123d39595debadee6742
getachew67/dataprogramming-1
/CSE160_hw1/hw1.py
1,715
4.375
4
# Name: Michael Shieh 1826962 # CSE 160 # Winter 2020 # Homework 1 # You may do your work by editing this file, or by typing code at the # command line and then copying it into the appropriate part of this file when # you are done. When you are done, running this file should compute and # print the answers to all of ...
41a587d19367911a8f416d9ae3a69b713d8d7131
Anri-Lombard/PythonBootcamp
/day8/81.py
345
3.921875
4
import math def paint_calc(height, width, cover): cans_decimal = round((height * width) / cover) cans_round = math.ceil(cans_decimal) print(f"You need {cans_round} cans of paint.") test_h = int(input("Height of wall: ")) test_w = int(input("Width of wall: ")) coverage = 5 paint_calc(height=test_h, width...
1ac0d8c282d7a5bc382929ca9d8f612fb72a0848
Anri-Lombard/PythonBootcamp
/day24/snake_game/scoreboard.py
1,126
3.84375
4
from turtle import Turtle # The scoreboard is now a turtle so I can just treat it as such. HEIGHT = 600 WIDTH = 600 HALF_WIDTH = int(WIDTH / 2) - 20 HALF_HEIGHT = int(HEIGHT / 2) - 20 ALIGNMENT = "center" FONT = ("Courier", 24, "normal") class Scoreboard(Turtle): def __init__(self): super().__init__() ...
2711c8bd5447c290fc89fa98669a1cb1b8462c23
Anri-Lombard/PythonBootcamp
/day3/36.py
1,010
3.921875
4
# "Angela".count("a") = 1 (counts only lower case a) # lower_case_name = "Angela".lower() # lower_case_name.count("a") = 2 print("Welcome to Love Calculator!") name1 = input("What is your name?\n") name2 = input("What is their name?\n") t = name1.lower().count("t") + name2.lower().count("t") r = name1.lower().count("r...
033eebde8c7a5d41bdcb5b75bef89387a4420f1e
Anri-Lombard/PythonBootcamp
/day3/30.py
439
4.25
4
height = float(input("Enter your height in m: ")) weight = float(input("Enter your weight in kg: ")) bmi = weight / height ** 2 reading = f"Your BMI is {bmi}, and " if bmi < 18.5: reading += "you are underweight." elif bmi < 25: reading += "you are normal weight." elif bmi < 30: reading += "you are overwei...
bf779bdb0bc1629de1686591a83b6d401be69a21
Anri-Lombard/PythonBootcamp
/day19/etch_a_sketch.py
625
3.578125
4
import turtle as turtle_module tim = turtle_module.Turtle() def move_forward(): tim.forward(10) def move_backward(): tim.backward(10) def clockwise(): new_heading = tim.heading() - 10 tim.setheading(new_heading) def anti_clockwise(): new_heading = tim.heading() + 10 tim.setheading(new_h...
235c0bf0f5e97f6f0a6fc329952859bbbbd56ac1
Anri-Lombard/PythonBootcamp
/day14/higher_lower_game.py
1,511
3.78125
4
import higher_lower_art import higher_lower_data import random # functions def random_num(): n1 = random.randint(0, len(data)) return n1 def play(score): global b_participant score += 1 a_participant = random_num() if score > 0: a_participant = b_participant print(f"You're r...
024991e3fe12304385c670c72f6dc5fa71e1b353
Anri-Lombard/PythonBootcamp
/day21/snake_game/scoreboard.py
837
3.828125
4
from turtle import Turtle # The scoreboard is now a turtle so I can just treat it as such. HEIGHT = 600 WIDTH = 600 HALF_WIDTH = int(WIDTH / 2) - 20 HALF_HEIGHT = int(HEIGHT / 2) - 20 ALIGNMENT = "center" FONT = ("Courier", 24, "normal") class Scoreboard(Turtle): def __init__(self): super().__init__() ...
3f96ab2973a27b7a3a5f64178c5ef50c75b60b75
Cocowtk/Intro-to-Python
/combined examples/chapter_07.py
35,423
4.03125
4
# Section 7.2 snippets import numpy as np numbers = np.array([2, 3, 5, 7, 11]) type(numbers) numbers # Multidimensional Arguments np.array([[1, 2, 3], [4, 5, 6]]) ########################################################################## # (C) Copyright 2019 by Deitel & Associates, Inc. and # # ...
3d98ce8fdf8cc89ebff82af0015b75904db80785
Cocowtk/Intro-to-Python
/IntroToPythonSlides/ch13/tweetlistener.py
2,424
3.640625
4
# tweetlistener.py """tweepy.StreamListener subclass that processes tweets as they arrive.""" import tweepy from textblob import TextBlob class TweetListener(tweepy.StreamListener): """Handles incoming Tweet stream.""" def __init__(self, api, limit=10): """Create instance variables for tracking number...
de50203bab7333246934ecb9f88f38ae7d211923
Cocowtk/Intro-to-Python
/Exam Solutions/Midterm12_Solution.py
951
3.625
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 14 10:12:43 2020 @author: Troy """ import statistics # List=[] def descriptive(myList): values=[0,0,0,0] titles=("Mean is:", "Median is:", "Sample SD is:", "Population SD is:") mean = statistics.mean(myList) median = statistics.median(myList) stdev = s...
015bc7219e2cdc8bd7be10088068a98d115b7151
jabhax/python-data-structures-and-algorithms
/OOP/Proxy.py
1,394
3.5625
4
# Design Patterns ''' The Proxy Pattern includes an object called “Proxy” to be in place of an existing object which is called the “Real Subject”. The Proxy object created of the real subject must be on the same interface in such a way that the client should not get any idea that Proxy is used in place of the real obj...
74034a218d3b8b8ac517817ba2939d6ef0cfcb22
jabhax/python-data-structures-and-algorithms
/OOP/Singleton.py
1,340
4.25
4
# Design Patterns ''' The Singleton Pattern restricts the instantiation of a class to one object. It is a type of creational pattern and involves only one class to create methods and specified objects. It provides a global point of access to the instance created. ''' class Singleton: __instance = None @static...
3bd7e9f5500e3ba3a67da98e7d2a4104aaaee8de
jabhax/python-data-structures-and-algorithms
/OOP/Decorators/ShopDecorator.py
2,367
4.53125
5
# Design Patterns ''' Decorator Pattern allows a user to add new functionality to an existing object without altering its structure. This pattern acts as a wrapper to existing class by creating a decorator class, which wraps the original class and provides additional functionality keeping the class methods signature i...
a64a95ea211b784e6e5913c48509e71905e5150a
jabhax/python-data-structures-and-algorithms
/OOP/StringSerialization.py
981
3.75
4
# Design Patterns ''' String serialization is the process of writing a state of object into a byte stream. In python, the “pickle” library is used for enabling serialization. This module includes a powerful algorithm for serializing and de-serializing a Python object structure. “Pickling” is the process of converting ...
51dae4294a247438e45ac9ee0730062efcc55b22
tanaes/ascii2dna
/ascii2dna.py
1,865
4.09375
4
### frm, to, and convert are from https://www.quora.com/How-do-I-write-a-program-in-Python-that-can-convert-an-integer-from-one-base-to-another/answer/Nayan-Shah def frm(x, b): """ Converts given number x, from base 10 to base b x -- the number in base 10 b -- base to convert """ assert(x >= 0...
af2f116bec9e984d5dc4913202db4d934fac06e4
MingkaiMa/Project-Euler
/Problem_37_46.py
5,833
3.8125
4
##Problem 37 ##from math import sqrt ## ##def is_prime(n): ## if n < 2: ## return False ## for i in range(2,round(sqrt(n)) + 1): ## if n % i == 0: ## return False ## return True ## ##def is_truncatable_prime(n): ## nr = n ## nl = n ## if len(str(n)) == 1: ## return Fal...
2519c1941b3fb6afaa74ecab73758ce278c0507f
exo7math/cours-exo7
/algo/algos/binaire.py
1,787
3.609375
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- #------------------------------------------ # Ecriture des nombres en base 2 #------------------------------------------ # Module mathématique intégrer sans avoir besoin de math.cos from math import * # Chiffres en base 2 vers nombre def binaire_vers_entier(tab): N = 0...
0c4bcebde2c1be232b6f2405899ccae3c4459a9b
exo7math/cours-exo7
/crypto/algos/statistiques.py
988
3.703125
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- #------------------------------------------ # Statistiques #------------------------------------------ def statistiques(phrase): liste_stat = [0 for x in range(26)] # Une liste avec des 0 for lettre in phrase: # On parcourt la phrase i =...
1bcd69e07a65644a328095bf4b038369fba3915f
exo7math/cours-exo7
/algo/algos/hello-world.py
373
4
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- #------------------------------------------ # Hello world! #------------------------------------------ a=3 b=6 somme = a+b produit = a*b print(somme) # Les résultats print("La somme est", somme) print("Le produit est", produit) # Majuscule/minuscule : c'est pas pareil ! # ...
ad99fdfe4e8a22309234d285821c2ce840c4992c
exo7math/cours-exo7
/algo/algos/pi-hasard.py
657
3.625
4
#!/usr/bin/python3 # -*- coding: utf-8 -*- #------------------------------------------ # Calcul de Pi au hasard #------------------------------------------ # Module qui génère des nombres aléatoires import random Tir = 0 # Numéro du tir NbTirDansLeDisque = 0 # Nombre de tirs dans le disque while...
5bd5d7eaeb8b532c75618fc5fc8f5a52ca45d594
RaghurajSawant/MachineLearning
/Statistics/Measures_Of_Central_Tendency/Mode/median.py
597
3.578125
4
#Import pandas library import pandas as pd # Import the dataset data = pd.read_csv("https://raw.githubusercontent.com/RaghurajSawant/MachineLearning/master/Statistics/Measures_Of_Central_Tendency/Mode/mode.csv") data.head(5) # Use the mean function on the 'Overall Marks' column of the dataset data["Overall Marks"].me...
e199912798d5d409940623d0c4146ff84df1d5f4
caideyang/PythonLearn
/学习1/0327.py
341
3.921875
4
#encoding:utf-8 point = int(input("Pls. insert your point: ")) if point >= 60: if point >= 70: if point >= 80: if point >= 90: print("Class A") else: print("Class B") else: print("Class C") else: print("Class D") else:...
b0499b41d9cb8b5f447de10c8ee4be1c70cac38e
caideyang/PythonLearn
/学习1/0403_1.py
326
3.71875
4
#coding:utf-8 def triangles(): L = [1] yield L L = [1,1] yield L L = [1,2,1] while True: L = [L[i]+L[i+1] for i in range(len(L))] L.insert(0,1) L.append(1) yield L if __name__ == "__main__": n = 5 while n > 0: print(next(triangles())) n ...
5facf33e767f435529f4e931db4b8a71cf59a8b2
JanMalinowski/Neurabble
/src/utils.py
1,871
3.6875
4
from typing import List import pandas as pd import cv2 def two_list(lst1: List[str], lst2: List[str]) -> str: """ Function that return a common element of two lists :param lst1: first list of strings :param lst2: second list of strings """ for elem in lst1: if elem in lst2: ...
19775cf2bac36b9dc799ba7a85967083800a33da
DevShel/personal-projects-python
/algorithm_practice/sort_numbers.py
724
3.890625
4
import sys import math import string # Practice Scenario: Given an array with n distinct elements, convert the given array to a form where all elements are in range from 0 to n-1. The order of elements is same, i.e., 0 is placed in place of smallest element, 1 is placed for second smallest element, … n-1 is placed for ...
21fa4ced0276f91d8e271d56bd33039c6f8fbcd3
Balajikalva/my_first
/one_python.py
301
3.703125
4
import random n = random.randint(0,10000) while True: a = random.randint(2,10) if a < 11: break def converter(n,a): s = str() while n>0: s = str(n%a)+s n = n//a return s #print("{} digit representation of {} is {}".format(a,n,converter(n,a)))
7b612a82d8c48fa9ef62af1792672761bf8200d2
swallowsyulika/BookSearcher
/test_search.py
741
3.546875
4
from Finder_Books import Books from Finder_Eslite import Eslite from Finder_Kingstone import Kingstone from Finder_Library import Library want = input("What book are you look for : ") B = Books() E = Eslite() K = Kingstone() L = Library() results = B.search(want) for result in results: for ele in result: ...
96dd0f57e8e3eb2773e88c8e205a9978d2346e36
burpcat/codedump
/dump1/20.py
251
3.734375
4
# Practise > Python > Itertools > itertools.permutations() # from itertools import permutations inp_string = input() wordLis, numa = inp_string.split() print(*[''.join(item) for item in list(permutations(sorted(wordLis), int(numa)))], sep='\n')
c9747336bcecbcd5f6ef3bc5da1fc62f3220baa7
burpcat/codedump
/dump1/23.py
429
3.890625
4
# Practise > Python > Sets > Introduction to Sets # https://www.hackerrank.com/challenges/py-introduction-to-sets/problem def average(array): # your code goes here sumnum = 0 mainSet = set(array) for i in mainSet: sumnum = sumnum + i return (sumnum/len(mainSet)) if __name__ == '__main__'...
02e8baeed82432b69c154a2b2a32a206d0cd2fbc
burpcat/codedump
/8.4as.py
756
4.5625
5
8.4 Open the file romeo.txt and read it line by line. For each line, split the line into a list of words using the split() method. The program should build a list of words. For each word on each line check to see if the word is already in the list and if not append it to the list. When the program completes, sort and p...
e9405a4516899d1255d7b183801cda6f34a2575f
BOGICAR/Lesson-5
/task_number_2.py
335
3.703125
4
# Задание №2 - сделано u_input = input('Enter some text: ') def amount_words(user_input): user_input = len(user_input.split()) return user_input def amount_elements(user_input): return len(user_input) print('Amount of words, elements: ', amount_words(u_input), amount_elements(u_input))
568661cdc0fa288a2f984babdade60691ba623a8
Amanda1223/Finch
/tapExample.py
878
3.921875
4
# A simple program that randomly changes the LED when the Finch is tapped or shaken # Try it by setting the Finch on a table and tapping the top from finch import Finch from random import randint # Instantiate the Finch object and connect to Finch tweety = Finch() left, right = tweety.obstacle() # Do the following w...
14c260cce0d89d37e4788e786c50e723cb743616
Amanda1223/Finch
/musicexample.py
1,672
4.125
4
""" Plays a list of songs. Input a number to choose. 1. Michigan fight song 2. Intro to Sweet Child of Mine 3. Mario Theme Song Uses notes.py, an add-on library that simplifies buzzer song creation. Thanks to Justas Sadvecius for the library! The Finch is a robot for computer science education. Its design is the resu...
77d95e6a8f736817cb9b39b9d26c99d4365d890a
raghav198/FlowchartParser
/display.py
645
3.703125
4
from node import * from sys import argv import pickle if len(argv) < 2: print("Usage: python3 %s [flowchart file]" % argv[0]) raise SystemExit() def walkthrough(node): print(node.text) if type(node) is StopNode: return if type(node) is ConditionalNode: path = input("(Y/N) ") ...
7cf949e24c5d31cb64fe01cb20fb0ba6d748cf66
kulvirvirk/python_calculator
/main.py
468
4.59375
5
# Instructions # 1. Write a docstring that describes what is going to happen. # 2. Set x, y, and z as equal to 2, 3, and 4. # 3. Determine the Pythagorean distance between x, y, and z. c = √(x^2 + y^2 + z^2) # 4. Include comments to clarify each line of code. import math # 1. """This program will determine the Pyth...
f6aaa453075727c769f4ce603c28b583af5b0b75
sandeepkc/jobprep
/python/Variables.py
264
3.703125
4
# Numbers a = 10 b = 20 print (a+b) c = 20.5 print (c + 10) print (c/1.7) name = "sandeep" place = "Sunnyvale" print (name + place) print (name[2:5]) print (name[1:]) print (name + "kumar") print (name*2) name = name + 'a' print (name)
f6d52577d68ce853ffbff3d23a6e0b886eedfd20
JoeDBNS/programming-practice
/python/7 - classes/classes.py
1,028
3.84375
4
class Dog: def __init__(self, name): self.name = name self.tricks = [] def add_trick(self, trick): self.tricks.append(trick) dog_1 = Dog('Fido') dog_2 = Dog('Buddy') dog_1.add_trick('roll over') dog_2.add_trick('play dead') dog_1.tricks print(dog_1.tricks) # ['roll over'] dog_2.tr...
6c28f52498d3adf88544131032307b68b610346b
JoeDBNS/programming-practice
/python/1 - strings/strings.py
957
4.0625
4
sentence = 'This is a TEST sentence. ' sentence[5] sentence[5:10] len(sentence) strip_sentence = sentence.strip() lower_sentence = sentence.lower() upper_sentence = sentence.upper() cool_sentence = sentence.replace('TEST', 'cool') double_sentence = sentence + sentence spaced_double_sentence = sentence...
20d0668be4b6c9974c62474e7188d39fd6d1c681
JoeDBNS/programming-practice
/Tutoring/Tyler/McMenu.py
1,560
4.0625
4
operator = "" num_one_text = "" num_two_text = "" num_one_int = 0 num_two_int = 0 num_list = [] operator_list = [] master_number = 0 continue_numbers = "" num_one_text = input("Enter starting number:\n") num_one_check_pass = False while num_one_check_pass != True: try: num_one_int = float(num_one_text) ...
0100b25f800d9f312ff4e9a80437ba0c3d4a98e6
RazvanPasca/Tensorflow
/TFBasics/estimator api.py
3,957
3.78125
4
import tensorflow as tf import numpy as np import pandas as pd import matplotlib.pyplot as plt from sklearn.model_selection import train_test_split """tf.estimator.LinearClassifier -> Constructs a neural network class model""" """tf.etimateor.DNNClassifier -> a neural network classification layer""" """1.Define a lis...
81755317f1885cf03048e6daebc90ca42ab5d4cf
sip11/python
/Function.py
1,660
4.1875
4
''' from sys import argv filename, f_name, x, y = argv def add(x,y): print (f" {x} add {y}, the answer is", (int(x) + int(y))) def multiply (x,y): return int(x)*int(y) if f_name == "add" or f_name is "a": add(x,y) if f_name == "multiply" or f_name is "m": print (f"{x} multiply {y}, the answer is", mu...
011413c1eb47462b5225602eea8c1198b8fa5e68
sanjipun/Data-Science
/tutorial/7. Deep Learning/Activation Function/Softmax.py
1,492
3.9375
4
import numpy as cp class Softmax(): ''' The softmax function is a generalization of the logistic function to multiple dimensions. It is used in multinomial logistic regression and is often used as the last activation function of a neural network to normalize the output of a network to a probabilit...
b0c1902184bb4a8d6b990b8aa5f9fa4c30a3ee0c
code-in-the-schools/NestedForLoops_CigashamwaByamungu
/main.py
434
4.25
4
#I dont know where to Start #Outer Loop for i in range (0,6): print("Outer Loop | i = " + str(i) ) #Inner Loop for j in range (0, 6): #They must both be even if (i%2) == 0 and (j%2) == 0: print("Both even") #They must both be odd if (i%3) == 0 and (j%3) == 0: print("Both odd")...
2b0937c681830ff76206b26de1447de870b225ef
ghjan/python-cookbook
/src/1/filtering_list_elements/example.py
1,800
4.09375
4
# Examples of different ways to filter data ''' 使用列表推导的一个潜在缺陷就是如果输入非常大的时候会产生一个非常大的结果集,占用大量内存。 如果你对内存比较敏感, 那么你可以使用生成器表达式迭代产生过滤的元素 ''' ''' 值得关注的过滤工具就是 itertools.compress() , 它以一个 iterable 对象和一个相对应的 Boolean 选择器序列作为输入参数。 然后输出 iterable 对象中对应选择器为 True 的元素。 和 filter() 函数类似, compress() 也是返回的一个迭代器。因此,如果你需要得到一个列表, 那么你需要使用 list(...
ff2909be477fb71541692e5f9603c7f53dd030ed
ghjan/python-cookbook
/src/8/extending_a_property_in_a_subclass/super_example.py
377
3.828125
4
class Animal(object): def __init__(self, name): self.name = name def greet(self): print('Hello, I am %s.' % self.name) class Dog(Animal): def greet(self): # super(Dog, self).greet() # Python3 可使用 super().greet() super().greet() print('WangWang...') if __name__ =...
1b8dc82dfe38c5acbdac6b6954c2ed58b582e83e
ghjan/python-cookbook
/src/8/creating_a_new_kind_of_class_or_instance_attribute/example1.py
1,894
3.71875
4
# -*- coding: utf-8 -*- # Descriptor attribute for an integer type-checked attribute # python描述符是一个“绑定行为”的对象属性,在描述符协议中,它可以通过方法重写属性的访问。 # 这些方法有 __get__(), __set__(), 和__delete__()。如果这些方法中的任何一个被定义在一个对象中,这个对象就是一个描述符。 # 描述器可实现大部分Python 类特性中的底层魔法, 包括@classmethod 、 # @staticmethod 、@property ,甚至是slots 特性。 # 通过定义一个描述器,你可以在底层...
8b2eb41a07792a49b045a0406ee9b6cb090bbfe5
arunadevi11/RAILWAY_RESERVATION-
/RAILWAY2.py
3,731
3.59375
4
from tkinter import * import sqlite3 main_screen = Tk() main_screen.geometry("300x250") main_screen.title("Movie Recommentation System") # Set text variables Passenger= StringVar() Survived = StringVar() Pclass=StringVar() Name=StringVar() Sex= StringVar() Age = StringVar() SibSP=StringVar() P...
4288f51acd395df5b65e97ce28f4961d37b0054c
ErichMorais/InteligenciaComputacional
/3 - Trabalho Algoritmos geneticos/src/Interface.py
4,045
3.65625
4
import turtle import time from Constants import WALL from Population import * matrix = [ "WWWWWWIW", "W W", "W W WW", "W WWW W", "W W", "W WWW W", "W W", "WFWWWWWW" ] class Wall(turtle.Turtle): def __init__(self): turtle.Turtle.__init__(self) se...
708932c133fceef7be6d820e814368a6560ca2d9
pramathesh18/school-projects
/prime_no.py
262
4
4
""" Write a program to enter a number and check if it is prime or not """ p = int(input('enter the no._')) t=0 for i in range(2,p): if p%i == 0: print("the entered no. is not a prime no.") t+=1 break if t == 0: print('entered no is a prime number')
50afdfdd05a28a4aaec3d24305eb18380b2d2acc
PChalmers/LeetCode
/addTwoNum.py
1,431
3.765625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def addTwoNumbers(self, l1, l2): # Get number from L1 l1List = self.getNum(l1, []) # Get number from L2 l2List = self.getNum(l2, [...
4f8607946dbf59545e3b39686ef841341c332166
PChalmers/LeetCode
/climbStairs.py
604
3.828125
4
class Solution: def climbStairs(self, n: int) -> int: # n under 3 does not follow the fib series if(n < 0): return 0 if(n <= 2): return n # Initiate array for storing values found. Note, only really need the last 2 # 1 more than n because t...
3173aa8f1cf9977803e11a8f88d566f66a6fadc2
PChalmers/LeetCode
/searchInsertPosition.py
451
3.515625
4
class Solution: def searchInsert(self, nums, target: int) -> int: for index in range(len(nums)): if(nums[index] >= target): return index return len(nums) s = Solution() print(s.searchInsert([], 5)) print(s.searchInsert([1,3,5,6], 5)) print(s.searchI...
65004d0a5310ebae033ed0fd4c1cac3b193e3605
PChalmers/LeetCode
/sqrtX.py
574
3.5
4
class Solution: def mySqrt(self, x: int) -> int: if(x <= 0): return 0 if(x == 1): return 1 left, right = 0, x while(left < right): mid = (left + right) // 2 if(mid*mid <= x < (mid+1) * (mid+1)): return mid ...
9a38ef46c16d3dd14f438acb7295e7f8c3b5f569
PChalmers/LeetCode
/reverseNodesKGroup.py
1,963
3.890625
4
# Definition for singly-linked list. class ListNode: def __init__(self, x): self.val = x self.next = None class Solution: def reverseKGroup(self, head: ListNode, k: int) -> ListNode: self.printList(head) # represents the previous list before the new reversed s...
1b86bc69067f66190e542ca972d5844149d93727
anonyxhappie/learnpy
/basicspy/hacker/repeated_string.py
990
3.8125
4
#!/bin/python3 import math import os import random import re import sys # Complete the repeatedString function below. def repeatedString(s, n): # infi_string = "" s_len = len(s) a_count = 0 r_count = 0 result = 0 if s_len == 1 and s[0] == 'a': return n d = n // s_len r = n % ...
a3f51f9ba4301cb7c56726810a63833974847e29
madeofstardust/Python-Machine-Learning-Cookbok
/Chapter 2/NaiveBayes.py
3,855
3.84375
4
# Naive Bayes '''The underlying principle of a Bayesian classifier is that some individuals belong to a class of interest with a given probability based on some observations. This probability is based on the assumption that the characteristics observed can be either dependent or independent from one another; in this se...
999581e931f8b8cbd6372e335508fbe7d3f88a5b
praveen-lokhande/python
/Exercise 2.py
490
4.125
4
var1=int(input("Enter first number\n")) var2=int(input("Enter second number\n")) operation=input("Enter a operator\n") if (var1==56 and var2==9 and operation=="+"): print("77") elif (var1 == 45 and var2 == 3 and operation=="*"): print("555") elif (var1 == 56 and var2 == 6 and operation=="/"): print("4") eli...
73a67ce2ae2ecc24db74144fa8c729197cb30dc1
praveen-lokhande/python
/time123.py
335
3.890625
4
import time initial=time.time() k=0 while(k<10): print("this is praveen") time.sleep(2) k+=1 # print(f"while loop ran in {time.time()}-{initial} seconds") # # initial2=time.time() # for i in range(10): # print("this is praveen") # print(f"for loop ran in {time.time()}-{initial2} print(time.asctime(time...
5ff8fed7690bd231680c7b2014ef204f856e14f0
praveen-lokhande/python
/operatorss.py
858
4.5625
5
#Operator in python #Arithmetic operators #Assignment operators #Comparision operators #Logical operators #Identity operators #Membership operators #Bitwise operators #Arithmetic operators print("6+6 is",6+6) print("6-6 is",6-6) print("6*6 is",6*6) print("6/6 is",6/6) print("6//6 is",6//6) print("6**2 is",6**2) print(...
b41557938374774a297a87c093bcbc78a71f525c
julweng/intro-python-for-informatics
/msg_freq.py
1,310
4.0625
4
# -*- coding: utf-8 -*- # Assignment 5: Message Frequency Count # Julia Tzu-Ya Weng U07487022 # This program reads through the mail box data and extract email addresses from # lines that start with "From". Then, the person with the highest number of # messages is printed # open file filename = raw_input("Enter the f...
900f08093dd3817a268a612421b47ed5c041f4f0
JustMax7CB/Interviews_Riddles
/100 Doors/Python/100 Doors.py
553
3.515625
4
OPEN = "OPEN" CLOSE = "CLOSED" Doors = [[x+1, CLOSE] for x in range(100)] def main(): def changeDoor(door): if door[1] == CLOSE: door[1] = OPEN elif door[1] == OPEN: door[1] = CLOSE jump_index = 0 while jump_index <= len(Doors): for i in range(jump_index,len...
153d8895664872bf27190bf6dcf184f3921ed4b4
dorayo/python_practice
/05-print_triangles.py
211
3.703125
4
#!/usr/bin/env python3 def triangles(): L = [1] while True: yield L L = [1] + [L[x]+L[x+1] for x in range(0, len(L)-1)] + [1] g = triangles() for i in range(0, 10): print(next(g))
bf1e32d38d5fdff7c40dee1f49690e400b6518f2
roerohan/Miscellaneous
/Python/crypto/xor.py
167
3.625
4
def xor(a,b): return bytes([a[i]^b[i] for i in range(len(a))]) if __name__=="__main__": print(xor(input("Enter a: ").encode(),input("\nEnter b: ").encode()))
5264ff3e72277bd684e41a614ad5d153994a461a
nhannt201/100AlgorithmsChallenge_Python
/19.arrayPreviousLess.py
346
3.625
4
#Code by Nhan Nguyen #Available on github.com/nhannt201 def arrayPreviousLess(arr): new_arr = [-1] for x in range(0, len(arr)-1): if arr[x] < arr[x+1]: new_arr.append(arr[x]) else: new_arr.append(-1) return new_arr inputArray = [3, 5, 2, 4, 5] print(...
5e9a9a82d63ed2cc43b7824fee88361f6c68cdca
dlamaral/Python-Practice
/pi_to_nth.py
302
4.46875
4
''' Diogo Amaral 2020 Program that Finds pi tho the nth digit - input by user ''' import math def Find_Pi(n_digit): ''' Finds Pi to the nth ''' pi = round(math.pi, n_digit) print(pi) Find_Pi(int(input("Please enter the number of digits (between 1 and 50) for pi you'd like to see: ")))
70cfbc67561dde27b806e6f828e1bd63d6bcd3e0
rprustagi/2019-17CS52-CN
/Progs/UDPClient.py
946
3.515625
4
#!/usr/bin/python #UDP client program import sys import argparse from socket import * recvSize = 2048 parser = argparse.ArgumentParser() parser.add_argument("--server", help="Server IP address", type = str, dest = "servername", required=True) parser.add_argument("--port", help = "Server port number", type = int,...
4c701a8a2592fb83730cbfa68a8b1dc2f0727bd2
rnmallick/sorting
/insertion_sort.py
817
3.84375
4
a = [] import random generate = input('Do you want to choose your numbers, or should the computer generate some? Type computer or player.') if generate == 'computer': start = int(input('First boundary:')) end = int(input('Second bondary:')) number = int(input('Number of numbers:')) for q in range(number...
ba70893998e23c2a8e002ded0bbbdc0963ae05c4
natnew/Exploring-Rocks-In-Space-Python
/spaceRocks.py
2,470
4.15625
4
print("Artemis Rover Rock Scanner Starting") '''We are looking for the following rocks: Basalt: The Mare Rocks: Breccia: Shocked Rock, Highland Rock: Anorthosite, Regolith Soil/Surface Layer. These are the four main types of rocks found on the moon''' basalt = 0 breccia = 0 highland = 0 regolith = 0 rock...
fa900240ab9df3b5bbdb3df91a0a202fc01774af
HerXtheSlayer/LearningPython
/lpthw/ex13.py
396
3.53125
4
from sys import argv script, first, second, third = argv fourth = raw_input("Enter fourth word: ") print "The script is called:", script print "Your first variable is:", first print "Your second variable is:", second print "Your third variable is:", third print "Your fourth variable is:", fourth # ans = raw_input("...
1a54b83d6737b40ea9b47b39d8cc600f9b8e3ef4
TanvirKaur17/Array-1
/WrongDiagonalTraverse.py
1,131
3.515625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Dec 2 15:23:28 2019 @author: tanvirkaur """ # Please check what i am doing wrong in this code # in line no. 14 giving list index out of range class Solution: def findDiagonalOrder(self, matrix: List[List[int]]) -> List[int]: if not matrix:...
4127bfb5a4a7f031899c430c05ea49265caea1a0
AyushSri19-777/Coding-2020
/Data Structures/String/Arya.py
1,167
3.890625
4
"""Arya has a string, S, of uppercase English letters. She writes down the string S on a paper K times. She wants to calculate the occurence of a specific letter in the first N characters of the final string. Input: First line of input contains a single integer T denoting the number of test cases. The first line of e...
aae93e255d424e1c8d070cacc95d733017bf92c2
ravi4all/AdvPython_AprilWE
/01-Codes/class_1.py
541
3.6875
4
class Emp(): """This is emp class""" e_id = None e_name = None e_sal = None e_dept = None def show(self): print(self.e_id,self.e_name,self.e_sal,self.e_dept) obj_1 = Emp() obj_1.e_id = 101 obj_1.e_name = 'Ram' obj_1.e_sal = 35000 obj_1.e_dept = 'IT' obj_1.show() obj_2...
44c780a7049b6851b0de0629d64c431bb422afbf
pchat99/Hacktoberfest2021-5
/Python/Lifespan of housefly.py
114
3.8125
4
age=int(input("Enter Age:")) if age<0: print("invalid input") else: answer=age*24*60*60 print(answer)
f3627e9a6cf9b741b89fdcf0e0a1da568c2f2e4c
odinfor/leetcode
/剑指Offer/009乘积小于k的子数组.py
966
4
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/1/26 10:43 上午 # @Site : # @File : 009乘积小于k的子数组.py # @desc : 给定一个正整数数组 nums和整数 k ,请找出该数组内乘积小于 k 的连续的子数组的个数。 class Solution: @staticmethod def res_of_list(nums: list) -> int: res = 1 for i in nums: res = res * i...
668a71953c52b03ff7c37736bf191c57eb9f2f59
odinfor/leetcode
/pythonCode/No51-100/no78.py
566
3.90625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/16 2:45 下午 # @Site : # @File : no78.py # @desc : class Solution: def subsets(self, nums: list) -> list: sub_set = list() if len(nums) == 1: sub_set.append(nums) for i in range(len(nums)): for ...
026ecab358ef68ec2360182b7aa68dc105206191
odinfor/leetcode
/剑指Offer/006排序数组中两数之和.py
728
3.6875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/1/25 5:53 下午 # @Site : # @File : 006排序数组中两数之和.py # @desc : 给定一个已按照 升序排列 的整数数组 numbers ,请你从数组中找出两个数满足相加之和等于目标数 target 。 class Solution: def twoSum(self, numbers: list, target: int) -> list: """双指针""" left, right = 0, len(numb...
ac329c8da2fdb745d58f289ff9b690b330ea2d75
odinfor/leetcode
/codeTop/array/349两个数组的交集.py
817
3.921875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/7/7 5:33 下午 # @Site : # @File : 349两个数组的交集.py # @desc : 给定两个数组,编写一个函数来计算它们的交集。 class Solution: def intersection(self, nums1: list, nums2: list) -> list: set_nums = set(nums2) if len(nums1) >= len(nums2) else set(nums1) len_nu...
861a639ca569b2ac0c50ae2c9ed699d89ac8592c
odinfor/leetcode
/pythonCode/No1-50/no28.py
952
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/1/20 4:05 下午 # @Site : # @File : no28.py # @desc : class Solution: def strStr(self, haystack: str, needle: str) -> int: # O(n)时间复杂度, if haystack == needle: return 0 if not needle and haystack: ...
825baabf9e362e6b97eef91dede80aca25f6893d
odinfor/leetcode
/剑指Offer/002二进制加法.py
1,118
3.53125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/1/25 4:05 下午 # @Site : # @File : 002二进制加法.py # @desc : 给定两个 01 字符串 a 和 b ,请计算它们的和,并以二进制字符串的形式输出。输入为 非空 字符串且只包含数字 1 和 0 class Solution: def addBinary(self, a: str, b: str) -> str: index_a, index_b, add_value, res = len(a) - 1, len(b) ...
8456ead2789a73663b455d53a380a37f4533e713
odinfor/leetcode
/pythonCode/No401-450/no520.py
1,112
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/10 6:30 下午 # @Site : # @File : no520.py # @desc : class Solution: def detectCapitalUse(self, word: str) -> bool: FirstBig, type_num = False, dict() for i in range(len(word)): if i == 0 and "A" <= word[i] <= "Z": ...
e3607668160356f4b05a7e75ed727657bbbb9897
odinfor/leetcode
/pythonCode/array/easy/61.旋转链表.py
1,781
3.71875
4
# # @lc app=leetcode.cn id=61 lang=python3 # # [61] 旋转链表 # # @lc code=start # Definition for singly-linked list. # class ListNode: # def __init__(self, val=0, next=None): # self.val = val # self.next = next class Solution: # def rotateRight(self, head: Optional[ListNode], k: int) -> Optional[Li...
04b4fb6f39c0a331e9b103d3db312aef6ce387da
odinfor/leetcode
/pythonCode/No151-200/no200岛屿数量.py
1,392
3.5625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2"0"22/3/9 11:34 上午 # @Site : # @File : no2"0""0"岛屿数量.py # @desc : class Solution: def numIslands(self, grid: list) -> int: if not grid: return 0 count = 0 row, column = len(grid), len(grid[0]) for y in...
4d3d11abbdf046fa1239e96d5884038e13268955
odinfor/leetcode
/pythonCode/No401-450/no819.py
1,001
3.65625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/11 4:26 下午 # @Site : # @File : no819.py # @desc : class Solution: def mostCommonWord(self, paragraph: str, banned: list) -> str: paragraph_dict, paragraph_list, s = dict(), list(), str() paragraph = paragraph.replace(" ", ";...
8756a3b47e278c43723d016f971fa439a8fe30b6
odinfor/leetcode
/codeTop/array/122买卖股票2.py
893
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/7/5 2:48 下午 # @Site : # @File : 122买卖股票2.py # @desc : 给定一个数组 prices ,其中 prices[i] 是一支给定股票第 i 天的价格。 # 设计一个算法来计算你所能获取的最大利润。你可以尽可能地完成更多的交易(多次买卖一支股票)。 # 注意:你不能同时参与多笔交易(你必须在再次购买前出售掉之前的股票)。 class Solution: def maxProfit(self...
146eacc6704ae6a0850c27b2a6c661298d20791b
odinfor/leetcode
/pythonCode/no707.py
3,713
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/7/1 10:30 上午 # @Site : # @File : no707.py # @desc : 实现一个链表,包含在链表类中实现这些功能: # get(index):获取链表中第index个节点的值。如果索引无效,则返回-1。 # addAtHead(val):在链表的第一个元素之前添加一个值为val的节点。插入后,新节点将成为链表的第一个节点。 # addAtTail(val):将值为val 的节点追加到链表的最后一个元素。 # addAtIndex(index,val):在链...
7e434731a8e90206359d19d0c84884151a364b53
odinfor/leetcode
/pythonCode/No201-250/no237删除链表中的节点.py
991
3.8125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/2/15 3:56 下午 # @Site : # @File : no237删除链表中的节点.py # @desc : 请编写一个函数,用于 删除单链表中某个特定节点 。在设计函数时需要注意,你无法访问链表的头节点head ,只能直接访问 要被删除的节点 。 # 题目数据保证需要删除的节点 不是末尾节点 class ListNode: def __init__(self, val=0, next=None): self.val = val ...
6dba1e6620676dd6d62b1b283a1d3c530583f75c
odinfor/leetcode
/pythonCode/no1290.py
579
3.71875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/7/1 4:59 下午 # @Site : # @File : no1290.py # @desc : # Definition for singly-linked list. class ListNode: def __init__(self, val=0, next=None): self.val = val self.next = next class Solution: def getDecimalValue(self, he...
40ea68e3f6ab556a364ec2c621e79b6f9b1e4c47
odinfor/leetcode
/pythonCode/No51-100/no97交错字符串.py
1,193
3.703125
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/2/10 5:14 下午 # @Site : # @File : no97交错字符串.py # @desc : class Solution: def isInterleave(self, s1: str, s2: str, s3: str) -> bool: if not s1 and not s2 and not s3: return True elif not s1 and s2 == s3: ...
38f6ac8836351cad29962e7a3488057a25f74b05
odinfor/leetcode
/pythonCode/No401-450/no724.py
553
3.765625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/10 11:22 上午 # @Site : # @File : no724.py # @desc : class Solution: def pivotIndex(self, nums: list) -> int: all_sum, curr_sum = sum(nums), int() for i in range(len(nums)): if i > 0: curr_sum += nu...
3554badc3d5ebe5db546cf38d30899185c524e6d
odinfor/leetcode
/pythonCode/No51-100/no98验证二叉搜索树.py
845
3.734375
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2022/2/17 2:14 下午 # @Site : # @File : no98验证二叉搜索树.py # @desc : class TreeNode: def __init__(self, val=0, left=None, right=None): self.val = val self.left = left self.right = right class Solution: def isValidBST(self,...
91ffe8b101d0633acb580723fae2365edb56e0a9
odinfor/leetcode
/pythonCode/No401-450/no557.py
997
3.671875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # @Time : 2021/6/11 2:34 下午 # @Site : # @File : no557.py # @desc : class Solution: def reverseWords(self, s: str) -> str: found_first, left_index = False, int() b = str() for i in range(len(s)): if s[i] == " " and not fo...
83d20d4638e00423b1f0dae169a50b4062fe12a1
vincepay/Project_Euler
/python/21-30/Prob28.py
666
3.984375
4
##Starting with the number 1 and moving to the right in a clockwise direction a 5 by 5 spiral is formed as follows: ## ##21 22 23 24 25 ##20 7 8 9 10 ##19 6 1 2 11 ##18 5 4 3 12 ##17 16 15 14 13 ## ##It can be verified that the sum of the numbers on the diagonals is 101. ## ##What is the sum of the numbers on ...
c4e9bc1c1c7c87c8ef9274944d62df98f5afdc31
vincepay/Project_Euler
/python/11-20/Prob17.py
2,291
3.90625
4
#If the numbers 1 to 5 are written out in words: one, two, three, four, five, #then there are 3 + 3 + 5 + 4 + 4 = 19 letters used in total. #If all the numbers from 1 to 1000 (one thousand) inclusive were #written out in words, how many letters would be used? #NOTE: Do not count spaces or hyphens. For example, #34...
3099528fcdb883bb2ac57fcea19081f351798857
vincepay/Project_Euler
/python/11-20/Prob19.py
1,884
3.984375
4
#You are given the following information, but you may prefer to do some research for yourself. # 1 Jan 1900 was a Monday. # Thirty days has September, # April, June and November. # All the rest have thirty-one, # Saving February alone, # Which has twenty-eight, rain or shine. # And on leap years, ...