blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
326e404d03568049e1667422f555773ecb2c1cd7 | AthaG/Kata-Tasks | /6kyu/VasyaClerk_6kyu.py | 1,295 | 4.15625 | 4 | '''The new "Avengers" movie has just been released! There are a lot of people at the
cinema box office standing in a huge line. Each of them has a single 100, 50 or 25
dollar bill. An "Avengers" ticket costs 25 dollars.
Vasya is currently working as a clerk. He wants to sell a ticket to every single person
in this l... | true |
50bfe95cf2fe7023477c7d1905f33b8ba556d552 | AthaG/Kata-Tasks | /5kyu/Rot13_5kyu.py | 1,258 | 4.75 | 5 | '''ROT13 is a simple letter substitution cipher that replaces a letter with the letter 13 letters after it in the alphabet. ROT13 is an example of the Caesar cipher.
Create a function that takes a string and returns the string ciphered with Rot13. If there are numbers or special characters included in the string, they... | true |
14516ff1d60fb951f12fbf86ecb8723ed3f0a88e | Tanveer132/Python-basics | /FST_03_list.py | 890 | 4.21875 | 4 | #LIST
# l=[1,3,4,5,6]
# #nesting list
# l2=[1,3,4,5,6.6,"hello",t]
# #accessing nesting list
# print(t2[6][2])
# #list operations
# # 1. list.append(value)
# l=["milk","eggs","sugar","Oil"]
# l.append(7)
# print(l)
# #2. list.remove(value)
# l.remove(7)
# print(l)
# #3. list.pop(value)
# item=l.pop()
# print(l)
#... | false |
dc3a319dc4cef21360ac1c9a61f93b39205ee072 | Tanveer132/Python-basics | /FST_04_dict.py | 765 | 4.375 | 4 | #--------------DICTIONARY--------------
# It is an important datatype used in machine learning
#key:value
d={1:"Tanveer", 2:"Akshay" ,3:"Shaheem",1:"Kiran"}
#print dictionary
print(d)
#print type of d
print(type(d))
#access the dictionary using key value
print(d[3])
#update the dictionary
d[4]="Snjana"
print(d)... | true |
f82fd283e547e2a829e7a5027b17d87c867a05e2 | EmIErO/Programming-Puzzles | /inverse_captcha_part_2.py | 821 | 4.15625 | 4 | # Program reviews a sequence of digits (a txt file)
# and find the sum of all digits that match the digit halfway around in the list.
import inverse_captcha
def add_matching_digits(list_of_digits):
"""Calculates the sum of all digits that match the digit halfway around the circular list."""
half_of_list =... | true |
e2a3b42c92a3bee0577c37c825cca6989e4fb694 | EmIErO/Programming-Puzzles | /corruption_checksum.py | 1,042 | 4.4375 | 4 | # Program converts txt file with data to a table (list of lists).
# It calculates the difference between the largest value and the smallest value for each row;
# then it calculates the sum of all of these differences.
def convert_data_to_table(file_name):
"""
Converts txt file with data to a table (list of lists) of ... | true |
f881c10bcc85560274ffbe2870ba498542b0165e | MerinGeorge1987/PES_PYTHON_Assignment_SET-1 | /ass1Q16.py | 918 | 4.1875 | 4 | #!/usr/bin/python
#Title: Assignment1---Question16
#Author:Merin
#Version:1
#DateTime:02/12/2018 5:30pm
#Summary:Write program to perform following:
# i) Check whether given number is prime or not.
# ii) Generate all the prime numbers between 1 to N where N is given number.
#i) Check whether... | true |
da69991eeb394b938db82b5bba25ff87e2240cf8 | MerinGeorge1987/PES_PYTHON_Assignment_SET-1 | /ass1Q10.py | 769 | 4.1875 | 4 | #!/usr/bin/python
#Title: Assignment1---Question10
#Author:Merin
#Version:1
#DateTime:02/12/2018 3:10pm
#Summary:Using assignment operators, perform following operations
# Addition, Substation, Multiplication, Division, Modulus, Exponent and Floor division operations
a=40
b=3
#Addition
res=a+b
p... | true |
1dad42d021d6502da9e9aaa70f073ff2d629bce8 | mindful-ai/oracle-june20 | /day_02/code/11_understanding_functions_and_modules/project_a_new.py | 508 | 4.28125 | 4 | # Project A
# Function based approach
# Program to determine if a number is prime or not
def checkprime(num):
for i in range(2, num):
if(num % i == 0):
return False
return True
# ------------------------------
print("Name: ", __name__)
if __name__ == "__main__":
... | true |
cdc2055c0b0027bc5a660cb082ebcce0d0062931 | rogos01/Practica_11 | /ejercicio4.py | 477 | 4.15625 | 4 | #estrategia descendente o top-down
memoria = {1:1, 2:1, 3:2}
def fibonacci(numero):
a = 1
b = 1
for i in range(1, numero-1):
a, b = b, a + b
return b
def fibonacci_top_down(numero):
if numero in memoria:
return memoria[numero]
f = fibonacci(numero-1)+ fibonacci(n... | false |
bf4ed5e7f04c6e502737a0acb578da4c8bc23120 | Yumingyuan/algorithm_lab | /merge_sort_new.py | 980 | 4.15625 | 4 | def merge(need_sort_list,low,mid,high):
after_sort=[]
index1=low
index2=mid+1
for k in range(low,high+1):
if index1>mid:
after_sort.append(need_sort_list[index2])
index2=index2+1
elif index2>high:
after_sort.append(need_sort_list[index1])
index1=index1+1
elif need_sort_list[index1]<need_sort_list[... | false |
58aec9aef681275f1b0e9af6ca1d2471051ec55b | Yumingyuan/algorithm_lab | /queue_simulate_stack.py | 1,732 | 4.28125 | 4 | # -*- coding: utf-8 -*-
#插入函数insertinqueue确保只有一个队列中有元素
def insertinqueue(queue1,queue2,item):
#当queue1为空,则往queue2的队尾加入东西
if len(queue1)==0:
#加入新加入元素
queue2.append(item)#item相当于栈顶元素
else:#反之queue2为空,则往queue1的队尾加入东西
queue1.append(item)#item相当于栈顶元素
#删除队尾元素函数delete_tail,把非空队列的0-(len-1)元素放入空队列
def delete_tail(queue... | false |
2272d7a3bff348eb8dbee45d842cdcb94424fafe | pricelesspatato/Python-Tutoring | /overview.py | 2,317 | 4.21875 | 4 | import math
def function():
return
def helloWorld():
print("Hello, world!")
def declareVariables():
integerValue = 1
floatValue = 3.999
stringValue= 'abc'
booleanValue = True
return integerValue, floatValue, stringValue, booleanValue
def returnOne():
one = 1
return one
def doM... | false |
0b01166508e91c0412f783f80ddafb9a9e2f529c | jenlij/DC-Week2 | /py108.py | 1,462 | 4.15625 | 4 | # Reading and writing files!
# Reading a file.
# Use the built-in `open` function
hello_file = open('hello.txt')
file_contents = hello_file.read()
print file_contents
# What if it doesn't exit?
boo_error_file = open('no_file_here_buddy.txt')
# (Error will print out)
# Reading line by line
swift = open('swift.txt')... | true |
0924cf9f8a45104532d6fbe5e68a1ccebe60d69d | gl051/tic-tac-toe | /tic-tac-toe.py | 1,871 | 4.21875 | 4 | #!/usr/bin/python
"""
Exercise: Implement a Tic-Tac-Toe game
"""
import grid
import random
class TicTacToe(object):
def __init__(self):
self.grid = grid.Grid()
self.game_over = False
self.players = {0: 'User', 1:'AI'}
def user_pick(self):
self.grid.show()
pos_str =... | false |
6a47887ebe2e5d31c6c2051a1963c27ad3b620f7 | lucasmbrute2/Blue_mod1 | /Extras/Exercicio13_func.py | 547 | 4.125 | 4 | # Faça um programa que tenha uma função chamada maior(), que receba vários parâmetros com valores
# inteiros.
# Seu programa tem que analisar todos os valores e dizer qual deles é o maior.
def maior(num):
maior = 0
if num > maior:
maior = num
return f"O maior valor é {maior}"
while True:
va... | false |
cc55a2975dfd94f3990b64deefba9696999bda10 | lucasmbrute2/Blue_mod1 | /Aula09/Exercicio01.py | 608 | 4.1875 | 4 | # #01 - Crie um programa onde o usuário possa digitar vários valores numéricos e
# cadastre-os em uma lista. Caso o número já esteja lá dentro, ele não será
# adicionado. No final, serão exibidos todos os valores únicos digitados, em ordem
# crescente.
l = []
while True:
valor = int(input("Digite o valor aqui: ")... | false |
e525cba83c896a374ee7554def4c9829abd85ad4 | Indolent-Idiot/All-Assignments-of-Python-for-Everybody-bunch-of-courses- | /Assignment 8.4.py | 1,131 | 4.65625 | 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 ... | true |
59667e5fb7abff4a718cd8c61c20dd392b52ebd1 | ahmadghabar/hangman-game | /hangman.py | 1,733 | 4.28125 | 4 | #I used random
import random
#I made list of words
listofwords = ["python", "turtle", "class", "bored" , "school"]
#This randomly picks one of the words out
secretword = random.choice(listofwords)
#my function
def get_guess():
# this is to make the dashes in the beginning and then be able to update them
dashes = "-... | true |
6cb903321858e364f88275f741520172c27bb2b2 | Pratik-Sanghani/Python-Tutorial | /Strings/stringindetail.py | 1,724 | 4.46875 | 4 | # A string is created by entering text between two single or double quotation marks.
# e.g. create a string with single and double quotes.
string1='python is fun!'
print(string1)
string2="I am programmer"
print(string2)
# python provides an easy way to avoid manually writing "\n" to escape newlines in a string.
# 'cus... | true |
e6f68a02dc5d9ccbc6207a038e8f2874706bb9d2 | shaneleblanc/kickstartcoding | /3.2-functions/activities/3_parameters.py | 2,850 | 4.15625 | 4 | # REMINDER: Only do one challenge at a time! Save and test after every one.
print('Challenge 1 -------------')
# Challenge 1:
# Write the code to "invoke" the function named challenge_1, providing a name.
def challenge_1(name=None):
print('Hello', name, '!')
challenge_1(name='Jack')
print('Challenge 2 --------... | true |
4d6e8c435b308a2a729175425acb252062e4c865 | Alexander-AJ-Berman/password_strength_detector | /main.py | 1,410 | 4.375 | 4 | #!/usr/bin/env python3
"""Strong Password Detector
This script allows the user to input a password and validate its strength. The criteria
for a strong password are as follows:
1. At least 7 characters long
2. Contains both uppercase and lowercase letters
3. Contains at least one digit (0-9)
4. Conta... | true |
a192df6516708dfba48f342e95668abd5b03913e | wizardcalidad/ClassWork | /venv/Cousera/practice.py | 858 | 4.25 | 4 | # x=-2
# # if x == 6 :
# # print('Is 6')
# # print('Is Still 6')
# # print('Third 6')
# # x = 0
# # if x < 2 :
# # print('Small')
# # elif x < 10 :
# # print('Medium')
# # else :
# # print('LARGE')
# # print('All done')
# if x < 2 :
# print('Below 2')
# elif x >= 2 :
# print('Two or more... | false |
1d9d32d24151fe50f28e878e2971d0a796f17f71 | Iongtao/learning-python3 | /learning/class/demo1.py | 1,542 | 4.375 | 4 | # !/usr/bin/env python3
# coding=utf-8
'''
什么是类?
类一个用于模拟生活现实场景的抽象的方法
也是编程中用于面向对象编程的最有效的编程方式
根据类创建的对象称之为实例化
类的概念需要慢慢理解
'''
'''
使用 class 关键字 跟上 类名(首字母需大写):
类的内容 由许多函数 和 属性(变量)构成
在类里面定义的函数 又被称为 方法
类中有一个特殊的方法 名为 __init__() 用于构建实例时传递属性值
self 关键字 指 当前类的实例对象 让构建的实例 可以访问当前类的 属性和方法
类的方法的第一个形参必须是self 但在调用方法的时候 不需要传递self 内部将默认... | false |
ad1fe2b895f91daf1a374f67b7537d38987bc108 | dhimanmonika/PythonCode | /MISC/ArgsKwargs.py | 834 | 4.8125 | 5 | """The special syntax *args in function definitions in python is used to pass a variable number of arguments to a function.
It is used to pass a non-keyworded, variable-length argument list."""
def testify(arg1, *argv):
print("first argument :", arg1)
for arg in argv:
print("Next argument through *arg... | true |
6e87b4af460b3ff05ac2b17091ec6838b677d308 | dhimanmonika/PythonCode | /Regex/FloatNumber.py | 1,136 | 4.34375 | 4 | """You are given a string .
Your task is to verify that is a floating point number.
In this task, a valid float number must satisfy all of the following requirements:
Number can start with +, - or . symbol.
You are given a string .
Your task is to verify that is a floating point number.
In this task, a valid float n... | true |
06d564c2345c3e98843868714ae240798fa705d5 | Rynxiao/python3-learn | /basic/dict.py | 528 | 4.25 | 4 | #!/usr/bin/env python3
# dict/map
d = { 'Michael': 95, 'Bob': 75, 'Tracy': 85 }
print('dict Michael', d['Michael'])
# insert
d['Adam'] = 78
print('after append', d)
# overwrite
d['Jack'] = 90
print('before overwrite', d)
d['Jack'] = 88
print('after overwrite', d)
# is In dict
print('Thomas is in dict?', 'Thomas' i... | false |
2da803123991c041b313d2b768498a081ca50a09 | ajaysharma12799/Learning-Python | /Control Flow/app2.py | 1,203 | 4.65625 | 5 | ####################################################
# Loops
"""
Note :- There are 3 Type of Loop
1. For Loop
2. Nested Loop
3. While Loop
Note :- There are Another Variant of Each Loop's With Else Statement Also.
"""
# 1. For Loop
for number in range(3): # By Default Start From 0 and Exclude Last Index
print... | true |
3759298271ba14be498fc9c68bc8bde2326f5e8b | ManasveeMittal/dropbox | /Python/Python_by_udacity/renaming_files.py | 772 | 4.3125 | 4 | #--------PSEUDO CODE________//
#define directory(s) name and path
#define selection criteria for files
#point to the directory(s)
#specify renaming criteria
#enclose file names into a list
#specify replacemnt criteria into a function
#loop over the file names
#execution the name changes
#again add the changes into a l... | true |
57d939f3223a18365ed4428d759156408e2860af | ManasveeMittal/dropbox | /Python/Python_by_udacity/regEx.py | 310 | 4.15625 | 4 | import re
str = 'an example word:cat!!'
match = re.search(r'word:\w\w\w',str)
print (match)
# match = re.search(r'word:\w\w\w', str)
# # If-statement after search() tests if it succeeded
# if match: print ('found', match.group()) ## 'found word:cat'
# else:print( 'did not find')
| false |
25f06472a39a3a3000f07a2e574d89336dec11a8 | ManasveeMittal/dropbox | /DataStructures/DataStructureAndAlgorithmicThinkingWithPython-master/chapter06trees/BSTToDLLWithDivideAndConquer.py | 2,507 | 4.125 | 4 | # Copyright (c) Dec 22, 2014 CareerMonk Publications and others.
# E-Mail : info@careermonk.com
# Creation Date : 2014-01-10 06:15:46
# Last modification : 2008-10-31
# by : Narasimha Karumanchi
# Book Title : Data Structures And Algorithmic Thinking With Python
# Warranty ... | true |
c0225a37853adb520d9bd9487733599e3a2c3ed3 | ManasveeMittal/dropbox | /Python/python_algo_implement/picking_numbers.py | 1,761 | 4.15625 | 4 | '''
Given an array of integers, find and print the maximum number of integers you can select from the array such
that the absolute difference between any two of the chosen integers is <= 1.
Input Format
The first line contains a single integer, n, denoting the size of the array.
The second line contains space-separa... | true |
3bb73de814a44708f6b12cb5ce294c9545b04201 | dsoloha/py | /Lab04/sdrawkcab-dsoloha.py | 322 | 4.3125 | 4 | # Backwards-izer
# Dan Soloha
# 9/12/2019
word = input("Welcome to the Backwards-izer! Enter the word you would like to make backwards. Press \"enter\" at any time to exit. ")
while word != "":
reversed_word = list(reversed(word))
reversed_word = "".join(reversed_word)
word = input(f"{reversed_wo... | true |
1cbf888fa258e090228375c88eb20e504d1df0fe | akshatakulkarni98/ProblemSolving | /DataStructures/adhoc/employee_importance.py | 1,934 | 4.28125 | 4 | """
You are given a data structure of employee information, which includes the employee's unique id, their importance value and their direct subordinates' id.
For example, employee 1 is the leader of employee 2, and employee 2 is the leader of employee 3.
They have importance value 15, 10 and 5, respectively. Then emp... | true |
519a13c91aaa73900cd8ce09e618848e8d089fef | Hadiyaqoobi/NYUx | /evennumbers.py | 398 | 4.3125 | 4 | """
Description
Write a program that reads a positive integer n, and prints the first
n even numbers.
For example, one execution would look like this:
Please enter a positive integer: 3
2
4
6
"""
import math
print("Please enter a positive integer: ")
number = int(input())
for x in range (number + (n... | true |
c4daced112e6845e3a7a6ca529dfd8b06a4a2f2b | Hadiyaqoobi/NYUx | /maxabsinlst.py | 616 | 4.28125 | 4 | """
Implement function max_abs_val(lst), which returns the maximum absolute
value of the elements in list.
For example, given a list lst: [-19, -3, 20, -1, 0, -25], the function
should return 25.
The name of the method should be max_abs_val and the method should take one parameter which is the list of values to test.... | true |
086fe78bd37a92f327e10430caf6635d3f474d5e | skykdg12/Inflean-Python | /chapter03_02.py | 1,224 | 4.34375 | 4 | # chapter03_02
# special method(magic method)
# 파이썬 핵심 -> 시퀀스(sezuence), 반복(iterator), 함수(functions), class
# 클래스안에 정의할 수 있는 특별한(built in) 메소드
# 클래스 예제2
# 벡터(x,y) (5,2)
# (10,3) * 5 = (50,15)
class Vector(object):
def __init__(self, *args):
'''
Create a vector, example : v = Vector(5, 10)
... | false |
800882163959ab906f62318b269f18a2f12e4e5c | gitcodes/SortingAlgorithms | /Bubblesort/BubbleSort.py | 571 | 4.1875 | 4 | #---------------------------------------------------
#
# Bubble Sort In python
#
#---------------------------------------------------
def bubble_sort(collection):
length = len(collection)
for i in range(length-1, -1, -1):#range(length-1, -1, -1)
for j in range(i):#range(1, i)
if collection[... | false |
39d6c64e73affacc14c0ec0f87f33c547d3f80ed | twitu/bot_programming | /movement_cost.py | 2,858 | 4.28125 | 4 | import random
import math
def linear_cost(scale=1):
"""
Manhattan distance, only linear movement is allowed
Args:
start (int, int): x and y coordinates of start point
end (int, int): x and y coordinates of end point
scale (int): scale of one step
Returns:
Ret... | true |
75e29eca8678e26edc74b1fb6046214a89d666ca | farhana13/python | /tup.py | 1,848 | 4.375 | 4 | #tuples are unmodified lists
x = ('john', 'sally', 'bob')
print ( x[2])
#constant syntax
y = (1, 9, 2)
print (y)
print (max(y))
for iter in y:
print (iter)
# unlike lists once you create a tuple, you cannt alter its contents-similar to a string.
x = [9,8,7]
x[2] = 6
print (x)
#things not to do with... | true |
926e88c0edd8d8d3a29f528fba82efc0fd1c838e | jambellops/redxpo | /mitx6.00/creditcode.py | 2,643 | 4.28125 | 4 | ##
## Title: Credit statement
## Author: James Bellagio
## Description: Calculation of Credit Statement assignment for edx mit 6.00 week 2
##
##
##
##
##
##
# def balance_unpaid(balance, payment):
# """ function of remaining balance after payment
# parameter: balance = initial balance
# parameter: pa... | true |
535d4cbb8a14c2b1d5b03d8cd2791a875b3b1c6b | Hacklad/Mygame | /quizgame.py | 1,093 | 4.1875 | 4 | print("Welcome to my computer quiz!")
playing = input("Do you want to play, Yes or No? ")
if playing.lower() != "yes":
quit()
print("Okay! Let's play :)")
score, scored = 0, 0
answer = input("What does CPU stand for? ")
scored += 1
if answer.lower() == "central processing unit":
print('Correct!')
score... | true |
a864a339df5ff230eca56cda8829395e77e28a37 | angela97lin/Sophomore-Year | /hw29-<Lin Angela>/hw29.py | 2,569 | 4.21875 | 4 | #Angela Lin
##pd 06
##HW29
##05=06=13
##Write a Python script that will read in a literary work of appreciable length and print its 30 most frequently occurring words.
##
##General guidelines:
##Place your files in a folder named “hw29-<Last First>”, then compress this folder into a ZIP archive. (no RAR!)
##Upload to... | true |
3889d29dae8dcf030513efa784bd87e19ad6737b | wolf2000/fastcampus | /AhReum_Han.py | 621 | 4.25 | 4 | #글자 수 세기
#특정 문자열을 매개변수로 넣기 매개변수로 넣으면 길이를 반환
#a = 'python is too hard'
#print(a.count(''))
def word_count(word):
word_cnt=word.split(" ")
return len(word_cnt)
print(word_count('python is too hard'))
##search
def search(string,word):
if type(string)==str:
new_string= string.split(" ")
elif type(string)== ... | false |
7a35a83576f488ce9f1f1e239b0d741b6f782ee5 | ofs8421/MachineLearning | /SimpleChat/SimpleChat.py | 2,182 | 4.125 | 4 | import re
prompts = {
"what": "What is a video game?",
"use": "What are video games used for?",
"companies": "what companies make video games?",
"long": "how long have video games been out?"
}
responses = {
"what": "A video game is an electronic game that involves interaction with a user interf... | true |
1490abf534ed1dd6c45ecbd2bac1d092c53c6690 | RaihanHeggi/pythonProgramChallenge_40 | /Second Challenge (Miles Per Hour Conversion App)/Miles Per Hour Conversion App.py | 303 | 4.125 | 4 | print("Welcome to the MPH and MPS Conversion App\n")
#getting MPH value
milesPerHour = float(input('What is your speed in miles per hour: '))
#conversion MPH to MPS and Print it
conversionToMPS = milesPerHour * 0.4474
print("Your speed in meter per second is "+str(round(conversionToMPS, 2)))
| true |
f80bb349a818334a93e74cbc13eb9966f1ab0acb | RaihanHeggi/pythonProgramChallenge_40 | /Fourth Challenge (Right Triangle Problem)/Right Triangle Solver.py | 642 | 4.3125 | 4 | import math
print("Welcome to the Right Triangle Solver App\n")
firstLeg = float(input("What is the first leg of the triangle: "))
secondLeg = float(input("What is the second leg of the triangle: "))
#calculate third leg with pythagorean theorem c^2 = a^2+b^2
thirdLeg = round(math.sqrt(firstLeg**2 + secondLeg*... | true |
d23932c4063ca81ce95f25d8fcf758948f33dbee | iproduct/intro-python | /01-sdp-intro/hello_python.py | 612 | 4.3125 | 4 |
def hello_python(name):
"""
simple function demo
using name as argument
"""
print(f'Hello, {name}!')
def conditional_print(number): # conditional print demo
if number > 2:
print(f"{number} is greater than two!")
elif number == 2:
print(f"{number} is equal to two!")
el... | true |
da6baa041385da08cea4f5c3fcd2e65726eda81a | iproduct/intro-python | /07-up-2021/animals.py | 1,488 | 4.125 | 4 |
class Animal(object):
def __init__(self, animalName):
print(animalName, 'is a animal.')
def make_sound(self):
pass
class Mammal(Animal):
def __init__(self, mammalName):
# super(Mammal, self).__init__(mammalName)
super().__init__(mammalName)
print(mammalName, 'is a... | false |
87ce4989653a6f39744ae712ea68ed9d63ef4e77 | iproduct/intro-python | /01-python-academy-intro-lab/examples.py | 686 | 4.40625 | 4 |
"""Python intro examples"""
def square(x):
"""Squares the argument"""
print(__name__)
return x * x
if __name__ == "__main__":
m = map(square, range(1,5))
m2 = map(square, range(1,5))
for item in m:
print(item)
print(list(m2))
print([it * it for it in map(square, range(1,5))... | false |
ed35cd88762201402e889eb925cff52126b562f2 | Jock2018/LeetCode_Notes | /LeetCode/基础数据结构/剑指offer/LeetCode剑指Offer10-11青蛙跳台阶问题.py | 1,387 | 4.21875 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
时间:2021/9/12 22:08
LeetCode原题链接:https://leetcode-cn.com/problems/qing-wa-tiao-tai-jie-wen-ti-lcof/
"""
# import functools
import functools
from typing import List
# class Solution:
# """解法一:递归"""
#
# def numWays(self, n: int) -> int:
# if n == 0:
#... | false |
b356a833d21fb1db87a254dfb8f243fff94ba7a5 | Jock2018/LeetCode_Notes | /LeetCode/基础数据结构/递归/LeetCode70爬楼梯.py | 1,342 | 4.34375 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
时间:2021/9/12 21:35
LeetCode原题链接:https://leetcode-cn.com/problems/climbing-stairs/submissions/
"""
# import functools
from typing import List
# class Solution:
# """解法一:递归"""
#
# def climbStairs(self, n: int) -> int:
# if n == 1:
# retur... | false |
f1b2372df97f341cee90b42b78653a97aa2d0214 | Jock2018/LeetCode_Notes | /LeetCode/基础数据结构/剑指offer/LeetCode剑指 Offer59I滑动窗口的最大值.py | 2,045 | 4.15625 | 4 | #!/usr/bin/env python
# -*- encoding: utf-8 -*-
"""
时间:2021/4/25 22:38
LeetCode原题链接:https://leetcode-cn.com/problems/hua-dong-chuang-kou-de-zui-da-zhi-lcof/
"""
from typing import List
class Solution1:
"""暴力解"""
def maxSlidingWindow(self, nums: List[int], k: int) -> List[int]:
if not nums or k == 1:... | false |
78f22d692251e798a4ef6485381b86609140dfe9 | JonArmen/Python_kurtsoa | /07-ejercicios/ejercicio1.py | 437 | 4.34375 | 4 | """
Ejercicio1.
- Crear variables: una "pais" y otra "continente"
- Mostrar su valor por pantalla (imprimir)
- Poner un comentario diciendo el tipo de dato
"""
pais = "España" # string
continente = "Europa" # string
year = 2021 #integer
print(f"El país que vamos a mostrar es {pais}")
print(f"El continente... | false |
269ebcd1231bbfc25e64ec016931a8b35fba0715 | engrishmuffin/LPTHW | /ex15.py | 775 | 4.15625 | 4 | from sys import argv
# prompts user to name the file they would like opened.
script, filename = argv
# defines txt by opening the file(name) defined in the argv
txt = open(filename)
# prints the name of the file, and reads the opened txt.
print "Here's your file %r:" % filename
print txt.read()
# closes txt, which was ... | true |
804c3808c9655e4af4b869a393eef7735b2a096a | dylanjackman/cp1404practicals | /Prac_05/hex_colours.py | 523 | 4.15625 | 4 | hex_colours = {"AliceBlue": '#f0f8ff', "Beige": '#f5f5dc', "Brown": '#a52a2a', 'Black': '#000000', 'Coral': '#ff7f50'}
hex_colour = input('Please input either AliceBlue, Beige, Brown, Black or Coral: ')
hex_colour = hex_colour.capitalize()
while hex_colour != "":
if hex_colour in hex_colours:
print(hex_colo... | false |
ee63085a5fd07e4515d7271b8aad5a3238a085bc | Marist-CMPT120-FA19/Patrick-Sach-Lab-5 | /Sentence Statistics.py | 505 | 4.25 | 4 | def sentencestatistics ():
words = input("Please enter a sentance: ").lower() #Input a sentence
number = len(words) #Counts the length of the sentance
print("The number of characters in your sentance is: ", number)
count=len(words.split())#Splits the sentence and counts the words
print("The number o... | true |
de0442782a4904785f306d3059d1666e8428a4d6 | soumyaevan/PythonProgramming | /CSV/FindUser.py | 911 | 4.3125 | 4 | '''
find user For this exercise, you'll be working with a file called users. csv user's last name.
Implement the following function: Each row of data consists of two columns: a user's first name,
and a Takes in a first name and a last name and searches for a user with that first and last name in the file.
If the user i... | true |
c300973f6439df6f9027265f1558d78790b8cfbe | blafuente/self_taught_programmer_lesson | /loop.py | 2,057 | 4.5625 | 5 | # Loops
# There's two different kinds of loops
# - For loops
# - used for iterating: one by one through an iterable like a list or a string
# example:
name = "Brian"
for character in name:
print(character)
shows = ["GOT", "Narcos", "Vice"]
for show in shows:
print(show)
coms = ("A. Developemnt", "Friend... | true |
94e89ffb4dfbfec8b632051d9dcb37a822014930 | freshklauser/_Repos_HandyNotes | /_CommonMethod/ClassDefineBase/IterDefined/squares.py | 1,197 | 4.25 | 4 | # -*- coding: utf-8 -*-
# @Author: KlausLyu
# @Date: 2020-04-09 08:55:08
# @Last Modified by: KlausLyu
# @Last Modified time: 2020-04-09 09:43:54
'''{自定义迭代器}
实现自动迭代平方运算
Tips:
__iter__机制中,__iter__只循环一次,一次循环之后就会变为空
比如,下列测试代码中,如果执行了 print(list(iter_nums)) 之后,
list(iter_nusm)就变为空
'''
class... | false |
ce710998b400ffec9c8f66db8fa3958b3a42174d | bronwyn-w/my_python_code | /dictionaries4.py | 1,704 | 4.4375 | 4 | # Third lesson using python dictionaries
#define a few dictionaries containing information about pets
pet_1 = {
'ownername':'bianca',
'petname':'nemo',
'breed':'clownfish',
'type':'fish',
}
pet_2 = {
'ownername':'xenia',
'petname':'wilson',
'breed':'mutt',
'type':'dog',
}
pet_3 ... | false |
cb65f759b04a644983e34e0988ab7e84ba40a76a | kiriyan1989/Pythonlearn | /17 - expo fun.py | 469 | 4.3125 | 4 | #print(2**3) ## power (expo)
def raise_to_power (base_num, pow_num):
result = 1
for i in range (pow_num):
result = result * base_num
return result
print(raise_to_power(2, 4))
############# Same as above but without the loop#########
def raise_to_power_2 (base_num, pow_num): ... | true |
7427f0e0101c39d1f6397855326f694c3c78d0ff | CalicheCas/IS211_Assignment10 | /load_pets.py | 2,432 | 4.375 | 4 | #! src/bin/python3
# -*- coding: utf-8 -*-
import sqlite3
def load_data(conn, data):
try:
cur = conn.cursor()
cur.execute('SELECT SQLITE_VERSION()')
v = cur.fetchone()[0]
print("SQLite version: {}".format(v))
cur.execute("CREATE TABLE person(id INTEGER PRIMARY KEY, first_... | false |
d67901e609311c9f6a2f190f9884adfa183f8429 | mdfaizan7/google-foobar | /solar_doomsday.py | 2,051 | 4.25 | 4 | # Solar Doomsday
# ==============
# Who would've guessed? Doomsday devices take a LOT of power.
# Commander Lambda wants to supplement the LAMBCHOP's quantum antimatter reactor core with solar arrays,
# and she's tasked you with setting up the solar panels.
# Due to the nature of the space station's outer paneling,... | true |
9d9022808b3c02c0da9a84804ca8746f9724ceb7 | Ze1598/Programming-challenges | /programming_challenges/anagram.py | 2,300 | 4.375 | 4 | #codeacademy challenge
#https://discuss.codecademy.com/t/challenge-anagram-detector/83127
string1 = input('Enter the first expression:') #string input 1
string2 = input('Enter the second expression:') #string input 2
#calculate factorial
def result_fact(x):
fact = 1
for x in range(x,0,-1):
fact *= x
... | true |
e252b4dd9558d7c010daa745f546fb7fefd8f411 | endrewu/Coursework | /INF3331/INF3331-Endre/week3/flexcircle.py | 1,148 | 4.15625 | 4 | #!/usr/bin/env python
from math import pi, sqrt
class FlexCircle(object):
def __init__(self, radius):
self.radius = radius
def set_radius(self, r):
if r < 0:
print "An error occured, a circle can not have a negative radius"
self.radius = 0
return
self._radius = r
self._area = pi*self.radius*self.r... | true |
c094d81e6696ed07fa7fa205d5ec234341983497 | wuxu1019/leetcode_sophia | /medium/math/test_866_Prime_Palindrome.py | 973 | 4.3125 | 4 | """
Find the smallest prime palindrome greater than or equal to N.
Recall that a number is prime if it's only divisors are 1 and itself, and it is greater than 1.
For example, 2,3,5,7,11 and 13 are primes.
Recall that a number is a palindrome if it reads the same from left to right as it does from right to left.
Fo... | true |
7dcac48ffa685cf54d1cba6c294fd826b40877fd | wuxu1019/leetcode_sophia | /medium/tree/test_114_Flatten_Binary_Tree_to_Linked_List.py | 1,354 | 4.28125 | 4 | """
Given a binary tree, flatten it to a linked list in-place.
For example,
Given
1
/ \
2 5
/ \ \
3 4 6
The flattened tree should look like:
1
\
2
\
3
\
4
\
5
\
6
click to show hints.
... | true |
0b48aef0261b71afc265826b3678885bc37ac1a3 | wuxu1019/leetcode_sophia | /easy/focus/479_Largest_Palindrome_Product.py | 887 | 4.125 | 4 | """
Find the largest palindrome made from the product of two n-digit numbers.
Since the result could be very large, you should return the largest palindrome mod 1337.
Example:
Input: 2
Output: 987
Explanation: 99 x 91 = 9009, 9009 % 1337 = 987
Note:
The range of n is [1,8].
"""
ass Solution(object):
def l... | true |
ddd52432f09dc65f5365b40d21ad3792c49db924 | wuxu1019/leetcode_sophia | /dailycoding_problem/encode_decode_string.py | 1,178 | 4.28125 | 4 | """
Good morning! Here's your coding interview problem for today.
This problem was asked by Amazon.
Run-length encoding is a fast and simple method of encoding strings. The basic idea is to represent repeated successive characters as a single count and character. For example, the string "AAAABBBCCDAA" would be encode... | true |
cfd4ee6cfdc320df10f790871394c1e2fc5196d8 | wuxu1019/leetcode_sophia | /medium/dp/test_376_Wiggle_Subsequence.py | 2,097 | 4.125 | 4 | """
A sequence of numbers is called a wiggle sequence if the differences between successive numbers strictly alternate between positive and negative. The first difference (if one exists) may be either positive or negative. A sequence with fewer than two elements is trivially a wiggle sequence.
For example, [1,7,4,9,2,... | true |
ba514039dc374ed5c25908eeba8070664d912c3f | guyhill/ellipses | /ellipses.py | 2,564 | 4.21875 | 4 | import math
import matplotlib.pyplot as plt
import sys
x=0
y=1
dt = 0.0001 # small time interval
# mode selection
if len(sys.argv) < 2:
mode = "3d"
else:
mode = sys.argv[1]
if mode == "3d":
pow = 3
max_orbits = 1
vmin = 5
vmax = 13
elif mode == "2d":
pow = 2
max_orbits = 5
vmin =... | true |
afbabf9a36378f280dd5e1136227d4e84ba9e62a | Arnaav-Singh/Beginner-code | /Upper case- lower case.py | 292 | 4.4375 | 4 | # To enter any character and print it's upper case and lower case
x = input("Enter the symbol to be checked: ")
if x >= 'A' and x <= 'Z':
print(x ," is an Uppercase character")
elif x >= 'a' and x <= 'z':
print(x , "is an lower case character")
else:
("Invalid Input")
| true |
a63a965abf66c2845ca93c5cddf2aa9fa927c1ba | Goodmanv4108/cti110 | /P4HW2_BasicMath_Goodman.py | 1,508 | 4.25 | 4 | #CTI-110
#P4HW2 - BasicMath
#Veronica Goodman
#3/12/2020
#
ans=True
while ans:
#Number One Choice
Number1 = int(input('Enter your first number: '))
#Number Two Choice
Number2 = int(input('Enter your second number: '))
#The sum of the two numbers added, multiplied, and subtration
add_... | true |
dcc90fcfe45c01c426371832fdafcf8c83664cdc | igorsorokin66/CareerCup | /FindIslandInMatrix.py | 1,532 | 4.125 | 4 | __author__ = 'Igor Sorokin'
__email__ = 'igor.sorokin66@gmail.com'
__status__ = 'Completed in O(n)'
'''
Problem:
Given a boolean matrix,
write a code to find if an island of 0's
is completely surrounded by 1's.
Source:
http://www.careercup.com/question?id=5192952047468544
'''
def search(x, y, data):
data[x][y] = ... | false |
11febde5b888da054e2af1788fafe6f301ccc0f1 | adwaitmathkari/pythonSampleCodes | /nQueens_lc.py | 2,590 | 4.15625 | 4 |
from typing import List
class Solution:
"""
1) Start in the leftmost column
2) If all queens are placed
return true
3) Try all rows in the current column. Do following for every tried row.
a) If the queen can be placed safely in this row then mark this [row,
column] as p... | true |
0296a00b6c6c326eb7d83b4a3a15034726180c8d | Cvam27/PyLearn_final | /venv/Programs/functin_new.py | 362 | 4.125 | 4 | # function to add two numbers
def add_numbers(num1, num2):
return num1 + num2
# function to multiply two numbers
def multiply_numbers(num1, num2):
return num1 * num2
number1 = 5
number2 = 30
sum_result = add_numbers(number1, number2)
print("Sum is", sum_result)
product_result = multiply_numbers(number1, num... | true |
4954ee3cdefb1c9ee3e9cde7ce4391b2b7b7ad9a | naghashzade/my-python-journey | /day3-rollercoaster.py | 331 | 4.125 | 4 | print("Wellcome to the Rollercoaster.")
if int(input("Height in cm: ")) >= 120:
age = int(input("Age: "))
if age >= 18:
print("your ticket costs 7$")
elif age < 12:
print("your ticket costs 3$")
else:
print("your ticket costs 5$")
else:
print("you are not allowed to use rolle... | true |
2d0cd4ec7a29b666dd1911a35315b5452caaa7fe | stephsorandom/PythonJourney | /BasicFoundations/Operators/IfElseStatments.py | 1,432 | 4.21875 | 4 | If, Elif, Else Statements
~ Control Flow Syntax in Python use of colons, indentation and whitespace
• This is VERY important and sets Python apart from other programming languages.
if some_condition :
# execute some code
else :
# do something else
elif some_other_condit... | true |
4ab5c52abe748650d998199c83a049176ed51472 | saregos/ssw567homework2 | /TestTriangle.py | 2,426 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Updated Jan 21, 2018
The primary goal of this file is to demonstrate a simple unittest implementation
@author: jrr
@author: rk
"""
import unittest
from Triangle import classifyTriangle
# This code implements the unit test functionality
# https://docs.python.org/3/library/unittest.html ha... | true |
cbed95572fe0f679c0639b10720e1f0726837e43 | suboice114/FirstPythonDemo | /AlgorithmsAndDataStructures/MergeSort.py | 1,510 | 4.1875 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# @Time : 2019/9/2 11:09
# @Author : su
# @File : MergeSort.py
"""归并排序"""
class Person(object):
def __init__(self, name, age):
self.name = name
self.age = age
def __str__(self):
return f'{self.name}: {self.age}'
def __repr__(s... | false |
3bcbe55a3a14754f0622f23f29d6fa2d4233a049 | suboice114/FirstPythonDemo | /AdvancedTutorial/advancedExample1.py | 932 | 4.34375 | 4 | #!/usr/bin/env python
# -*- coding: UTF-8 -*-
# python 面向对象1:类的创建 与 对象
class Employee:
"""所有员工的基类"""
empCount = 0
def __init__(self, name, salary):
self.name = name
self.salary = salary
Employee.empCount += 1
def display_employee(self):
print('Name:', self.name, ", Sa... | false |
aeda4fb358498be512c17e84198fd9f28ec15155 | philipteu/Philpython | /The guessing game.py | 978 | 4.375 | 4 | #The Guessing Game
#Step-by-step to develop a program.
#The guessing game program will do the following:
#• The player only gets five turns.
#• The program tells the player after each guess if the number is higher or lower.
#• The program prints appropriate messages for when the player wins and loses.
i... | true |
a9b0e555dc61e276f652b8884fc36fd504b2cc5b | BhagyashreeKarale/list | /palindrome.py | 1,283 | 4.21875 | 4 | # Code likho jo check kare ki kya list palindrome hai ya nahi.
# Aur print karo “Haan! palindrome hai” agar hai. Aur “nahi! Palindrome nahi hai” agar nahi hai.
#Abhi ke liye iss list ko use kar ke code likh sakte ho:
# name=[ 'n', 'i', 't', 'i', 'n' ]
# rev=name[::-1]
# if rev==name:
# print("It's a palidrome")
... | false |
35bdab241a0abbf63592bb2047d3a081cdd8dd2f | Penzragon/CipherFile | /file.py | 2,403 | 4.21875 | 4 | alphabet = "abcdefghijklmnopqrstuvwxyz"
symbol = "~`!@#$%^&*()_-+=;:'\",.? "
def vigenere(message, keyword):
"""This is a function for decrypting a message
Args:
message (string): message that going to be decrypted
keyword (string): a keyword for decrypting the message
Returns... | true |
7ae2df6791de10590a2bffb773fae99fd9ad2824 | caroling2015/excise_2018 | /test/learn/charpter 1/charpter 1.py | 551 | 4.1875 | 4 | # -*- encoding: utf-8 -*-
# 正则表达式 regular expression
import re
# Match literal string value literal
n = re.match('foo','foo')
if n is not None:
print n.group()
# Match regular expressions re1 or re2
bt = 'bat|bet|bit'
m = re.match(bt,'bat')
if m is not None:
print m.group()
l = re.match(bt,'he bit me')
if l ... | true |
1a21c454f2956a9ca01a8e9df52ec6eb058543da | lcodesignx/pythontools | /lists/names.py | 208 | 4.4375 | 4 | #!/usr/local/bin/python3
# Store a few names in a list then print each name
# by accessing each element in the list, one at a time
names = ['python', 'c++', 'c', 'java']
for name in names:
print(name)
| true |
1c382bc5797fd633b81fe46c8dee98141b4b631d | Yoann-CH/git-tutorial | /guessing.game.py | 1,096 | 4.375 | 4 | #! /usr/bin/python3
# The random package is needed to choose a random number
import random
#Define the game in a function
def guess_loop():
#This is the number the user will have to guess, chosen randomly in betw een 1 and 100
number_to_guess = random.randint (1, 100)
print("I have in mind a number in between 1 an... | true |
1101b5d2be334ff37d8d893697d62a3dec048b8b | DaveTanton/PythonHomework | /RPS.py | 1,340 | 4.125 | 4 | mport random as r
print ("Rock, paper, scissor game")
result = ""
choices = ("rock","paper","scissors","SHOTGUN")
while True: #whats this "error"
computer = choices[r.randint (0,3)]
user=input("\nRock, Paper or Scissors? make your choice :").lower()
if user == "shotgun":
result="STOP CHEATING! TRY AGAIN!!... | false |
b61f2572a06fc16a9636e4f7318da88e8781f5b5 | MohammedSabith/PythonProgramming | /filescore.py | 582 | 4.21875 | 4 | '''Suppose that a text file contains an unspecified number of scores. Write a program
that reads the scores from the file and displays their total and average. Scores are
separated by blanks. Your program should prompt the user to enter a filename.'''
fname = input("Enter the filename : ")... | true |
7298ebdc56b9306a91f8051def636c9aeb5dc898 | dpappo/python-tutorial | /six.py | 1,166 | 4.28125 | 4 | "This is a docstring"
# how do objects, classes, and inheritance work in Python?
# here's a list of functions that are part of every number object
# print(dir(5))
# looking at one of the magic methods aka dunder aka double underscore
print(bool(0))
# classes are the blueprints for objects in python
print(type('a'))
... | true |
c512b2098643ec204c7a5114bf79d8fd023b5f68 | Psp29onetwo/python | /ch3/greetings.py | 702 | 4.34375 | 4 | names_of_my_friends = ['Hiren','Naman','Saumya','Kundan','Srinath']
message = "How are you?"
print(names_of_my_friends[0] +", " + message)#accessing the first element and conctinating the message string variable
print(names_of_my_friends[1] +", " + message)#accessing the second element and conctinating the message s... | false |
7d5b8ea1838103b8bf4c240badad88de7403bed0 | Psp29onetwo/python | /multipleof10.py | 240 | 4.34375 | 4 | multiple_of_ten = int(input("Enter the number and i will tell you that entered number is multiple of ten or not: "))
if (multiple_of_ten % 10) == 0:
print("Number is multiple of ten")
else:
print("Number is not multiple of ten") | true |
39e4603f2c6224a0c12838bd2809545b8825c43e | Psp29onetwo/python | /ch3/list.py | 413 | 4.46875 | 4 | bicycle = ['trek', 'cannondale', 'redline', 'specialized']
#List declartaion and initialization
print(bicycle) #Printing list
print(bicycle[0])#Pulling out the first element of list
print(bicycle[0].title())#printing very first element in list in form of title
'''Indexing the list'''
print(bicycle[-1])#returning... | true |
55d45ee0242d43654400cc5a3288cfed2c07d11d | bicongwang/lintcode-python3 | /40. Implement Queue by Two Stacks.py | 992 | 4.125 | 4 | # Solution 1:
#
# Comment: push(): push element to self._stack1
# pop(): pop element from self._stack2
# it will adjust stack when we invoke pop()
class MyQueue:
def __init__(self):
# do intialization if necessary
self._stack1 = []
self._stack2 = []
"""
@pa... | false |
15f44b114a85890be057b7b467a3590cc18ef28f | BraysonWheeler/Python-Basics | /Functions.py | 821 | 4.15625 | 4 |
#def declares function dont need to declare anynumber
def activity(anynumber):
if (anynumber == 0):
print ("given number is 0")
elif (anynumber > 0):
print ("given number is pos")
else:
print("given numbe is negative")
number = int(input("Enter any number"))
activity(number)
activity(number*-2)
#... | true |
623be520ee39be247a5c1327fb1c0a74942d5c96 | shivang17/learnPythonTheHardWay | /ex18.py | 511 | 4.15625 | 4 | # this one is like the scripts with argv
def print_two(*args):
arg1,arg2 = args
print(f"arg1 : {arg1}, arg2: {arg2}")
# *args is not recommended, instead we can use the following method.
def print_two_again(arg1,arg2):
print(f"arg1: {arg1}, arg2: {arg2}")
# One argument function
def print_one(arg1):
... | true |
d74ad8e8b8c7e04b649401adbb4b2811d9596333 | RithvikKasarla/Udacity-Data-Structures-Algorithms-Nanodegree-Program | /Unscramble Computer Science Problems/Task4.py | 1,345 | 4.21875 | 4 | """
Read file into texts and calls.
It's ok if you don't understand how to read files.
"""
import csv
with open('texts.csv', 'r') as f:
reader = csv.reader(f)
texts = list(reader)
with open('calls.csv', 'r') as f:
reader = csv.reader(f)
calls = list(reader)
if __name__ == '__main__':
incomingtex... | true |
8bae74c76c436768df150474c61e3ce54ec1792e | danrneal/restaurant-menu-app | /models.py | 2,357 | 4.34375 | 4 | """Model objects used to model data for the db.
Attributes:
engine: A sqlalchemy Engine object with a connection to the sqlite db
Classes:
Base()
Restaurant()
MenuItem()
"""
from sqlalchemy import Column, ForeignKey, Integer, String, create_engine
from sqlalchemy.ext.declarative import declarative_ba... | true |
bebdcd816eb674b3aed82fc98a145ea9858ded06 | namhla1986/pythonpractice | /translator_practice.py | 714 | 4.1875 | 4 | def translate(phrase):
translation = ""
for letter in phrase:
if letter.lower() in "aeiou":
if letter.isupper():
translation = translation + "G"
else:
translation = translation + "g"
else:
translation = translation + le... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.