blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
5b269c95f2eeed5db00155b1a25feed94cd56bfe
TomiwaJoseph/Python-Scripts
/emirp_numbers.py
745
4.34375
4
''' An emirp is a prime that results in a different prime when its decimal digits are reversed. Example: Input: 13 Output: True (13 and 31 are prime numbers) Input: 23 Output: False (23 is prime but 32 is not) Input: 113 Output: True (113 and 311 are prime numbers) ''' print() def know_prime(number): return n...
true
cfab197d408c4a376f486922b7f7c6bbd0377304
TomiwaJoseph/Python-Scripts
/neon_numbers.py
532
4.1875
4
''' A number is considered Neon if the sum of digits of the square of the number is equal to the number itself. Example: Input: 9 9 * 9 == 81 8 + 1 == 9 Output: True ''' print() def neon(number): squared = number ** 2 sum_of_digits = sum([int(i) for i in str(squared)]) return sum_of_digits == number ...
true
bebc9c33456253aac57a78dd4dbf58b3854b75c3
TomiwaJoseph/Python-Scripts
/twin_prime_numbers.py
795
4.15625
4
''' A Twin prime is a prime number that is either 2 less or 2 more than another prime number. For example: (41,43) or (149,151) Example: Input: 0,15 Output: (3,5),(5,7),(11,13) ''' print() def check_prime(number): return number > 1 and not any(number % n ==0 for n in range(2, number)) def twin_prime(number): ...
true
0c2ecd13b13a498ff90c14f10cd2d710c07c56da
TomiwaJoseph/Python-Scripts
/anti-lychrel_numbers.py
1,245
4.125
4
''' An anti-Lychrel number is a number that forms a palindrome through the iterative process of repeatedly reversing its digits and adding the resulting numbers. For example 56 becomes palindromic after one iteration: 56+65=121. If the number doesn't become palindromic after 30 iteratioins, then it is not an anti-Lychr...
true
a091e96b64e922d1c06701fa93a5bafe24258fd3
jchaclan/python
/cat.py
580
4.25
4
# Given the below class: class Cat: species = 'mammal' def __init__(self, name, age): self.name = name self.age = age # 1 Instantiate the Cat object with 3 cats cat1 = Cat('Freddy', 10) cat2 = Cat('Manny', 8) cat3 = Cat('Lucy', 9) # 2 Create a function that finds the oldest c...
true
cd89199bc64100a5527d6a7729b6c52fca85afa8
dinakrasnova/lesson
/lesson2.py
2,236
4.21875
4
''' Задача 1 Вывести на экран циклом пять строк из нулей, причем каждая строка должна быть пронумерована. ''' for i in range(1,6): print(i, 0) ''' Задача 2 Пользователь в цикле вводит 10 цифр. Найти количество введеных пользователем цифр 5. ''' sum = 0 for i in range(10): answer = int(input('Введите любую цифру...
false
f825c3e3fd51e813ae357890221d8287edb9f09b
brianbruggeman/lose-7drl
/lose/utils/algorithms/pathing.py
2,765
4.3125
4
# -*- coding: utf-8 -*- import operator import heapq from .distances import log_distance def create_dijkstra_map(graph, start, target=None, cost_func=None, include_diagonals=None): """Creates a dijkstra map Args: graph (list): a set of nodes start (node): the starting position target ...
true
d69954226bd6d65bb7d9fb405a1f21c95a5c55bf
brianbruggeman/lose-7drl
/lose/utils/algorithms/distances.py
2,737
4.5
4
# -*- coding: utf-8 -*- import math from itertools import zip_longest as lzip def manhattan_distance(x, y): """Calculates the distance between x and y using the manhattan formula. This seems slower than euclidean and it is the least accurate Args: x (point): a point in space y (point...
true
4c300e2170cb75b47518e284b545201cfaafd0af
aineko-macx/python
/ch16/16_6.py
2,019
4.28125
4
import copy class Time(object): """Represents a time in hours, minutes, and seconds. """ def print_time(Time): print("%.2d: %.2d: %.2d" %(Time.hour, Time.minute, Time.second)) def add_time(t1, t2): sum = Time() sum.hour = t1.hour + t2.hour sum.minute = t1.minute + t2.minute sum.second = ...
true
f55cd76dfe5ccb409039ae8f53b69d48ffd33677
aineko-macx/python
/ch17/17_1.py
892
4.25
4
class Time(object): """Represents the time of day. """ def __init__(self, hour = 0, minute = 0, second = 0): self.hour = hour self.minute = minute self.second = second def print_time(self): print("%.2d: %.2d %.2d" %(self.hour, self.minute, self.second)) def time_t...
true
cc6c7455f19cc0beb742973aec0dd34371e3ef4c
aineko-macx/python
/ch17/17_5.py
982
4.25
4
class Point(object): """Represents a point in 2-D Cartesian space. """ def __init__(self, x = 0.0, y = 0.0): self.x = x self.y = y def __str__(self): return("(%g , %g)" % (self.x, self.y)) def __add__(self, other): if isinstance(other, Point): return ...
false
82d1990426120000f438a843da0f103baf3ed5df
akfmartins/Curso-de-Python
/desafio015.py
384
4.125
4
''' Escreva um programa que pergunte a quantidade de Km percorridos por um carro alugado e a quantidade de dias pelos quais ele foi alugado. Calcule o preço a pagar, sabendo que o carro custa R$60 por dia e R$0,15 por Km rodado. ''' c = float(input("Informe a temperatura em °C: ")) f = ((9 * c) / 5) + 32 print...
false
6d9f449312a335671fd358bf0482486d59eab245
SoniaB77/Exercise_12_Collections
/exercise12.2.py
267
4.25
4
tup = 'Hello' print(len(tup)) print(type(tup)) # this is a string so the length is checking the iterables of the string which is 5. tup = 'Hello', print(len(tup)) print(type(tup)) # this is a tuple so it is checking the iterables but of a tuple so this outputs 1.
true
11d167121472792a525554e7d54d1bed829a641c
ProgrammingForDiscreteMath/20170823-bodhayan
/code.py
2,748
4.46875
4
""" This is the code file for Assignment from 23rd August 2017. This is due on 30th August 2017. """ ################################################## #Complete the functions as specified by docstrings # 1 def entries_less_than_ten(L): """ Return those elements of L which are less than ten. Args: ...
true
97deeac8f41eec71854d110f529d35053203302b
YongCloud/Python
/housing_loan_calculator.py
1,673
4.4375
4
''' A simple housing loan calculator ''' def average_capital(amount,rate,term): ''' Average Capital amount: loan amount rate: interest rate(per year) term: loan term(years) ''' print('===Average Capital===') mon_principal = amount / (12 * term) mon_rate = rate / 12 sum_i = 0; ...
false
b6c12ae165a10fa29347189009f7e60edba15f91
215shanram/lab4
/lab4-exercise4.py
1,163
4.25
4
import sqlite3 #connect to database file dbconnect = sqlite3.connect("lab4.db"); #If we want to access columns by name we need to set #row_factory to sqlite3.Row class dbconnect.row_factory = sqlite3.Row; #now we create a cursor to work with db cursor = dbconnect.cursor(); #execute insetr statement cursor.execute('''in...
true
76b8b31d7c66daa0600fe3d738803c15899c544c
btab2273/functions
/path_exists.py
946
4.3125
4
# Define path_exists() def path_exists(G, node1, node2): """ Breadth-first seach algorithim This function checks whether a path exists between two nodes( node1, node2) in graph G. """ visited_nodes = set() # Initialize the queue of cells to visit with the first node: queue queue = [node1] # Iterate over the n...
true
09b72fc9f5de9115ebf38fb41cdf7db89821e245
noobkid2411/Random-Programs
/list-sort.py
870
4.1875
4
# sorting using custom key friends= [ {'Name': 'Phoebe', 'age': 35, 'salary': 9000}, {'Name': 'Rachel', 'age': 30, 'salary': 8000}, {'Name': 'Ross', 'age': 25, 'salary': 10000}, {'Name': 'Chandler', 'age': 30, 'salary': 15000}, {'Name': 'Joey', 'age': 29, 'salary': 8000}, {'Name': 'Monica...
false
f3c75aa885aa7fabed4400e78a8c5410fb648f89
jeandy92/Python
/ExerciciosDSA/Exercicios_Capitulo_3/Exercicios - Loops e Condicionais/ex002.py
325
4.15625
4
# Exercício 2 - Crie uma lista de 5 frutas e verifique se a fruta 'Morango' faz parte da lista fruits = ['Pinneaple', 'WaterMellon', 'Strawberry', 'Apple', 'Lemon'] #fruits = ['Pinneaple', 'WaterMellon', 'Apple', 'Lemon'] for fruit in fruits: if (fruit == 'Strawberry'): print('The list contains Strawberry...
false
b644ba60f87f1ff5c4bdfa9311698112fd6f59a1
paul-tqh-nguyen/one_off_code
/old_sample_code/misc/vocab/vocab.py
1,572
4.40625
4
#!/usr/bin/python # Simple program for quizzing GRE vocab import random import os if __name__ == "__main__": os.system("clear") definitions = open('./definitions1.csv', 'r') # load GRE words from .csv file # We want to split the words by part of speech so that when quizzing, the quizzee cannot guess the answe...
true
e0178e180e7f08eff52d9c9e878e23e8ecfe5e5c
FariaTabassum/Python-Basic
/program18(operators).py
978
4.6875
5
''' Operators in python 1.Arithmetic operators 2.Assignment operators 3.Comparison operators 4.logical operators 5.Identity operators 6.Membership operators 7.Bitwise operators ''' #Arithmetic operators print("Arithmetic operator:\n") print("5+6 is ",5+6) print("5-6 is ",5-6) print("5/6 is ",5/6) print("5**6 is ",5**6)...
false
654e9a81c02402214df6d7f0e3f2ba226375d205
sanika2106/if-else
/next date print.py
826
4.34375
4
# Write a Python program to get next day of a given date. # Expected Output: # Input a year: 2016 # Input a month [1-12]: 08 # Input a day [1-31]: 23 # The next date is...
true
c516eed37f3a04549028b078464756a786711002
sanika2106/if-else
/16link.py
429
4.1875
4
# c program to check weather the triangle is equilateral ,isosceles or scalene triangle side1=int(input("enter the number:")) side2=int(input("enter the number:")) side3=int(input("enter the number:")) if(side1==side2 and side2==side3 and side1==side3): print("it's a equilateral triangle") elif(side1==side2 or sid...
true
4dd716f7a3114ec557a8da4758acff8f4dd1d074
sanika2106/if-else
/2nd.py
604
4.21875
4
#leap year # year=int(input("enter the number:")) # if year%4==0: # print("its leap year") # year2=int(input("enter the number")) # if year2%400==0: # print("its also a leap year") # else: # print("its not leap year") # else: # print("its also not a leap year") year=int(input("ent...
false
b60fe06fd61994d24e2c6292c0266f2179d1ced9
sanika2106/if-else
/q13.py
658
4.15625
4
age=int(input("enter the number")) if age>=5 and age<=18: print("can go to school") elif age>=18 and age<=21: print("""1.can go to school, 2.can vote in election""") elif age>=21 and age<=24: print("""1.can go to school, 2.can vote in election, 3.can drive a car""") elif age >=24 ...
true
4c7c531576a1c5fd956a08ec5dfc454509604ec0
sanika2106/if-else
/prime number.py
306
4.21875
4
#prime number num=int(input("enter the number:")) if num==1 or num==0: print("not a prime number") elif num%2!=0 and num%3!=0 and num%5!=0 and num%7!=0: print("prime number") elif num==2 or num==3 or num==5 or num==7 : print("it is also a prime number") else: print("not a prime number")
true
44f57eb1192b6e2059ab3ffafc1e35f7ce39ef44
saurabh00031/PYTHON-TUTS-
/tut54.Instance&ClassVariables.py
2,842
4.3125
4
#.............................................................................................. #self-practicing:- #intance and class variables class student: leaves=10 harry=student() larry=student() harry.std=12 harry.marks=100 harry.leaves=10 print("leaves of harry : " ,harry.leaves) #in...
false
720179901f16379215f0160e45b410f039462b33
A-Chornaya/Python-Programs
/LeetCode/same_tree.py
1,823
4.15625
4
# Given two binary trees, write a function to check if they are the same or not. # Two binary trees are considered the same if they are structurally identical and the nodes have the same value. ''' Example 1: Input: 1 1 / \ / \ 2 3 2 3 [1,2,3], [1,2,3] Output: t...
true
d5efc35e0ef0f9c25258247625e9063c8fdd5a92
AhmedFakhry47/Caltech-Learn-from-data-cours-homework-
/PLA.py
736
4.15625
4
''' A simple code (Script) to illustrate the idea behind perception learning algorithm ''' import numpy as np import matplotlib.pyplot as plt ##First step is generating data D = np.random.rand(3,1000) threshold = .4 #target function represented in weights f = np.array([0.2,0.8,0.5]).reshape((3,1)) Y = ...
true
486705e17f2ad4eb0ad7a421deb1319818f4142d
umeshchandra1996/pythonpractice
/palindrome.py
312
4.1875
4
num=int(input("Enter the number ")) numcopy=num #copy num for compare whith reverse reverse=0 while num>0: reminder=num%10 #find reminder reverse=(reverse*10) + reminder num//=10 if(numcopy == reverse): print("Yes It is a plaindrome number ") else: print("It is not plaindrome number ")
true
95fccfec6fdce9dc9c580d33362cc6bcc83a82c7
Nsk8012/30_Days_Of_Code
/Day_9/3_Logical&Condition.py
314
4.28125
4
# Logical condition - and & or # and n = 5 if n > 0 and n % 2 == 0: print('Even Positive') elif n > 0 and n % 2 == 1: print('Odd Positive') elif n == 0: print('Zero') else: print('Negative NUmber') # or n = 0 if n > 0 or n == 0: print('Not Negative Number') else: print('Negative Number')
false
52b50a64102f7813ab4c7dc2a20df989963965e9
Nsk8012/30_Days_Of_Code
/Day_5/2_List_with_value.py
780
4.53125
5
# Initialing the value fruits = ['banana', 'orange', 'mango', 'lemon', 'apple'] print('Fruits:', fruits) print('Length of Fruits List:', len(fruits)) # List can have items of different data types. lst = ['Nishanth', 15, True, {'Country': 'India', 'City': 'Coimbatore'}] print(lst) # Index of list # [a, b, c, d, e] # 0...
true
265d3fe67eefc5514a347f467ef3e2d4639b174f
Nsk8012/30_Days_Of_Code
/Day_8/1_Creating_Dictionaries.py
504
4.1875
4
# 30_Days_Of_Code # Day 8 # Dictionary will have key:value. empty_dict = {} # Dictionaries with Values dct = {'Key1': 'Value1', 'Key2': 'Value2', 'Key3': 'Value3', 'Key4': 'Value4'} print(dct) # len is used to find the length od dicitionaries print(len(dct)) # Accessing Dictionary Items by calling keys init. print(d...
true
719da2eb3374940257fa83a687556275a47f2351
BlaiseGD/FirstPythonProject
/RockPapScis.py
1,963
4.3125
4
from random import randrange reset = 'y' while reset == 'y': print("This is rock, paper, scissors against a computer!\ny means yes and n means no\nEnter 1 for rock, 2 for paper, or 3 for scissors") #1 is rock 2 is paper 3 is scissors for compInput computerInput = randrange(1, 4) userInput = int(input())...
true
7faf361b63dbd5d85da99313cd55a9e57eaefec5
beebeebeeebeee/python-practice
/bmi_calculator.py
561
4.40625
4
#bmi calculator #bmi function def bmi_calculator(height, weight): bmi = round(weight / ((height / 100) ** 2), 2) if bmi < 18.5: status = "underweight" elif 18.5 <= bmi < 24: status = "normal" elif 24 <= bmi < 27: status = "overweight" else: status = "obesity" ret...
false
b2d81645b2694214cc0b952a6f0abc694113c8d2
nstrickl87/python
/working_with_lists.py
2,909
4.28125
4
#Looping Through Lists magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician) #More WOrk in a Loop magicians = ['alice', 'david', 'carolina'] for magician in magicians: print(magician.title()) #makign Numerical Lists using the range function #Range off by one starts counting fro...
true
6c6293507679501315a1dcf6b5816ce937dc1d42
BC-csc226-masters/a03-fall-2021-master
/a03_olorunpojuessangd.py
1,267
4.1875
4
# Author: David Olorunpoju-Essang # Username: olorunpojuessangd # Assignment: A03: Fully Functional Gitty Psychedelic Robotic Turtles # Purpose: Draws a fractal tree #Reference : https://www.youtube.com/watch?v=RWtNQ8RQkO8 #Google doc link: https://docs.google.com/document/d/1AVxiZuugCxoRw1HFxaOiRBXjW_VQFrHNXVA4CwW8-q...
true
07d5cb0b86979e01d27520837279bf378d3c4f82
BC-csc226-masters/a03-fall-2021-master
/ayisie_A03.py
1,569
4.25
4
# Author : Ebenezer Ayisi # Username: ayisie # google link : https://docs.google.com/document/d/1EN02kKmUNzDABtUjf3uC-kj8b4T7asFKH69ek9Z7bSg/edit?usp=sharing # Assignment: T03: Turtles # Purpose: To very simply demonstrate the turtle library to demo shapes and using images for shapes import turtle def draw_eyes(je)...
false
456158d879e62a796234c946d7c3432254872e98
BC-csc226-masters/a03-fall-2021-master
/a03_bridgemanc.py
1,507
4.34375
4
# Author: Cameron Bridgeman # Username: bridgemanc # # Assignment: A03 :Fully Functional Psychedelic Robotic Turtles # Purpose: To learn how to draw something complex using RGB color values, functions, and more. ################################################################################# # Acknowledgements: # I le...
false
732fb7258b5baae253205e6fbf4c21c49948f15b
rupeshkumar22/tasks.py
/basic/fibonacci.py
1,179
4.25
4
from typing import List def matrixMul(a, b): """ Returns the product of the given matrices """ # Initializing Empty Matrix c = [[0, 0], [0, 0]] # 2x2 matrix multiplication. Essentially O(1) for i in range(2): for j in range(2): for k in range(2): c[i...
true
6b63098f3c1fdeb2fe23804b79d7881edbbbd8a5
MRajibH/100DaysOfCode
/DAY07/classes.py
678
4.21875
4
# OOP - Programming Paradigm # In OOP we think about world in terms of objects # Objects might store information or support the ability todo some operations # OOP helps you to create new types or you can say customized types e.g. 2D Values # class = A templete for a type of objects class point(): # It'll called a...
true
f02d92449a70f0e6365fb7ce764bfb91cbdef928
azarateo/bnds
/python_workspace/as/unicode.py
207
4.15625
4
print('Hello. This program will show you different unicode characters,'+ 'well at least the ones Python 3 can print') for x in range(32, 127): print "Character with number %d is %s in hex %X" % (x,x,x)
true
896f9a1d5526e06de47c6e4e870458ba81c82d44
842679600/MyPython
/面向对象.py
840
4.125
4
#对象=属性+方法,类名是大写字母开头 #面象对象的特征1.封装(信息屏蔽技术)2.继承 3.多态(名字一样,但是类不一样) #OOA面向对象分析,oop面向对象编程 ood:面向对象设计 #slef 相当于c+的指针,每个类都是需要self第一个参数 msg='' class Python_first_class(): def fisrtdef(self,name): self.name = name print('你好'+self.name) x=Python_first_class() x.fisrtdef('pp') #什么是继承 class Mylist(list): ...
false
8bc79e0d2a65ddca96589a3659beed116986b221
garikapatisravani/PythonDeepLearning
/ICP2/StringAlternative.py
311
4.21875
4
# Author : Sravani Garikapati # program that returns every other char of a given string starting with first # Ask user to enter a string s = str(input("Enter a string: ")) # Use slicing to get every other character of string def string_alternative(s): print(s[::2]) if __name__ == '__main__': string_alternative(...
true
1dca25eb10e1ea42cfaa5efada2c760a0d177f3a
rgraveling5/SDD-Task2a---Record-Structure-Lists-
/main.py
973
4.28125
4
#Record structure #Rachael Graveling #28/08/2020 # List to store all records student_records = [] # Number of records number_of_students = 3 # Loop for each student for x in range(number_of_students): student = [] student.append(input('Please enter name: ')) student.append(float(input('Please enter a...
true
1f0b4de15cf6e721462a4a7f1eb0384e082759f0
Aneesh540/python-projects
/NEW/one.py
1,237
4.125
4
""" 1) implementing __call__ method in BingoCage class which gives it a function like properties""" import random words = ['pandas', 'numpy', 'matplotlib', 'seaborn', 'Tenserflow', 'Theano'] def reverse(x): """Reverse a letter""" return x[::-1] def key_len(x): """Sorting a list by their length""...
true
44f1fc9e2a4a0d4daf2dfb19f95b68c4242dd23f
Aneesh540/python-projects
/closures/closures2.py
761
4.3125
4
""" A closure is a inner function that have access to variables in the local scope in which it was created even after outer function has finished execution""" import logging def outer_func(msg): message=msg def inner_func(): # print(message) print(msg) return inner_func hello=outer_func('hello') pri...
true
4ee9ad807758a023149d0b45efe19768a8757386
Aneesh540/python-projects
/closures/decorators.py
1,185
4.59375
5
""" Decorators are used to add functionality to functions without changing them in this module we'll be using functional decorators """ # Example 1 def decorator_function(original_func): def wrapper_function(): """return original function with execution""" print('wrapper xecte this before {}'.format(original_f...
false
4de9a04857f0e838acb52dba77a7ba5a98c303d7
meghaggarwal/Data-Structures-Algorithms
/DSRevision/PythonDS/bst.py
809
4.125
4
from dataclasses import dataclass @dataclass class Bst(): data:int left:object right:object def insertNode(data, b): if b is None: return Bst(data, None, None) if data < b.data: b.left = insertNode(data, b.left) else: b.right = insertNode(data, b.right) return b b = None b = i...
true
c24699269a2bdc789332da8b5a523930e6a0d616
mike1806/python
/udemy_function_22_palindrome_.py
439
4.25
4
''' Write a Python function that checks whether a passed string is palindrome or not. Note: A palindrome is word, phrase, or sequence that reads the same backward as forward, e.g., madam or nurses run. ''' def palindrome(x): x = x.replace(' ','') # This replaces all spaces " " with no space ''. (Fixes is...
true
88149ebc6508f5f6b031a1c98f572ea28d0f2b33
jpsampaio/ExEcommIT
/Ex42.py
674
4.15625
4
while True: n1 = float(input("\n Escreva o lado 1 do triângulo: ")) n2 = float(input(" Escreva o lado 2 do triângulo: ")) n3 = float(input(" Escreva o lado 3 do triângulo: ")) if(n1 > 0 and n2 > 0 and n3 > 0 and n1 <= n2+n3 and n2 <= n1+n3 and n3 <= n1+n2): if(n1 == n2 and n1 != n3 or n...
false
bf9d8f5013c8791f8df90f0f9c50095ed39de6cc
cpd67/Languages
/Python/Python3/Practice3.py
1,911
4.1875
4
#Python program for counting the number of times a letter appears in a string. #Also, learned that locals are NOT reassigned in for loop... def findMax(lis): """Finds the max element in a list.""" index = [0] m1 = [-999999999] #Special use case: empty list if len(lis) == 0: return -1, -1 #Special use case: lis...
true
f0cc6b193e1a77e194295927cea914fe3f1c7424
cpd67/Languages
/Python/Python3/Practice5.py
573
4.25
4
#!/bin/python # Dice Rolling Simulator # THIS CODE ONLY WORKS WITH PYTHON3 import random MIN = 1 MAX = 7 def rollDice(): print("Let's roll some dice!") print("Rolling...") print("The dice roll is: " + str(random.randrange(MIN, MAX))) rollDice() while True: x = input('Would you like to roll again? '...
true
d1acf74226395891e904adb871c7adad36c15ef4
Wattabak/quickies
/selection-sort-python/selection_sort.py
2,371
4.1875
4
""" Time complexity: Worst case: [Big-O] O(n^2) Average case: [Big-theta] ⊝(n^2) Best case: [Big-Omega] Ω(n^2) How it works: - find the position of the minimum element; - swap this element with the first one (because in the sorted array it should be the first); - now regard the sub-array of length N-1, w...
true
2b3155ea06158cec47b36bc822688f83024aeccf
do-py-together/do-py
/examples/quick_start/nested.py
1,369
4.15625
4
""" Nest a DataObject in another DataObject. """ from do_py import DataObject, R class Contact(DataObject): _restrictions = { 'phone_number': R.STR } class Author(DataObject): """ This DataObject is nested under `VideoGame` and nests `Contact`. :restriction id: :restriction name:...
true
d99461ef2af3705856402a4cfa25029512521a11
WillianSagas/teste
/2018-2S/noite/aula7/matriz_test.py
1,409
4.21875
4
# Para criar uma lista com 5 elementos '_' # ex. ['_', '_', '_', '_', '_'] print("Lista com elementos iguais") lista = [] for i in range(5): lista.append('_') print("Lista: ", lista) # Alternativa lista_alternativa = ['_' for i in range(5)] print("Modo Alternativdo de criar lista: ", lista_alternativa) # Para cr...
false
80c95e36826f3d3aa0c32986f35024d67b8e7609
carlagouws/python-code-samples
/How tall is the tree.py
1,167
4.21875
4
# ****************************************************************************************** # Description: # Program asks the user how tall the tree is # User inputs the height of the tree in number of rows, e.g. "9" produces a height of 9 rows ''' How tall is the tree : 5 # ### ...
true
4f624c48797695f31507d40cf0c0a84b15fad99c
krishankansal/PythonScripts
/Files/e.py
511
4.1875
4
def count_the(filename): ''' Total number of appeareances of word 'the' in file''' try: f = open(filename) contents = f.read() appeareances = contents.lower().count('the') print(f"The file {filename} has word 'the' appereared {appeareances}. times") except FileNotFoundError: ...
true
dd7ad1c4bb038caab7a793e4b24ff4b657b8dc8c
Bryantmj/iteration-1
/iteration.py
2,203
4.15625
4
# Make a local change # Make another local change # Make a change from home # iteration pattern # [1, 5, 7 ,8 , 4, 3] def iterate(list): # standard for loop with range # for i in range(0, len(list)): # print list[i] # for each loop for item in list: print item def print_list(list): print "" def add_one(l...
true
de773b5afd4597a2f89027b50b0f75a89a530085
VinceSevilleno/variables
/developmentexercise2.py
373
4.375
4
#Vince Sevilleno #24/09/2014 #Development Exercise 2 print("This program will convert a given value in degrees Fahrenheit into degrees Centigrade:") print() fahrenheit=int(input("Please enter any value of temperature:")) centigrade=(fahrenheit-32)*(5/9) print() print("The value {0} degrees Fahrenheit is equa...
true
acd07f7c71a7a5e941ef5be46fe296ae65a47e32
sunruihua0522/SIG-PyCode
/Python Study/buldin property.py
1,004
4.15625
4
class People: '这是一个测试类的内置属性的测试' PeopleNumber = 0 def __init__(self, Name, Age, Address='none'): People.PeopleNumber += 1 self.Name = Name self.Age = Age self.Address = Address def __del__(self): People.PeopleNumber -=1 def SayHello(self): print('%s s...
false
d60cc8f46dbf6738555f7a715869f1e38e7ca033
girl-likes-cars/MIT_programming_course
/Newton square root calculator.py
577
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sun Jun 24 16:52:15 2018 @author: Maysa """ #Set the epsilon and the square root you want to find #Pick a random starting point for your guess (let's say, guess/2) epsilon = 0.01 k = int(input("Give me a number whose square root you want to find! ")) guess = k/2.0 ...
true
eb4481b19aa8e9c0116ae88a69b596192a05cf9c
AlvaroMenduina/Jupyter_Notebooks
/Project_Euler/41.py
1,564
4.125
4
""" Project Euler - Problem 41 We shall say that an n-digit number is pandigital if it makes use of all the digits 1 to n exactly once. For example, 2143 is a 4-digit pandigital and is also prime. What is the largest n-digit pandigital prime that exists? """ import numpy as np import itertools def is_prime(n): ...
true
fcf684ff90ae780d7070caef6ecfced3749e5c8c
Charlieen/python_basic
/python_tutorial/NumberAndString.py
2,942
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Mon Feb 8 09:13:37 2021 @author: dzgygmdhx """ # print(2+2) # print(8/3) # print(17//3) # print(17%3) # print(5**2) width =20 height= 3*9 print(width * height) # begin string '' " " \ \n r print('I like "you", but "you" do not like me') print("I like ...
true
a5e324794898c9ed9a024dcb506366e9617c1694
mvimont/FoundationsofMeasurement
/Chapter1/ThreeProceduresBasicMeasurement/Ordinal/ordinal.py
1,948
4.21875
4
import sys import random #Covers contens of Chapt 1, 1.1.1 pages 2 - 3 #Purpose here to define fundamental concepts (greater than, addition, etc) in definition/conditions used in book #length is here used as means to illustrate attribution of quantities to qualitative observations #transitive property def is_greater(...
true
029d436bddee58022eaa2c619b3adccf19f34884
SeanRosario/assignment9
/lk1818/data.py
1,129
4.125
4
''' This module is for data importing, transforming, and merging. ''' import pandas as pd import numpy as np def load_data(): #this function reads the files and creates two data frames: countries and income in desired format. countries = pd.DataFrame(pd.read_csv('./countries.csv')) income = pd.DataFrame...
true
8075bf6e3f2b4e9551fc405d348704ea7e757286
nglongceh/HWbyNglong
/BubbleSort.py
504
4.125
4
def BubbleSort(list): for i in range(len(list)): for j in range(len(list)-1): # Ascending list if list[j] > list[j+1]: temp = list[j] list[j] = list[j+1] list[j+1] = temp return list def main(): list = [] lenL...
false
ed784f7a6638216dc456eccbe7adcf8172234450
Mukesh-SSSDIIT/python2021_22
/Sem5/Collections/List/list_basic3.py
686
4.125
4
list1 = ["aaa","bbb","ccc"] list2 = [111,222,333] list3 = list1 + list2 print(list1) print(list2) print(list3) # Another way to join to lists. # for i in list2: # list1.append(i) # print(list1) # Use extend method list1.extend(list2) print(list1) list4 = list([1,2,3,4]) print(list4) list5 = [10,20,10,20...
true
851f4795a81b7ea502e7f1e88e745206b7a989c8
mlnance/JHU_Class_Material
/comp_prot_pred_and_des/hw1/MLN_hw1_q2a.py
877
4.46875
4
#!/usr/bin/python __author__="morganlnance" ''' Homework 1 Question 2a Usage: ./script.py <nth number of Fibonacci sequence> Example: ./MLN_hw1_q2a.py 5 ''' ########### # IMPORTS # ########### import sys ############# # FUNCTIONS # ############# def fib(num): # num == 0 # if asking for the 0th fib number, ...
false
f4fe9dd155371769e419497fc24a46f0ead30cfd
NathanCrowley/Coding_Challenges
/Python_Challanges/Medium_difficulty/Email_generator.py
770
4.3125
4
class Employee: def __init__(self,first,second): self.first = first self.second = second def email(self): email = self.first.lower() + '.' + self.second.lower() + '@company.com' return email def fullname(self): fullname = self.first + ' ' + self.second retur...
false
cac27739601b117356d19c3a8bad348ac16863a9
bilaleluneis/LearningPython
/abstract_class.py
1,708
4.375
4
from abc import ABC, abstractmethod __author__ = "Bilal El Uneis and Jieshu Wang" __since__ = "June 2018" __email__ = "bilaleluneis@gmail.com" """ Animal is an abstract class and I shouldn't be able to create instance of it, but in python there is no abstract keyword or feature that is part of the language construct...
true
592b8c16c6ed624d8ae70f240be8be978780dee0
Mahay316/Python-Assignment
/Homework/homework1/assign1.py
663
4.125
4
# 1. 元素输出和查找 # 请输出0-50之间的奇数,偶数,质数 # 能同时被2和3整除的数 from math import sqrt # 练习使用列表解析式生成列表 odd = [x for x in range(51) if x % 2 == 1] print("奇数:") print(odd) even = [x for x in range(51) if x % 2 == 0] print("偶数:") print(even) # 练习使用循环判断质数 print("质数:") for i in range(2, 51): for j in range(2, int(sqrt(i)) + 1): ...
false
399124fad7d11889f36237589336c1da625d3587
Mahay316/Python-Assignment
/Homework/homework6/assign4.py
1,060
4.1875
4
# 4. 封装一个学生类,有姓名、年龄、性别、语文成绩、数学成绩和英语成绩 # 封装方法,求单个学生的总分,平均分,以及打印学生的信息 class Student: GENDER_MALE = '男' GENDER_FEMALE = '女' def __init__(self, name, age, gender, score): self.name = name self.age = age self.gender = gender # score为元组,依次保存语文、数学和英语成绩 self.score = score ...
false
09383d8e3d90a1801c149c2506d78660d790c983
JuliaGu808origin/pyModul1
/extraLabba/extra2/extra2/extra2.1.py
341
4.59375
5
# Write a Python program to get the dates 30 days before and after from the current date # !可以顯示再漂亮一點 import datetime today = datetime.datetime.now() before = today - datetime.timedelta(days=30) after = today + datetime.timedelta(days=30) print(f"Today: {today}, \n30 days before: {before}, \n30 days after: {after}")...
true
979d8e871ff93c499b1e2c5fa30084f399b60655
JuliaGu808origin/pyModul1
/extraLabba/extra2/extra2/extra2.2.py
795
4.34375
4
######################################################### # Write a Python program display a list of the dates # for the 2nd Saturday of every month for a given year. ######################################################### import calendar try: givenYear = int(input("Which year -> ")) except: print("Wrong y...
true
e97220295929a55b8a4d67316cc7a53371ae156b
Jatin7385/Temperature-Converter
/Temperature_Converter.py
1,685
4.34375
4
def options(): print("Which conversion would you like me to do?") print("1)Celcius to Farenheit") print("2)Celcius to Kelvin") print("3)Farenheit to Celcius") print("4)Farenheit to Kelvin") print("5)Kelvin to Celcius") print("6)Kelvin to Farenheit") print("7)Quit Program") choice = i...
false
5d13fd5fed6c1f1fc198039f4f8249ea33c73a31
smraus/python-assignments
/28 octal to decimal.py
246
4.40625
4
#---- 28 octal to decimal conversion ---- print('Octal to decimal conversion\n') octal = input('Enter octal number : ') octal = octal[::-1] decimal = 0 for i, bit in enumerate(octal): decimal += int(bit) * 8 ** i print('Decimal :' , decimal)
false
c58dc265baa1f9ad0d4530ed428f44c1eba98726
smraus/python-assignments
/27 binary to decimal.py
253
4.4375
4
#---- 27 binary to decimal conversion ---- print('Binary to decimal conversion\n') binary = input('Enter binary number : ') binary = binary[::-1] decimal = 0 for i, bit in enumerate(binary): decimal += int(bit) * 2 ** i print('Decimal :' , decimal)
false
08f51078381095f447623fed68837c911cedb949
smraus/python-assignments
/08 startswithIs.py
517
4.375
4
#--------8 program to get a new string from a given string where "Is" has been added to the front------- def main(): while True: try: string = input('Enter a string : ') if string.startswith('Is'): print('Your string' , string , 'is correct.') else: ...
true
a85ccfc169daf20fc4ced387b9d51cdcdc7ef556
smraus/python-assignments
/37 number palindrome.py
834
4.25
4
#---- program to reverse the digits of a given number and add it to the original, If the sum is not a palindrome repeat this procedure ---- def number(): num_inp = input('Enter digits : ') num_inp_rev = num_inp[::-1] num_total_inp = int(num_inp) + int(num_inp_rev) num_total_inp = str(num_total_inp) ...
false
f1a30558ce9da0d7f2f57b4782dc406b9e19f819
smraus/python-assignments
/16 x1y1 x2y2.py
757
4.3125
4
#-----16 program to compute the distance between the points (x1, y1) and (x2, y2)---- from math import sqrt def main(): while True: try: print('Enter the pairs in the format x,y') x1_y1 = input('Enter x1,y1 : ') x2_y2 = input('Enter x2,y2 : ') first = x1_y1.sp...
true
3d4a19f5a378a454403c21abe780ee3a62fe9cc7
qainstructorsky2/gitleeds2021c1
/demos/lambda.py
416
4.59375
5
choices = { "R":,Rock "P": Paper, "S: Scissors" } # Get the user's choice of the three user_choice = input("\nType R, P, or S to play against the computer: ") # Print what the user's choice, so she knows what she picked print user_choice # Make sure the user input is valid if user_choice in choices: print "You ch...
true
d02059f5953986a9aaa0680b42321c3f58336189
rob19gr661/Python-Tutorials
/Python/2 - Reading And Writing Files/Writing_Files.py
680
4.125
4
""" Writing Files: """ # Testing the "a" operation """ Test_file = open("Testtest.txt", "a") # Remember that append will add something to the end of the file Test_file.write("\nToby - Official poopscooper") # We add the typed line to the end of the document Test_file.close() """ # Testing the "w" ope...
true
b029fb0cd22c7c7a4c6ae93dc85e2d6223f804e6
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Strings/434_number_of_segments_in_string.py
560
4.28125
4
# Count the number of segments in a string, where a segment is defined to be a contiguous sequence of non-space characters. # # Please note that the string does not contain any non-printable characters. # # Example: # # Input: "Hello, my name is John" # Output: 5 def countSegments(s): """ :type s: str :rty...
true
9b0583e881f7ae10553828b4051968d8b0619a5e
AmitKulkarni23/Leet_HackerRank
/CrackingTheCodingInterview/Bit Manipulation/ith_bit_set.py
795
4.15625
4
""" Python program to check if ith bit is set in the binary representation of a given number To check if the ith bit is set or not (1 or not), we can use AND operator And the given number with 2^i. In 2 ^ i only the ith bit is set. All the other bits are zero. If numb & ( 2 ^ i) returns a non-zero number then the ith ...
true
fd0d1ff9f35f40b9159edd85135d069a02b562b4
AmitKulkarni23/Leet_HackerRank
/Dynamic_Programming/rod_cutting.py
957
4.15625
4
# Given a rod of certain lenght and given prices of different lenghts selling in the # market. How do you cut teh rod to maximize the profit? ################################### def get_cut_rod_max_profit(arr, n): """ Function that will return maximum profit that can be obtained by cutting teh rod into pie...
true
c5d38264a6fc929dad3989817c2965fa3c67c0e6
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Trees/226_invert_binary_tree.py
1,294
4.40625
4
# Invert a binary tree. # # Example: # # Input: # # 4 # / \ # 2 7 # / \ / \ # 1 3 6 9 # Output: # # 4 # / \ # 7 2 # / \ / \ # 9 6 3 1 # Definition for a binary tree node. # class TreeNode(object): # def __init__(self, x): # self.val = x # self.left = N...
true
f5e0e4edbdb2beb39e967a2edbc8d0f246649079
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Strings/844_backspace_string_compare.py
989
4.25
4
# Given two strings S and T, return if they are equal when both are typed into empty text editors. # means a backspace character. # # # # Example 1: # # Input: S = "ab#c", T = "ad#c" # Output: true # Explanation: Both S and T become "ac". # Example 2: # # Input: S = "ab##", T = "c#d#" # Output: true # Explanation: Both...
true
ff3dc719301e1f8dbcfc28964d43173e79c7278d
AmitKulkarni23/Leet_HackerRank
/Dynamic_Programming/maximum_sum_increasing_subsequence.py
1,346
4.25
4
# Given an array of n positive integers. # Write a program to find the sum of maximum sum subsequence of the given array such that the intgers in # the subsequence are sorted in increasing order. For example, if input is {1, 101, 2, 3, 100, 4, 5}, # then output should be 106 (1 + 2 + 3 + 100), # if the input array is {...
true
9a640edb1c2cea9743d4b651dbbae43095032d20
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Trees/572_subtree_of_another_tree.py
2,144
4.15625
4
# Given two non-empty binary trees s and t, check whether tree t # has exactly the same structure and node values with a subtree of s. # A subtree of s is a tree consists of a node in s and all of this node's descendants. # The tree s could also be considered as a subtree of itself. # # Example 1: # Given tree s: # # ...
true
a8dce32f98177322594dbd445b955acfa98c6fcb
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/merge_2_sorted_linked_lists.py
2,896
4.125
4
# Merge 2 sorted linked lists # Return the new merged list # Definition for singly-linked list. # class ListNode: # def __init__(self, x): # self.val = x # self.next = None # My Solution - Very poor performance - beats only 26% of python submissions # Runtime for 208 test cases = 88ms # Sometimes...
true
ed006d939bae223afdd788f0becae5ffe29e2ad3
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Bit_Manipulation/number_of_1_bits.py
1,081
4.375
4
# Write a function that takes an unsigned integer and returns the number of '1' bits it has (also known as the Hamming weight). # # Example 1: # # Input: 11 # Output: 3 # Explanation: Integer 11 has binary representation 00000000000000000000000000001011 # Example 2: # # Input: 128 # Output: 1 # Explanation: Integer 128...
true
b2af5b93ed6b9fc6fa6503ed5ad1b93caae1ea70
AmitKulkarni23/Leet_HackerRank
/LeetCode/Medium/BFS/199_binary_tree_right_side_view.py
1,605
4.3125
4
# Given a binary tree, imagine yourself standing on the right side of it, return the values of the nodes you can see ordered from top to bottom. # # Example: # # Input: [1,2,3,null,5,null,4] # Output: [1, 3, 4] # Explanation: # # 1 <--- # / \ # 2 3 <--- # \ \ # 5 4 <--- # ...
true
6e65a2c082edad96b92dc17dced5ed6615e22433
AmitKulkarni23/Leet_HackerRank
/LeetCode/Medium/DFS/439_ternary_expression_parser.py
2,830
4.5625
5
# Given a string representing arbitrarily nested ternary expressions, calculate the result of the expression. You can always assume that the given expression is valid and only consists of digits 0-9, ?, :, T and F (T and F represent True and False respectively). # # Note: # # The length of the given string is ≤ 10000. ...
true
3c9e6d1bc56f8b97daada933d42d642542d3cd5c
AmitKulkarni23/Leet_HackerRank
/LeetCode/Easy/Bit_Manipulation/power_of_2.py
362
4.21875
4
# Given an integer, write a function to determine if it is a power of two. # # Example 1: # # Input: 1 # Output: true # Example 2: # # Input: 16 # Output: true # Example 3: # # Input: 218 # Output: false def isPowerOfTwo(self, n): """ :type n: int :rtype: bool """ if n > 0: ...
true
efe5f93bbda6a8c7729f320e8f93bf710218ef32
lv888/fizzbuzz
/fizzbuzzLV.py
384
4.25
4
#fizzbuzzattemptsLV # Example output: "1 2 fizz 4 buzz fizz 7" # fizz for numbers divisible by three # buzz for numbers divisible by five i = int(input("Enter a number: ")) num = 0 while num < i: num += 1 if num == 0: continue if num%3 == 0: print("fizz") continue if num%5 == 0:...
false
58589846f783e636a07f40bb1c9a67441cbe9bdd
giancarlo358/cracklepop
/crackle_pop.py
686
4.25
4
#Write a program that prints out the numbers 1 to 100 (inclusive). #If the number is divisible by 3, print Crackle instead of the number. #If it's divisible by 5, print Pop. #If it's divisible by both 3 and 5, print CracklePop. You can use any language. #custom range start = 1 end = 101 my_range = range(start,end) div...
true
08772f0631dc9181b1edfafce557153778c8cb97
UjjwalP08/Basics-Of-Python
/No_06_dictonary.py
1,576
4.65625
5
a = {"key": "value", "greet": "good morning", "jay": "studyman", "mehul": "FEKU"} # Here a is dictionary in python dictionary start with curly brackets{} """Dictionary is collection of key and value pairs""" print(a) print(a["key"]) print(a["greet"]) # here this the key and we print the value of key a["ritik"] = "Gk"...
false
f592d4f598ec510ad260fb6133460514ea38e7d4
UjjwalP08/Basics-Of-Python
/Exercises/Exercise 1.py
353
4.125
4
"""In This exercise we can take input from user and compiler return according to its out put Eg:- Key now we can provide some details about it.""" a = {"key": "Use to open lock", "greet": "Means to Call about Good mornig", "IT": "Study of Website and Computer"} "" print(a.keys()) print("Enter Key which details you wan...
true
c4a9d247b4095d2db4b6de8e86656368b1014a8c
UjjwalP08/Basics-Of-Python
/Practice/1.py
762
4.21875
4
""" ---------> Program of printing star pattern <--------- """ n=input("Enter the value of n:-") n=int(n) # for value in range(n,0,-1): # for itm in range(1,value+1): # print("*",end=" ") # print() # # for values in range(1,n+1): # print(values) for i in range(1,n+1): for j in rang...
false