blob_id stringlengths 40 40 | repo_name stringlengths 5 119 | path stringlengths 2 424 | length_bytes int64 36 888k | score float64 3.5 5.22 | int_score int64 4 5 | text stringlengths 27 888k |
|---|---|---|---|---|---|---|
c8b57f42b4db063ca7c79841fcc6172c99d824ba | rchronic/hackerrank | /Belajar_1/Repeated String | 1,059 | 3.65625 | 4 | #!/bin/python
import math
import os
import random
import re
import sys
# Complete the repeatedString function below.
def repeatedString(s, n):
sums = 0
if len(s) == n:
x = sorted(s)
for i in x:
if i == 'a':
sums += 1
else:
break
elif ... |
953693222f0d0cd396538813f42c86476879af24 | KKisly/PrismAssignments | /SalesMan/SalesMan.py | 2,255 | 4.125 | 4 | # This script is to find distance between cities
import csv
import math
from math import pi, log, tan
#loop through csv list
def find (city):
csv_file = csv.reader(open('cc.csv', "rt"), delimiter=",")
for row in csv_file:
if city == row[1]:
finding = row
#print(finding)
... |
09ee263336d9d5a5be3c23f0d505a177702d2f83 | OwenAspen/Python-Practice | /CowsAndBulls.py | 1,445 | 3.5625 | 4 | import random
#Cows and bulls: Generates a 4 digit string, asks user for a 4 digit string,
#if the strings match, you win. Otherwise, for every matching digit
#in the same position of the string, you will get a cow. for every digit in both
#strings, but not in the same position, you get a bull.
guesses = 0
#Counts th... |
c7850878a9b2db7f0cbdfe2e6b3e5c5468c2f5f5 | mvinovivek/BA_Python | /Class_5/adfd.py | 83 | 3.828125 | 4 | X=[1,2,3,4]
Y=["One","Two","Four","Three"]
for x,y in (zip(X,Y)):
print(x,y)
|
516d924a5a23e85e13e07206430f3178e6f83135 | fazriegi/Python | /Algoritma Pengurutan/Selection Sort/selectionSort.py | 336 | 3.71875 | 4 | # Algoritma Sorting
# Kompleksitas 0(N**2)
def selectionSort(arr):
for i in range(len(arr)-1):
minIndex = i
for j in range(i+1, len(arr)):
if arr[j] < arr[minIndex]:
minIndex = j
arr[i], arr[minIndex] = arr[minIndex], arr[i]
a = [1, 5, 2, 7, 4, 9, 8]
selectionS... |
d337523cd9af9acdcb78db9d17f73c5017b1c98e | kn33hit/Coursework | /GL_backup/201/LABS/LAB5/lab5.py | 1,018 | 3.765625 | 4 | # file: lab5.py
# author: Neh Patel
# date: 10/3/2013
# section : 17
# email : npatel10@umbc.edu
# description : this program determines whether a number is perfect or not
def main():
# declaring variables
total = 0
divisor = 0
flag = True
num = 0
# input
while (flag):
tr... |
36552fc1aa7896a3b71a13ed5db1c1a4d1bc825e | ray60110/HeadFirst_Python | /Chapter6/dataobject.py | 906 | 3.625 | 4 | def sanitize(time_string):
# create a function to produce standardized time format. xx.xx
# erase anyother marks wihin each value.
if '-' in time_string:
splitter= '-'
elif ':' in time_string:
splitter= ':'
else:
return(time_string)
(mins, secs)= time_string.split(splitt... |
8b1a709002770b53100d2d708f1a0a38c3bb7b33 | SlipShabby/Hackerrank | /Python/functionals.py | 943 | 3.890625 | 4 | # map and lambda
cube = lambda x: x**3 # complete the lambda function
def fibonacci(n):
a,b = 0,1
for i in range(n):
yield a
a,b = b,a+b
# return a list of fibonacci numbers
# reduce
def product(fracs):
t = reduce((lambda x,y: x*y) ,fracs)# complete this line with a reduc... |
710c1daafafebff47a6f963c5077017cf4e9cec0 | rynk14/AlgorithmData | /4็ซ ๅๅธฐใจๅๅฒ็ตฑๆฒป/euclid.py | 1,012 | 3.921875 | 4 | # 4็ซ ๏ผๅๅธฐ
"""
p.46ใฆใผใฏใชใใใฎไบ้คๆณ
mใnใงๅฒใฃใใใพใใrใจใใใจ
GCD(m, n)=GCD(n, r)
ใงใใ
"""
def GCD(m, n):
# ใใผในใฑใผใน
if n==0: # ใใพใใ0ใชใใฐ็ตใใ
return m
# ๅๅธฐๅผใณๅบใ
return GCD(n, m%n)
print("ใฆใผใฏใชใใใฎไบ้คๆณ")
print("GCD(51, 15)={}".format(GCD(51, 15)))
print("\n")
"""
p.47ใใฃใใใใๆฐๅๅๅธฐversion
F_0=0
F_1=1
F_N=F_N-1+F_N-2 (N... |
bd45fe22e646e060c806a8f8969247a332700670 | obviouslyghosts/dailychallenges | /ProjectEuler/036/pe-036.py | 719 | 3.78125 | 4 | """
The decimal number, 585 = 1001001001^2 (binary), is palindromic in both bases.
Find the sum of all numbers, less than one million, which are palindromic
in base 10 and base 2.
(Please note that the palindromic number, in either base, may not include
leading zeros.)
"""
# an even number will end with a 0 in binar... |
3afc674c012099ea0b886baf160576039102db5b | tnehf18/chatbot | /ch02_control/ex10_for.py | 4,597 | 4.03125 | 4 | # ํ์ด์ฌ ๊ธฐ์ด (+์นด์นด์คํก ์ฑ๋ด) ์คํฐ๋ 1์ฃผ์ฐจ
# python ์ ์ด๋ฌธ
# 3. ๋ฐ๋ณต๋ฌธ for
# 3.1 ๊ธฐ๋ณธ ํํ
print("\n[ 3.1 ๊ธฐ๋ณธ ํํ ] โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ\n")
numbers = [1, 2, 3]
print(numbers, type(numbers))
for i in numbers:
print(i)
# range() ํ์ฉ
print("\n# range() ํ์ฉ")
for i in ra... |
d2045429e00bfcc4b183d55d221b2d36da495bca | LachezarKostov/SoftUni | /03_ะOP-Python/05-PolymorphismandMagicMethods/02-Exercise/03_account.py | 2,465 | 3.578125 | 4 | class Account:
def __init__(self, owner: str, amount: int = 0):
self.owner = owner
self.amount = amount
self._transactions = []
def add_transaction(self, amount: int):
if not isinstance(amount, int):
raise ValueError("please use int for amount")
self._transac... |
2cddb5e422737ce9b31a383e5881fca709266226 | ilhamdwibakti/Python3.x_Object_Oriented_Programming | /Episode #13 - Super()/Main.py | 478 | 3.65625 | 4 | class Hero:
def __init__(self,name,health):
self.name = name
self.health = health
def showInfo(self):
print ("{} dengan health: {}".format(self.name,self.health))
class Hero_intelligent(Hero):
def __init__(self,name):
#Hero.__init__(self, name, 100)
super().__init__(name, 100)
super().showInfo()
class... |
0962cd62297cfe4f2fbd8d0e4f27e6b69b6e7c05 | KrisCheng/HackerProblem | /Python/4_ChannelExchange/force_exchange.py | 1,828 | 3.5 | 4 | #!/usr/bin/python
# -*- coding: utf-8 -*-
'''
Desc: see readme
Author: Kris Peng
Copyright (c) 2017 - Kris Peng <kris.dacpc@gmail.com>
'''
import random
import time
def Exchange(num, maxChannel):
matrix = []
for i in range(num):
matrix.append([])
for j in range(num):
matrix... |
5ed5e46838e79b1b71a7770013167d5f4695afcf | TDhondup/Unit_4_Lesson_5 | /Lesson 5/problem1.py | 189 | 4.03125 | 4 | from turtle import *
me = Turtle()
me.color("red")
me.pensize(6)
me.speed(7)
me.shape("turtle")
def DrawTri():
for x in range(3):
me.forward(100)
me.left(120)
DrawTri()
mainloop() |
fe9fb85561a47f44890223483420b97a84e0bf3e | paweldrzal/python_codecademy | /file_io.py | 519 | 4.0625 | 4 | #File Input/Output
my_list = [i**2 for i in range(1,11)]
# Generates a list of squares of the numbers 1 - 10
f = open("output.txt", "w")
#This told Python to open output.txt in "w" mode ("w" stands for "write"). We stored the result of this operation in a file object, f.
#"r+" will allow you to read and write
fo... |
2cf3991c1690d9a5b0d59f02d064b7547f7d2d24 | anabeatrizzz/exercicios-pa-python | /exemplos_Aula_4/Aula_4_09.py | 197 | 3.984375 | 4 | matriz = [
[1, 42, 23, 14, 51],
[22, 32, 55, 54, 12]
]
print("Os elementos pares da matriz sรฃo: ")
for a in range(0, 2):
for b in range(0, 5):
if matriz[a][b] % 2 == 0:
print(matriz[a][b]) |
8a65934afc899c73a7231a9aa8b33c361807408c | munakata0299/Python_Lesson | /python_programming/lesson63.py | 843 | 3.859375 | 4 | # Pythonใioใใใใกไธใซไฝใฃใฆใใใไธๆใใกใคใซใๅฆ็ใ็ตใใฃใใๆถใใ
import tempfile
# ไธๆใใกใคใซใไฝๆใใฆไฝฟ็จใใๆนๆณใฏไปฅไธใฎ้ใ
with tempfile.TemporaryFile(mode='w+') as t:
t.write('hello')
t.seek(0)
print(t.read())
#ใไธๆใใกใคใซใๆฎใใใๅ ดๅใซใฏไปฅไธใฎ้ใ
with tempfile.NamedTemporaryFile(delete=False) as t:
print(t.name)
with open(t.name, 'w+') as f:
... |
4cdbca49da01e32a554673d4c33db8292899f37f | sravankarthik/dsa | /mysolution/last_digit_of_fibonacci_number.py | 444 | 4.03125 | 4 | def last_digit_of_fibonacci_number(n):
assert 0 <= n <= 10 ** 7
# 1 1 2 3 5
if n == 1:
return 1
elif n==2:
return 1
a=1
b=1
for i in range(2,n):
summ=a+b
#print(summ)
x=str(summ)
x=int(x[len(x)-1])
a=b
b=x
... |
5d2b0cdb45e3672193937851c4e8a236641591a9 | tzieba1/IntroPythonFiles | /PythonCodeSnippets/numberCheck.py | 1,459 | 3.921875 | 4 | myString = ""
keepLooping = True
while myString.lower() != "q" and keepLooping != False :
myString = input("A number: ")
myNumber = ""
isNegative = False
isFloat = False
isNumber = True
firstNumberSeen = False
decimalPointSeen = False
loopCounter = 0
while ( loopCo... |
d1d01c6ba1d4cf2e3037644b0466a36af8ab0d01 | joaoppadua/fight-club | /covid ciencia git/code/budget_uni.py | 541 | 3.609375 | 4 | #Script to generate plot for budget data
import pandas as pd, numpy as np, plotly.express as px
df = pd.read_excel(r'/Users/joaopedropadua/Dropbox/Textos Padua/covid ciencia brasil/orcamento_universidades.xlsx')
graph_df = df[['Universidade', 'Valor per capita (em US$ dรณlares)']]
graph_df_rounded = graph_df.round(3)
... |
f9e5bb8777b25d3547f49c8a7e394aef74201629 | SaribK/2D-Shape-Physics | /Scene.py | 2,923 | 3.53125 | 4 | ## @file Scene.py
# @author Sarib Kashif (kashis2)
# @brief Contains the Scene class to create
# a simulation of a shape moving
# @date Feb 12 2021
# @details Uses provided functions that decide
# how the shape will behave
from scipy import integrate
## @brief Scene is a class that implements an ADT to display... |
e88ee13da4710e59dd02a5fd48896bc46baca1cf | tamzidhussainkhanpage/zserio | /compiler/extensions/python/runtime/src/zserio/builtin.py | 575 | 3.734375 | 4 | """
The module provides implementation of zserio built-in operators.
"""
def numbits(num_values: int) -> int:
"""
Gets the minimum number of bits required to encode given number of different values.
This method implements zserio built-in operator numBits.
:param num_values: The number of different va... |
97a0585379f2c1396064d4a67889cd952ec2b7af | Nagappansabari/PythonPrograming | /findprimenumber.py | 242 | 3.78125 | 4 | x=input()
y=input()
if x<y:
for z in range(x+1,y-1):
if z%2!=0 and z%3!=0 and z%5!=0 and z%7!=0 and z!=1:
print z
elif z==2 or z==3 or z==5 or z==7:
print z
else:
print("enter the valid range")
|
42561e7d4d758008fb406a9b6cd40c955c63df11 | Nathx/data_structures_and_algorithms | /and_or_xor.py | 480 | 3.578125 | 4 | # https://www.hackerrank.com/challenges/and-xor-or
def max_xor(seq):
stack = []
max_xor = 0
for elem in seq:
while stack:
prev = stack[-1]
max_xor = max(max_xor, elem ^ prev)
if prev >= elem:
stack.pop()
else:
break
... |
ecce52c06fb160666efeaa384ce5a666e6510e42 | sg13blue/TTT | /ttt.py | 1,271 | 3.703125 | 4 | from tttlib import *
def main():
T=genBoard()
gameNotOver= True
while gameNotOver:
printBoard(T)
#Player is x, game starts by X choosing available spot and displaying game state.
moveX = input("X move?")
m=int(moveX)
if m<-1 or m>9:
print("Not in range... |
8bee1f10fa3e16c8cae5759e2343617b7829279b | arodrrigues/DP_CS_Code_ARodrigues | /tools/tools/reverseWordA.py | 559 | 4.09375 | 4 | '''
Description: Write a method called reverseWordA. The method takes
a Strings and returns the string in reverse
Parameters: String s
Returns: String
Precondition: s is a valid string of any length.
reverseWordA(โcatโ) โ โtacโ
'''
def reverseWordA(s):
a = "" #sets a to an empty string
#loop through the stirng i... |
81bae11b54999d460c44d4eded128691c2e7ed19 | m-sandesh/Python-Learnings | /Python/15LIstExercise.py | 345 | 4 | 4 | # A program takes start, stop and end listing values
startInp = int(input('Enter Starting Value: '))
endInp = int(input('Enter Ending Value: '))
jumpInp = int(input('Enter Jumping Value: '))
print('Integers\t' + 'Squares\t\t' + 'Cubes')
for i in range(startInp, endInp, jumpInp):
print('{}\t\t{}\t\t{}'.for... |
46ef2e9502007296c7dd96e569a06669b8adbeeb | LarisaOvchinnikova/Python | /HW7(list comprehension)/0 - a list of numbers.py | 207 | 3.921875 | 4 | # Use list comprehension and range function
# to create a list of numbers with type str
def createListOfNumbers(n):
x = [str(number) for number in range(n)]
return x
print(createListOfNumbers(10)) |
7a457e123afdf2cc2c4c99f1b474a4d849d6c6fc | adi-797/10-Days-of-Statistics-Hackerrank | /10 Days of Statistics/Multiple Linear Regression.py | 689 | 3.5 | 4 | # Enter your code here. Read input from STDIN. Print output to STDOUT
from sklearn import linear_model
input_line = str(raw_input()).split()
m,n = int(input_line[0]),int(input_line[1])
x_train=[]
y_train=[]
for i in range(n):
input_line = map(float,str(raw_input()).split())
x_train.append(input_line[:m])
y_... |
00d102b701c88b44e56eab6c98f282f4d90983d6 | rohangoli/PythonAdvanced | /Leetcode/LinkedList/p1227.py | 1,487 | 4.1875 | 4 | ## Merge Two Sorted Linked Lists
# Example 1:
# Input: list1 = [1,2,4], list2 = [1,3,4]
# Output: [1,1,2,3,4,4]
# Example 2:
# Input: list1 = [], list2 = []
# Output: []
# Example 3:
# Input: list1 = [], list2 = [0]
# Output: [0]
# Definition for singly-linked list.
# class ListNode:
# def __init__(self, val=0,... |
9f08f757d2e93de021298dbf1629044cf949b3de | hmsong95/Lindsey-novel | /Lindsey Python/09C-cacl.py | 475 | 3.640625 | 4 | import random
a=random.randint(1,30) #1์์ 30๊น์ง ์์์ ์ ์๋ฅผ ๋ถ๋ฌ a์ ์ ์ฅํ๋ค.
b=random.randint(1,30) #1์์ 30๊น์ง ์์์ ์ ์๋ฅผ ๋ถ๋ฌ b์ ์ ์ฅํ๋ค.
print(a,"+",b,"=") #๋ฌธ์ ๋ฅผ ์ถ๋ ฅํฉ๋๋ค.
x=input() #๋ต์ ์
๋ ฅ๋ฐ์ x์ ์ ์ฅํฉ๋๋ค. ๋ฌธ์์ด๋ก ์ ์ฅ๋ฉ๋๋ค.
c=int(x) #๋ฌธ์์ด๋ก ๋์ด ์๋ x๋ฅผ ์ ์๋ก ๋ฐ๊พธ์ด c์ ์ ์ฅํฉ๋๋ค.
if a+b==c:
print("์ฒ์ฌ")
else:
print("๋ฐ๋ณด")
|
f5c6335a9718eb0f1ed34b7d7a01f0269ef97ec6 | huangsam/leetcode | /python/firstBadVersion.py | 1,103 | 3.53125 | 4 | # https://leetcode.com/problems/first-bad-version/
# Example of a possible answer (>=1)
ANSWER = 4
def isBadVersion(version):
"""
:type version: int
:rtype: bool
"""
return version >= ANSWER
class Solution:
def firstBadVersion(self, n):
"""
:type n: int
:rtype: int
... |
73f915517faed6cadb3996bd976d96e2542a1260 | burakbayramli/books | /Python_Scripting_for_Computational_Science_Third_Edition/py/regex/introre.py | 1,889 | 3.5625 | 4 | #!/usr/bin/env python
import re
# make some artificial output data from a program (just for testing):
sample_output = """
t=2.5 a: 1.0 6.2 -2.2 12 iterations and eps=1.38756E-05
t=4.25 a: 1.0 1.4 6 iterations and eps=2.22433E-05
>> switching from method AQ4 to AQP1
t=5 a: 0.9 2 iterations and eps=3.78796E-05
... |
7bd7d698e7e5f7a0779abaac09e5933e3ae7e59b | sandeepkumar8713/pythonapps | /08_graph/06_strongly_connect_component.py | 2,945 | 4.21875 | 4 | # https://www.geeksforgeeks.org/strongly-connected-components/
# Question : Given a graph with N nodes and M directed edges. Your task is to complete the
# function kosaraju which returns an integer denoting the no of strongly connected components
# in the graph. A directed graph is strongly connected if there is a pat... |
0aa149ee7da2c99e37be853763dc71a93787f0e2 | AlfredPianist/holbertonschool-higher_level_programming | /0x0B-python-input_output/3-to_json_string.py | 433 | 3.96875 | 4 | #!/usr/bin/python3
# -*- coding: utf-8 -*-
"""3-to_json_string
This module has the function to_json_string which returns the JSON
representation of an object.
"""
import json
def to_json_string(my_obj):
"""Returns the JSON representation of an object as a string.
Args:
my_obj (:obj:): The object to b... |
7c66012a1b6bc7c306a020a7da3bc51d1aa9ece6 | shellfly/algs4-py | /algs4/depth_first_search.py | 1,262 | 3.625 | 4 | """
Execution: python depth_first_search.py filename.txt s
Data files: https: // algs4.cs.princeton.edu / 41graph / tinyG.txt
https: // algs4.cs.princeton.edu / 41graph / mediumG.txt
Run depth first search on an undirected graph.
Runs in O(E + V) time.
% python depth_first_search.py tiny... |
afa81d35577d89c3a4197f6578ae328d69cecb72 | HopeCheung/leetcode | /leetcode-first_time/leetcode53.py | 1,117 | 3.71875 | 4 | class Solution:
def maxSubArray(self, nums):
"""
:type nums: List[int]
:rtype: int
"""
max_num = nums[0]
def judge(nums, max_num):
if len(nums) == 0:
return max_num
if max_num <= 0:
return max(max_nu... |
8ad81d24787e9e5df8f96271721be5636014bac2 | drunkwater/leetcode | /medium/python/c0340_740_delete-and-earn/00_leetcode_0340.py | 1,194 | 3.828125 | 4 | # DRUNKWATER TEMPLATE(add description and prototypes)
# Question Title and Description on leetcode.com
# Function Declaration and Function Prototypes on leetcode.com
#740. Delete and Earn
#Given an array nums of integers, you can perform operations on the array.
#In each operation, you pick any nums[i] and delete it to... |
9e012c695b4469202e3a1c9d94c3c4fc20e8a7b7 | AudreyChigarira/Group8-OOP.py | /petclass.py | 834 | 3.640625 | 4 |
#create Class o Instance Variables: ๏ง pet_name is of type string, ๏ง breed is of type string, ๏ง age is of type int, ๏ง appointment of type Appointment
class pet():
def __init__ (self, pet_name, breed, iAge, owner): #def __init__ (self, pet_name, breed, iAge, appointment?):
self.pet_name = pet_name
... |
7829693777b0e59bff40fe587184d0608ea27119 | potirar/CodigoPythonDSI | /Comandos/exemplo4(Estrutura condicional).py | 329 | 4.28125 | 4 | # Estutura se e senรฃo (if or else)
nota1 = float(input("Digite a nota 1:"))
nota2 = float(input("Digite a nota 2:"))
nota3 = float(input("Digite a nota 3:"))
media = (nota1+nota2+nota3)/3
if media > 7:
print('Vocรช passou')
elif media == 7:
print('Passou arrastado')
else :
print('Infelizmente, vocรช nรฃo pass... |
16553922f9f2cf67bb7aad8c2d739b08081c14fa | Gugunner/python-challenge | /PyPoll/main.py | 2,615 | 3.515625 | 4 | # TODO GET TOTAL NUMBER OF VOTES
# TODO GET LIST OF CANDIDATES
# TODO GET PERCENTAGE OF VOTES PER CANDIDATE
# TODO GET NUMBER OF VOTES PER CANDIDATE
# TODO GET WINNER OF ELECTION
import os
import csv
# declare all global variables
elections = { 'candidates': {} }
csvPath = os.path.join('Resources', 'election_data.csv')... |
c1a91dd53dc15fe46f8cebab2af6c821e2030629 | rifatmondol/Python-Exercises | /009 - [Strings] Data Por Extenso.py | 533 | 4 | 4 | #009 - Data por extenso. Faรงa um programa que solicite a data de nascimento (dd/mm/aaaa) do usuรกrio e
#imprima a data com o nome do mรชs por extenso.
#Data de Nascimento: 29/10/1973
#Vocรช nasceu em 29 de Outubro de 1973.
meses = ['Janeiro', 'Fevereiro', 'Marรงo', 'Abril', 'Maio', 'Junho', 'Julho', 'Agosto', 'Setembro'... |
b2b0ef0e5f9055632008d88784e9a802cee84a9c | rickyriosp/MITx-6.00.2x-Introduction-to-Computational-Thinking-and-Data-Science | /Quiz/midterm_problem3.py | 944 | 3.84375 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Aug 12 11:47:12 2018
@author: nas7ybruises
"""
def greedySum(L, s):
""" input: s, positive integer, what the sum should add up to
L, list of unique positive integers sorted in descending order
Use the greedy approach where you find the largest mult... |
d48b7136bc7481b4a71d285ed40d710cc0d07006 | aotalento/python-challange | /pybank/.ipynb_checkpoints/Main-checkpoint.py | 2,588 | 3.59375 | 4 | # import dependants
import csv
import os
# add file path
BankData = os.path.join("budget_data.csv")
# Set list variables
Profits = []
MonthlyChange = []
Date = []
# Set variables to zero
MonthCount = 0
TotalProfits = 0
Change = 0
StartingProfit = 0
with open(BankData, newline = "") as csvfile:
csvreader = csv.r... |
9e187db8632740055b7af48f8e00e62fba5ac349 | bbuchake/learn-python | /Candy and Pie Store/candystore.py | 641 | 3.90625 | 4 | candyInStore = ["Snickers", "Kit Kat", "Sour Patch Kids", "Juicy Fruit", "Sweedish Fish", "Skittles", "Hershey Bar", "Skittles", "Starbursts", "M&Ms"]
allowance = 5
selectedCandy = []
#for i in range(len(candyInStore)):
#print("[" + str(i) + "] " + candyInStore[i])
for candy in candyInStore:
print ("[" + str... |
28308ec2f781dd9db5644a23690bd3659ca3c806 | tdkumaran/python-75-hackathon | /String/stroperation4.py | 500 | 4.09375 | 4 | #split string
s="am daily coding in Python, so, I develoope my knowledge"
print(s.split(","))
#join list of string
date="14"
month="12"
year="2018"
today="-".join([date,month,year])
print(today)
#case converting
print(s.capitalize())
#return first letter capitalize
print(s.lower())
#print all uppercase to lowercase
... |
43769796453af972a5e03580d2056fe4e28408f4 | Andressa-Anthero7/Exercicios-Python | /Desafio-97.py | 349 | 3.78125 | 4 | #Faรงa programa que tenha uma funรงรฃo chamada escreva(),
# que receba um texto qualquer e mostre uma mensagem
# com tamanho adaptรกvel
#Autora:Andressa Cristina Anthero
def escreva(frase):
tam = len(frase) + 4
print('~'*tam)
print(f' {frase}')
print('~'*tam)
frase = str(input('E... |
30cbc0b09c88c599b493f7b796853dee33aaf7c3 | twterryh/statistical_analysis | /NumpyScipy/05_norm(length).py | 315 | 3.671875 | 4 | import numpy as np
# vector length : norm of vector
# ||a||
# = root a.T * root a
a = np.array([1,3])
print(np.linalg.norm(a))
# 3.1622776601683795
# ๋จ์ ๋ฒกํฐ (unit vector) : ๊ธธ์ด๊ฐ 1 ์ธ ๋ฒกํฐ
# ex) [0,1], [0,1], [1/np.sqrt(2),1/np.sqrt(2)]
a = np.array([0,1])
print(np.linalg.norm(a))
|
b905432dbcca308d3624de9cc0194222a2fbe72d | BramvdnHeuvel/Batteryboys | /classes/house.py | 1,010 | 4.03125 | 4 | class House:
"""
The house class represents a house in the smart grid. Each house has an id,
an x and y coordinate which determine the location of the house in the grid,
and an output.
"""
def __init__(self, id, x, y, output):
self.id = id
self.x = x
self.y = y
... |
000d3e67d07fd3cb072c9daae86945ea891af873 | Anastasiya999/Python | /zestaw6/test_fracs.py | 1,982 | 3.6875 | 4 | import unittest
from fracs import *
class TestFracs(unittest.TestCase):
def setUp(self):
self.zero=Frac(0,1)
self.negative=Frac(-5,7)
self.positive=Frac(3,4)
self.need_simplify=Frac(5,10)
def test_print(self):
self.assertEqual(str(self.need_simplify),"1/2")
sel... |
adc7e738ba1adba1ce1e67b2241b7c64e3668c4a | joaomlneto/tuenti-challenge-2020 | /07/main.py | 1,388 | 3.546875 | 4 | #!/usr/bin/env python3
import argparse
import icu
import os
import re
import sys
parser = argparse.ArgumentParser(description="Tuenti Challenge 2020 - Problem 07")
parser.add_argument("-f", "--file", dest="filename", type=str,
help="the text file to analyze", required=True)
args = parser.parse_arg... |
f068cf0ac9571a39aa5dd868d3f6d3e5eb7609b6 | joreakshay/python | /SimplePrograms/List/list.py | 258 | 3.984375 | 4 | def addelement(l1,var):
if type(var)==list :
l1.extend(var)
else :
l1.append(var)
def main():
l1=[1,2,3]
print l1
addelement(l1,4)
print l1
l2=[5,6,7]
addelement(l1,l2)
print l1
if __name__=="__main__":
main() |
cacefab29f4ebd4a312ad416c3963cc4edf19ea2 | jessicagmarshall/machine-learning | /conjugate_priors/Marshall_MSE_GaussianKnownSigma.py | 3,600 | 3.609375 | 4 | #Jessica Marshall
#ECE414 Machine Learning
#Conjugate Priors Programming Assignment
#MSE plots - Gaussian sigma
##########################################
#import libraries
import math
import numpy as np
import matplotlib.pyplot as plt
##########################################
#generate normally distributed observa... |
98c0a69dc1892e8cd61fbb9fe307f4b25a0cb84b | lgc13/LucasCosta_portfolio | /python/practice/personal_practice/ticTacToeV2.py | 896 | 4.21875 | 4 | # ticTacToeGame v2, made by Lucas Costa and Sasha Larson
# started on Feb 26, 2017
# what we need in order to make a tic tac toe game in python
# v2: we will also make it so that we can play against the computer
# finally, we will make this 2D
"""
What we need:
1- Board array
2- Players
a- accept input
3- Rules
4-... |
1dbdeb0ab1e9ac41973b8448a6e993c7b914ae5e | yangzhao5566/go_study | /DesignPatterns/bag.py | 880 | 3.671875 | 4 | """
Bag
"""
class Bag(object):
"""
bag
"""
def __init__(self):
self._items = list()
def __len__(self):
return len(self._items)
def __contains__(self, item):
return item in self._items
def add(self, item):
self._items.append(item)
def remove(self, ite... |
0ee0bb58c02635d4c55e982d1195ab044d761b77 | kotegowder/linkedin_learning_python | /06_class.py | 486 | 3.78125 | 4 | class myClass():
def method1(self):
print("myClass method1")
def method2(self, someStr):
print("myClass method2 " + someStr)
class myAnotherClass(myClass):
def method1(self):
myClass.method1(self)
print("myAnotherClass method1")
def method2(self, someStr):
print("myAnotherClass method2")
def main():
... |
aefaf80ed082b09aedfb6d874233c58f55b64826 | wwoods93/Python_Challenge | /challenge1.py | 722 | 3.75 | 4 | ###################################################################
# Python Challenge Level 1 Solution
# Wilson Woods
# 10/16/19
# Program translates a string where all chars are shifted by a set amount
# In this case shift is +2 (a = c, b = d, etc.)
# increment = [shift amount] & decrement = [26 - shift amount]
#####... |
df36833f719eaa8e9828c69a86d72ee5148ae8f2 | MrHamdulay/csc3-capstone | /examples/data/Assignment_5/chtgen002/question4.py | 1,068 | 3.84375 | 4 | """
Graph of mathematical function
Genevieve Brownyn Chetty (CHTGEN002)
16/04/2014
"""
import math
def main():
function = input("Enter a function f(x):\n")
x=0
y=0
for row in range(10,-11,-1): #-10 to 10 axes limit
for column in range(-10,11,1):
x=column
... |
69331a7c381ccfcf1011036cbc2a4ebe156e3318 | Hafizuddin961/data-science-project1 | /test.py | 293 | 3.578125 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Jun 7 10:19:02 2020
@author: hafizuddin
"""
import pandas as pd
df = pd.read_csv("glassdoor_jobs.csv")
df = df[df['Salary Estimate'] != '-1']
salary = df['Salary Estimate'].apply(lambda x: x.split('(')[0])
salary_hour = salary.find('Per Hour') |
07c424d0d6e51c2469e74073ffa102c06b77cd6b | NR4l3rt0/pcap_netacad | /frequency_histogram.py | 2,010 | 3.984375 | 4 | """
This program will check how many characters there are in a given text file
and will create a histogram from it (if the value is 0, then will be omitted)
"""
from os import strerror
# In this case, we will assume that the text file is in the same directory as the program
def take_txt_name():
out= False
... |
469330e8d9e9ff567f57b8ef3e41445c8c797775 | billxsheng/python | /maps.py | 321 | 3.578125 | 4 | import collections
dict1 = {"day1": "Mon", "day2": "Tues"}
dict2 = {"day3": "Wed", "day4": "Thurs"}
map = collections.ChainMap(dict1, dict2)
print(map)
print('Keys = {}'.format(list(map.keys())))
print('Values = {}'.format(list(map.values())))
print()
for key,val in map.items():
print('{} = {}'.format(key, val))... |
96b581a2b0125ee8a0dc3c70110eb992d49c2f1e | sorttomat/julekalender | /luke4.py | 1,746 | 3.53125 | 4 |
def erPartall(tall):
return tall % 2 == 0
def checkElementInThing(thing, element):
antall = 0
for elem in thing:
if elem == element:
antall += 1
return antall
def numberOfEachLetter(word):
antBokstaver = []
for bokstav in word:
antBokstaver.append(checkElementInThi... |
65fc656cd60ff2b32d80fd1417e43931744b761b | AshokKumarChoppadandi/PythonExamples | /PythonBasics/Basics.py | 12,220 | 3.78125 | 4 | # This is a comment
"""
This are Multi-line comments
"""
# importing the libraries
import sys
import math
import random
import threading
import time
from functools import reduce
"""
print('HELLO WORLD...!!!')
"""
"""
# Primitive DataTypes:
# integers, floats, complex numbers, strings, booleans
# Variable Declarati... |
030b1278003f9f627aba06031631e167af7f33e8 | smriti-ranjan/PythonBootcamp_byFloxus | /EvenOddUsingBitwise.py | 236 | 4.40625 | 4 | #Floxus Python Bootcamp : Assignment - 1
#1. Write a program to check a number is even or odd using bitwise operator?
number = int(input("Enter a number:"))
if number ^ 1 == number + 1:
print('Even')
else:
print('Odd')
|
bcc000176091070d278e3356f25bbc0a1dd04a06 | gurmeetkhehra/python-practice | /list is empty or not.py | 163 | 4.375 | 4 | # 5. Write a Python program to check a list is empty or not.
emptylist = []
print (emptylist)
emptylist =[]
if not emptylist:
print("List is not emptylist.") |
7fdce4352c1a2280eae620d0ba23aaf69eb4656d | mathiasarens/python-test | /BinaryTreeZigzagLevelOrderTraversal.py | 2,124 | 4.125 | 4 | import queue
# Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def zigzagLevelOrder(self, root):
"""
:type root: TreeNode
:rtype
"""
nodes_odd = qu... |
afc1e3ff126c58967bf4306fdfcd8c38bcde97bf | python15/homework | /3/shijiangnan/Three_week_operation.py | 2,824 | 3.65625 | 4 | '''
ๅฐ้ฟๆไผฏๆฐๅญ่กจ็คบ็ไธไธฒๆดๆฐ(ๅฐไบ1ไธ)่ฝฌๆขๆๆ ๅ็ไธญๆ่ดงๅธ่กจ่พพๅผ๏ผๅไฝไธบๅ
:ๆฏๅฆโ1234โ่ฝฌๅไธบ"ๅฃนไป่ดฐไฝฐๅๆพ่ๅ
",โ1001โ่ฝฌๅๆไธบ"ๅฃนไป้ถๅฃนๅ
",ๆฐๅญ็ไธญๆๅฏนๅบ๏ผ้ถ", "ๅฃน", "่ดฐ", "ๅ", "่", "ไผ", "้", "ๆ", "ๆ", "็","ๆพ", "ไฝฐ", "ไป", "ไธ".
'''
num_dir={"0":"้ถ","1":"ๅฃน","2":"่ดฐ","3":"ๅ","4":"่","5":"ไผ","6":"้","7":"ๆ","8":"ๆ","9":"็"}
unit={"0":"ๅ
","1":"ๆพ","2":"ไฝฐ","3":"ไป","4":"ไธ"}
def inputshuzi():
... |
23a36e266e69b03b008b367ff6efa3caa18cea0c | Aeternix1/Python-Crash-Course | /Chapter_8/modules.py | 1,053 | 3.828125 | 4 | #You can store all of your functions in a separate file called a module
#Then you can import the module into your main program
#Import a module you make a file which contains all of your functions
#In the file that you use the functions
#import pizza (should be at the top of the file)
#To call the function you need ... |
415d473399dbe80d9f4729477fcb5ed5b9cffb03 | ygidtu/pysashimi | /src/BamInfo.py | 2,564 | 3.609375 | 4 | #!/usr/bin/env python3
# -*- coding:utf-8 -*-
u"""
Created by ygidtu@gmail.com at 2019.12.06
"""
from typing import Dict, List, Optional
def set_barcodes(barcodes: Optional[List[str]]) -> Dict:
u"""
separate barcodes by its first character to reduce set size
:params barcodes: list or set of barcodes
"... |
10a1c5fe2082916767393ed5d2a86a9552f3d639 | wajahatali987/git-assiment | /Pandas assigment part 1(Cleaning Us-Census Data) by wajahat ali.py | 4,023 | 3.640625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[1]:
# importing libarary
import pandas as pd
import numpy as np
import matplotlib.pyplot as plt
from glob import glob
import re
# In[17]:
# loading data by using glob & loop & concatenation all csv files
files = glob("states*")
us_census = pd.concat((pd.read_csv(file) ... |
3c8451e3733309d614ced4d239cbff65d518905d | rioshen/deliberate-practice | /code-kata/simple_lists/single_list_test.py | 1,128 | 3.671875 | 4 | import unittest
from single_list import SingleList
class ListTest(unittest.TestCase):
def test_single_one(self):
lst = SingleList()
self.assertEqual(None, lst.find("fred"))
lst.add("fred")
self.assertEqual("fred", lst.find("fred").value)
self.assertEqual(None, lst.find("wil... |
1777ead4ef6176ca94a6f7d64cef58e039112f91 | BhargaviSiddipeta/Python | /ICP/icp_3/icp3/websc.py | 1,091 | 3.890625 | 4 | import requests
import urllib.request
import os
from bs4 import BeautifulSoup
#set the wiki page to the link
html_page = requests.get("https://en.wikipedia.org/wiki/List_of_state_and_union_territory_capitals_in_India")
# open the link it for parsing
soup = BeautifulSoup(html_page.text, "html.parser")
# print title of ... |
460103378fd3bc3a56ff679f273f7cf5f2737571 | iamsaib197/Lane_Car_Detection | /lane_car_detection.py | 927 | 3.5 | 4 | import cv2
from cv2 import CascadeClassifier
import numpy
import pandas as pd
cap = cv2.VideoCapture('C:/Users/HP/PycharmProjects/lane_Car_detection/yellow.mp4')
# Trained XML classifiers describes some features of some object we want to detect
car_cascade = cv2.CascadeClassifier('cars.xml')
# loop r... |
e2401614cbc981128a0cbb1c9ebced34e1fd8b22 | Kordisgames/Translater | /one.py | 989 | 4.125 | 4 | print('ะะพัะฐะณะพะฒัะน ะบะพะฝะฒะตััะตั ะธะท ะดะตัััะธัะฝะพะน ัะธััะตะผั');
num = int(input("ะะฒะตะดะธัะต ัะธัะปะพ ะฒ ะดะตัััะธัะธัะฝะพะน ัะธััะตะผะต: "));
# setting
delimiter = 3; # ะพัะฝะพะฒะฐะฝะธะต ัะธััะตะผั ะธััะธัะปะตะฝะธั 1 - 9
#
firstNum = num; # ะกะพะทัะฐะฝัะตะผ ะฟะตัะฒะธัะฝะพะต ะทะฝะฐัะตะฝะธะต ะดะปั
pos1, pos2, answer = 0, 0, '';
# ะะฐะฟััะบะฐะตะผ ัะธะบะป ะฟัะตะพะฑัะฐะทะพะฒะฐะฝะธั ะฒ 3-ั ัะธััะตะผั
while True:
# ... |
e4ed1ae71a4e46ef187d6106431ae94f60cff96f | Aasthaengg/IBMdataset | /Python_codes/p02865/s291039913.py | 106 | 3.640625 | 4 | import math
n = int(input())
if n%2==0:
print(round(((n-2)/2)))
else:
print(round(((n+1)/2)-1)) |
0a2dc71aa14bc2a1d7a341b300ebbbaabbe0c381 | Pin2-jack/Encryption-Decryption | /Encryption.py | 9,073 | 4.53125 | 5 | """
Encrypt Decrypt
Encrypt is a function that takes a string, -message-, as an attribute and will return None.
Encrypt will:
Ask the user to enter a file name. This file should contain pairs of characters and numbers.
Match the characters from -message- to the numbers given in the file.
Save the numbers ... |
d4e430356e13c0140253e7562f03893efc3855bd | skyrocxp/python_study | /exercises8.py | 2,813 | 3.53125 | 4 | # LY-05-for
# ็ฎๅๅพๅฝขๆๅฐ
'''
ๆๅฐไปฅไธๅพๅฝขๅจ่พๅบไธ้ข
*
* *
* * *
* * * *
* * * * *
'''
# ๆนๆก1
for i in range(1,6):
print("* " * i)
print("------ๆ-ๆฏ-ๅ-ไธฝ-็-ๅ-ๅฒ-็บฟ-------")
# ๆนๆก2
for i in range(1,6):
# ๆๅฐไธ่ก
# ๆฏไธ่กๆๅฐๅ ไธชๆๅท,่ท่กๅท็ธๅ
ณ
# ไธ่กๅ
ๆๅฐไธ้่ฆๆข่ก,ไธ่กๆๅฐๅฎๆฏๆข่ก
for j in range(i):
print("* ",end = "")
print()
print("------... |
71e4ba5af603b8091a72628e5ddda7e75638b4ea | retr0rafay/100DaysOfPython | /Day 23 - Turtle Crossing/car_manager.py | 889 | 3.75 | 4 | from turtle import Turtle
import random
COLORS = ["red", "orange", "yellow", "green", "blue", "purple"]
STARTING_MOVE_DISTANCE = 5
MOVE_INCREMENT = 10
class CarManager(Turtle):
def __init__(self):
self.all_cars = list()
self.car_speed = STARTING_MOVE_DISTANCE
def create_car(self):
c... |
9da9a91bb92939dec3da67925279afbf2e95924b | victoriacorreaalves/Curso-Introducao-Ciencia-da-Computacao-com-Python-Parte-1-USP | /semana 1/dezenas.py | 193 | 4.03125 | 4 | # pede um nรบmero para o usuรกrio e retorna o nรบmero da dezena desse nรบmero
n= input("Digite um nรบmero inteiro:")
num= int(n)
d= (num // 10) % 10
print ("O dรญgito das dezenas รฉ", d) |
aa9b7bd421235d55eb0b9f8d3dc5a1250423293d | farazlfc/CP | /Diamond_aka_cherry_pickup.py | 3,591 | 3.859375 | 4 | '''Task Description:
Diamond Mine is your new favorite game . Its map is represented as a square matrix. The board is filled with cells, and each cell will have an initial value as follows:
โข A value โฅ 0 represents a path.
โข A value of 1 represents a diamond.
โข A value of โ1 represents an obstruction.
The basic rules ... |
30887f3afa75ad9429defc270fd6a46e04f58fd6 | ianramzy/old-code | /Counter/counter.py | 263 | 3.921875 | 4 | num = 0
ans = input(str(num)+" Press enter or 'q' to quit...")
while True:
if ans.lower() == 'q':
break
else:
num = num + 1
if num > 5:
num = 0
ans = input(str(num)+" Press enter or 'q' to quit...")
|
46547cae5d0973f64d6895cbb6965bf4d8089043 | marcelopontes1/Estudos-Python-GUPPE | /S5/decimo_nono_programa.py | 369 | 4.375 | 4 | num1 = int(input('Insira um nรบmero: '))
if num1 % 3 == 0 or num1 % 5 == 0:
print('O nรบmero รฉ divisรญvel por 3 OU 5')
if num1 % 3 == 0 and num1 % 5 == 0:
print('O nรบmero รฉ divisรญvel por 3 E 5 ao mesmo tempo')
else:
print('O nรบmero nรฃo รฉ divisรญvel por 3 E 5 ao mesmo tempo')
else:
print('O ... |
c4ccaba26bbcd0f824635ff487158a6bd1621834 | oalawode/ATM_mock_project | /database.py | 3,159 | 3.625 | 4 | # create record
# update record
# read record
# delete record
# CURD
import os
import validate
user_db_path = "data/userRecord/"
def create(user_account_number, first_name, last_name, email, password, opening_balance):
# create a file
# name of file is account number .txt
# add the user details to the fi... |
58447a0a14ea0f5450bf45e39596d46d8eab67ec | viniciusbds/math | /MatematicaDiscreta/relacoes/transitiva.py | 820 | 3.765625 | 4 | #-*-coding: utf-8-*-
'''
Recebe como parรขmetros um conjunto no qual a relaรงรฃo รฉ aplicada e a prรณpria relaรงรฃo.
'''
def transitiva(A, relacao):
for a in A:
for b in A:
for c in A:
if (a,b) in relacao and (b,c) in relacao and not (a,c) in relacao:
return False
... |
b95b06eab0b89ff242d6067cb95adae5e4836877 | jcbwlkr/aoc | /2017/day08/blah.py | 645 | 3.71875 | 4 | def isAnagram(a, b):
tester = list(a)
tested = list(b)
print("Tester: ", tester)
print("Tested: ", tested)
print("testing...")
i = 0
while i < len(tester):
j = 0
while j < len(tested):
print(i,j)
if tester[i] == tested[j]:
if len(tester... |
06cc0d80ff286192a99fea6d499545f9cea1ba01 | jmyket/python_cc | /chapter_9/user_attr.py | 558 | 3.515625 | 4 | from chapter_9_classes import user
class Privileges:
def __init__(self, privileges = []):
self.privileges = privileges
def show_privileges(self):
print(
f"admin privileges: {self.privileges}"
)
class Admin(user.Users):
def __init__(
self, first_name = None, la... |
ac726c28888f7b722782d3d847a255c6efb9b6b6 | maclamont/ProgrammingTests | /PYTHON/ProjectEuler/Ex10_Lamont.py | 792 | 4.34375 | 4 | #! /Users/macl2/anaconda/bin/python -tt
'''
The sum of the primes below 10 is 2 + 3 + 5 + 7 = 17.
Find the sum of all the primes below two million.
'''
import math
def IsPrime(num): # function to check if it is prime or not
rangenum = int(math.sqrt(num))
for i in range(3,rangenum+1,2): # just loop to the s... |
1bee2f9381cc922d172ee7e65912ff8605c2be00 | BryantHuang9/NumberGuessing | /File1.py | 1,657 | 4.03125 | 4 | import random
def compare_num(num, answer, tries):
if tries > 0:
if int(num) == answer:
print("Correct. Congratulations!")
exit()
elif answer == 1:
print("Hint: It is a prime number.")
elif answer == 2:
print("Hint: It is a multiple of 2.")
... |
ec6b2ceba4b412a51ce518fe7a0ca8614560b035 | dongxietest/AIDP-ython | /01Pbase/day04/2019.05.25 WAID1905/PythonBase03/exercise04.py | 1,025 | 3.96875 | 4 | # ็ปไน ๏ผ๏ผใๆๅฐๅฝๆๆฅๅ
# ่ทๅ็จๆท่พๅ
ฅ็ๆฌๆ็ฌฌไธๅคฉๆฏๆๆๅ ๏ผ5
# ่ทๅ็จๆท่พๅ
ฅ็ๆฌๆ็ๆปๅคฉๆฐ๏ผ31
# ๆๅฐๆฌๆๆฅๅใ
start = int(input("่พๅ
ฅ็ๆฌๆ็ฌฌไธๅคฉๆฏๆๆๅ ๏ผ"))
days = int(input("่พๅ
ฅ็ๆฌๆ็ๆปๅคฉๆฐ๏ผ"))
print("ไธ ไบ ไธ ๅ ไบ ๅ
ญ ๆฅ")
# ๆๅฐๅผๅง็็ฉบ็ฝๅ ไฝ
print(" " * 4 * (start -1), sep="",end="")
# ๅฝๅ้ๅ็ๅคฉๆฐ
i = 1
# ๅฝๅ้ๅๅคฉๆฐๅฏนๅบๆฏๆๆๅ
j = start
# ๅคๅฑๅพช็ฏ้ๅๆๆๅคฉๆฐ
while i <= days:
# ๅ
ๅฑๅพช็ฏๆๅฐๅจไธๅฐๅจๆฅ็ๆฐๆฎ
while... |
cef2a59889605c41dbb72ce3b648ae11875aa19b | sahdev-01/Hello-sahdev | /odd or even.py | 186 | 4.375 | 4 | # To find odd or even number entered by a user
number = int(input("Enter a number: "))
if number % 2 == 0:
print(number, "is even number.")
else:
print(number, "is odd number.")
|
d6719d43ca09f6922cc05c7f689323555719bbaf | AdamMcCarthyCompSci/Programming-1-Practicals | /Practical 5/p9p3.py | 599 | 4.25 | 4 | '''
Prompt for positive integer
if input isn't positive
print warning
else
set factorial variable to 1
create for loop where counter starts at 1 and ends at input+1
multiply factorial variable by counter
print factorial answer
'''
integerinput=int(input('Enter an integer to calculate i... |
32e67576ade4556f8d65613c5f4aa002e5cadd3f | gauravtatke/codetinkering | /leetcode/numbercompliment.py | 1,620 | 3.78125 | 4 | #!/usr/bin/env python3
#Given a positive integer, output its complement number. The complement strategy
#is to flip the bits of its binary representation.
#Note:
#The given integer is guaranteed to fit within the range of a 32-bit signed
#integer. You could assume no leading zero bit in the integerโs binary
#represent... |
7f630a40c03ffa7cd35f44f7bae2bacc2aff31dc | Haruho/PythonProject | /Teach/openfile.py | 271 | 3.5 | 4 | #ๆๅผๆไปถ
#็ฌฌไบไธชๅๆฐ'w'ไปฃ่กจๆฐๅปบไธไธชๅๅญๆฏ็ฌฌไธไธชๅๆฐ็ๆไปถ๏ผๅ
ๅซๅ็ผ๏ผๅทฒ็ปๅญๅจ็ๅฐไผ่ฆ็
open('test1.txt','w')
#็ฌฌไบไธชๅๆฐ่ฟๆ'r'-ไป
่ฏปๅๆไปถ
#'r+'ๅฏนๆไปถ่ฟ่กๅ
ๅฎนๆทปๅ ๏ผ่ชๅจๆทปๅ ๅฐๆไปถๅ
ๅฎน็ๆซๅฐพ
|
b1af980db3be4bd5eeaa68893d41dce021819d9a | ff-sherpa/LearningPython | /pothole/potholes.py | 1,329 | 3.640625 | 4 | # potholes.py
# Analyze potnole data to find 10 block section with most potholes.
import csv
import operator
# create dictionary
potholes_by_block = {}
def make_block(address):
''' Rewrite an address to strip address in 1000s (10 blocks)'''
parts = address.split()
num = parts[0]
new = num[:-3] # o... |
73d7bcd07d00a861b875a0db295f14433e088e23 | scaryswe/Chatbot | /Chatbot.py | 1,213 | 3.703125 | 4 | #chatbot Ashraj Grewal cs1.0
import random
def get_bot_response(user_response):
bot_response_happy = ["Great! That's how you belong", "Keep the good times going!", "Good, life is too short to be anything else"]
bot_response_angry = ["Sorry to hear that, take some time to think", "Have a cup of tea!", "Go liste... |
654710f5af7d99df94d195dae23f635a49a8832c | SafetyBits/codebreaker | /affineCipher.py | 2,384 | 3.609375 | 4 | # Affine Cipher
# http://inventwithpython.com/codebreaker (BSD Licensed)
import sys, random, pyperclip
SYMBOLS = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
def main():
message = 'A COMPUTER WOULD DESERVE TO BE CALLED INTELLIGENT IF IT COULD DECEIVE A HUMAN INTO BELIEVING THAT IT WAS HUMAN. -ALAN TURING'
keyA, keyB = 5, 7
... |
56c4d425f231167ce70dd0c70c5de565174985b8 | itsolutionscorp/AutoStyle-Clustering | /all_data/exercism_data/python/hamming/071e786374ec4931bd5d961fefc16ee9.py | 291 | 3.859375 | 4 | """The Hamming distance."""
def distance(string1, string2):
"""Return the number of positions where the symbols are different."""
if len(string1) != len(string2):
raise ValueError(string1, string2)
return sum(1 for sym1, sym2 in zip(string1, string2) if sym1 != sym2)
|
6cc1b36a183bad8b9147033d08638f3789738a53 | Kylin2048/test | /P42_3_17_4_ๆ ผๅผๅ่พๅบ.py | 173 | 3.640625 | 4 | # -*- coding: utf-8 -*-
"""
Created on Wed Mar 24 22:26:28 2021
3.17.4
@author: Qilin Wang
"""
a = eval(input())
b = eval(input())
print("%d้คไปฅ%d็ไฝๆฐๆฏ%d" %(a,b,a%b)) |
5c575aa581708d2b8751a9c9404b8a3c3fc45c1a | sushmita119/pythonProgramming | /programmingInPython/nqt prime.py | 289 | 3.578125 | 4 | def prime(n):
l=[]
for i in range(n+1):
if i>1:
for j in range(2,i):
if i%j==0:
break
else:
#print(i,end=" ")
l.append(str(i))
print(",".join(l))
n=50
prime(n)
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.