blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string |
|---|---|---|---|---|---|---|
afcdcdd6477fd4c6c20f45f5dd1247c0e3838b07 | hugodiazmarquez/POO_Python | /graficado/Cow_Bull.py | 2,370 | 4.21875 | 4 | """
Create a program that will play the “cows and bulls” game with the user. The game works like this:
Randomly generate a 4-digit number. Ask the user to guess a 4-digit number. For every digit that the
user guessed correctly in the correct place, they have a “cow”. For every digit the user guessed
correctly in the wr... |
9162be2deeab0f293d74dabd4ee02b448e3af287 | shikhasingh1797/Function_Question | /ques_1.py | 174 | 3.953125 | 4 | def eligible_for_vote(age):
if age<=18:
print("not eligible")
else:
print("you are eligible")
age=int(input("enter your age="))
eligible_for_vote(age) |
b7c1eaf3c8318a2c6b0543ae3785019dcdc8ad0a | Epiloguer/ThinkPython | /Chapter 4/Ex_4_3_x/Ex_4_3_5.py | 587 | 4.5625 | 5 | # Make a more general version of circle called arc that takes an additional parameter
# angle, which determines what fraction of a circle to draw. angle is in units of degrees,
# so when angle=360, arc should draw a complete circle.
import turtle
import math
bob = turtle.Turtle()
def polygon(t, length, n):
angle... |
ccf7950b70e82496f7b055515ad8c572e2a9492a | 47AnasAhmed/Class-Assignments | /3.12.py | 264 | 3.859375 | 4 | print("Anas Ahmed")
print("(18B-116-CS),Sec-A")
print("Practice Problem 3.12")
def negative(number):
neg_num= []
for i in number:
if i <0:
neg_num.append(i)
return neg_num
x = negative([1,3,-9,-10,-6,-8])
print(*x, sep="\n")
|
6ee5d60382d89cbaa6a463975b1522c399667704 | Hopw06/Python | /Python_Deep_Dive/Part 1/4.NumericTypes/14.Booleans.py | 904 | 4.34375 | 4 | # bool class is used to represent boolean values.
# the bool class inherits from the int class.
print(issubclass(bool, int))
print(type(True), id(True), int(True))
print(type(False), id(False), int(False))
print(isinstance(True, bool))
print(isinstance(False, bool))
print(isinstance(True, int)) # 1
prin... |
f7148d46665dfd3b3d73e53222d78fee26c6d0e6 | derickdev6/pyprojetcs | /FCCBeginnerKylieYing/guess_number.py | 401 | 3.875 | 4 | import random
def guess(x):
print(f'Guess a number between 0 and {x}')
rnum = random.randint(1, x)
while True:
a = int(input('Try: '))
if a < rnum:
print('Low')
elif a > rnum:
print('High')
else:
print('Good job!')
break
if... |
b5054fa66d4c7189a7c94c3a5a2e83047fa2b724 | toanbui1991/1.dataframe_pandas | /8.filter_pandas.py | 643 | 3.796875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Tue Dec 13 17:20:28 2016
@author: User
"""
import pandas as pd
movies = pd.read_csv('C:/Users/User/Desktop/DataScience/1.dataframe_pandas/data/imdb_1000.csv')
#method
print(movies.head())
print(movies.shape)
#filter the data frame base on one criteria with boolean operation.
lo... |
e246bb5cdc46fe944ebef4fac2cfaa9ac674ca3a | eunice-pereira/Python-practice | /ex8.py | 790 | 4.15625 | 4 | formatter = "{} {} {} {}" #definig variable
#Using format function below, syntax is string.format()
#This allows for multiple substitution and value formatting
#Places one or more replacement fields and placeholders defined by {}
#value inside string.format() can be integer, string, character, variable, floating poi... |
408939f27a5362f767a07bbd1cc3c63b27f34b17 | Nilesh-Thote/t2021-2-1 | /Program-4.py | 715 | 3.859375 | 4 | """Problem-4: Get the total count of number list in the dictionary which is multiple of [1,2,3,4,5,6,7,8,9]
(examples)
input: [1,2,8,9,12,46,76,82,15,20,30]
Output:
{1: 11, 2: 8, 3: 4, 4: 4, 5: 3, 6: 2, 7: 0, 8: 1, 9: 1}"""
a=eval(input("Enter the list: ")) #Asking User to input list.
b={} ... |
7b682674a129ff944f755ca5df4e637264e35c1e | jgadelugo/holbertonschool-machine_learning | /supervised_learning/0x03-optimization/9-Adam.py | 930 | 3.59375 | 4 | #!/usr/bin/env python3
""" Update a variable in place using the adam optimization algorithm """
def update_variables_Adam(alpha, b1, b2, epsilon, var, grad, v, s, t):
""" Update a variable in place using the adam optimization algorithm
@alpha: learning rate
@b1: weight used for the first moment
@b2: w... |
cff2958e660947038d38cf4cf7931197315a0701 | Bit4z/python | /addpython/fgx.py | 222 | 3.859375 | 4 | # Hello World program in Py
import re
list=["dear","dog","dad","design","fghdemr"]
a=input("enter the string=")
for i in range(len(list)):
mt=re.match(a,list[i])
if(mt!=None):
print(list[i])
|
112263376dd848340b58c410ae7eb8a2d05b136b | yusupovbulat/eric-matthes-python-crash-course | /chapter_1_basics/part3/3-2.py | 296 | 3.546875 | 4 | friend_names = ['artem', 'dima', 'kolya', 'valera', 'slava']
message = ' is my freind.'
print(friend_names[0].title() + message)
print(friend_names[1].title() + message)
print(friend_names[2].title() + message)
print(friend_names[-2].title() + message)
print(friend_names[-1].title() + message)
|
8e2447212feb616ceaa8433757a97e1f9c96eeef | Predstan/Lane-Finder | /pipeline.py | 6,244 | 3.8125 | 4 | #importing some useful packages
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
import cv2
import math
def grayscale(img):
"""
Applies the Grayscale transform
This will return an image with only one color channel
but NOTE: to see the returned image as grayscale
... |
8d10340adabde01d3b6117aafaa4325405d1030c | jerryleem412/codemy-SQLite3-Python | /3 - sqlite3_insert_record_into_table.py | 384 | 3.65625 | 4 | import sqlite3
#conn = sqlite3.connect(':memory:') #creates a temp db in memory.
conn = sqlite3.connect('customer.db') #Creates or connects End up with a customer.db file in current directory
#Create cursor
c = conn.cursor()
c.execute("INSERT INTO customers VALUES ('Marry', 'Brown', 'mbrown@yahoo.com')")
... |
5ed1b7165810a96144704db78526c50abeabb1bf | wandeg/utilities | /get_ips.py | 1,580 | 3.65625 | 4 | #Script to get the urls and ip addresses of any url
import urllib2
from BeautifulSoup import BeautifulSoup
import subprocess
import socket
import whois
url=''
print whois.whois(url)
content=urllib2.urlopen(url).read()
soup=BeautifulSoup(content)
url_tags=soup.findAll('a') #get all links in the webpage
print "There ... |
285491a0f28d6053adc7bc3550261f77248f5435 | KimPopsong/CODE_UP | /3321.py | 648 | 3.609375 | 4 | import math
toppingKind = int(input())
s = input().split()
doughPrice = int(s[0])
toppingPrice = int(s[1])
doughKcal = int(input())
toppingKcal = []
for i in range(toppingKind):
toppingKcal.append(int(input()))
toppingKcal.sort()
sumPrice = doughPrice
sumKcal = doughKcal
bestPizza = math.floor(sumKcal / sumPri... |
b868c477dbcb494d982f1fb5efc85a0749247767 | NDjust/python_data_structure | /dummy_LikedList/popMethod1.py | 935 | 3.59375 | 4 | def popAfter(self, prev):
ret = prev.next.data
if self.nodeCount == 1:
self.head.next = self.tail = None
elif prev.next == self.tail:
prev.next = None
self.tail = prev
else:
prev.next = prev.next.next
self.nodeCount -= 1
return ret
def popAt(self, pos):
if... |
03d404b291eda0df7956c966c6edc844441fa744 | tgni/thinkpython | /lists/capitalize_nested.py | 444 | 4.03125 | 4 | #!/usr/bin/python3
"""
begin a word with capital letter
"""
def capitalize_all(t):
res = []
for s in t:
res.append(s.capitalize())
return res
def capitalize_nested(t):
res = []
for s in t:
if isinstance(s, list):
res.append(capitalize_all(s))
else:
re... |
5480b64e3051e292bcca153b38a1e0993b3e30b2 | yongzhuo/leetcode-in-out | /hot/a37_count_and_say.py | 7,307 | 4.0625 | 4 | # !/usr/bin/python
# -*- coding: utf-8 -*-
# @time : 2020/3/31 19:55
# @author : Mo
# @function:
"""38. 外观数列
「外观数列」是一个整数序列,从数字 1 开始,序列中的每一项都是对前一项的描述。前五项如下:
1. 1
2. 11
3. 21
4. 1211
5. 111221
1 被读作 "one 1" ("一个一") , 即 11。
11 被读作 "two 1s" ("两个一"), 即 21。
21 被读作 "one 2", "one 1" ("一个二" , "一个一... |
f7871d2cfa13af83be5fa3ab898e919053a7758a | roushzac/genotype_frequency | /genotype_frequencies.py | 4,108 | 3.671875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Mon Dec 12 14:39:22 2016
@author: Zach
"""
# import whats needed to plot the data
import pylab
import random
import matplotlib.pyplot as plt
# read input file with genotype relative fitness and allele frequencies
inputFile = open("SelctionAgainst_HomoRec.txt","r")
i... |
ed3d0d3e043ad1ef2158dee280d4cf39df63cb21 | DKU-STUDY/Algorithm | /LeetCode/Array/Find_the_Duplicate_Number/6047198844.py | 449 | 3.65625 | 4 | class Solution(object):
def findDuplicate(self, nums):
for i in range(len(nums)):
if nums.count(nums[i])>1 :
return nums[i]
# How can we prove that at least one duplicate number must exist in nums?
# Can you solve the problem without modifying the array nums?
# Can you solve... |
8f49c1f0621d56bbb1bae526e47429d086b6a247 | nathanstuart01/python_practice | /name.py | 602 | 3.5625 | 4 | name = "ada lovelace"
print(name.title())
print(name.upper())
print(name.lower())
first_name = 'Nathan'
last_name = 'Stuart'
full_name = first_name + " " + last_name
print(full_name)
print("Hello, " + full_name.title() + "!")
message = "Hello, " + full_name.title() + "!"
print(message)
print("Python")
print("... |
ebe0a91532dfeb8586ad46076d9238c8e9ee8dd3 | Stymphalian/CSC421_Assignments | /a2/test_logic.py | 1,084 | 3.828125 | 4 | # test_logic.py
import logic as logic
"""
@purpose - Test the logic expression evaluator.
Failed tests will print to the screen with the test number and
the failed expression
Passed tests will NOT print anything.
"""
d = {
"a" : True,
"b" : False,
"c" : True,
"d" : True,
"... |
33867e94b39866f76ca97d4ceb6253bece3550e7 | shermz-lim/project-euler- | /ps5.py | 411 | 3.6875 | 4 | #! python3
# 2520 is the smallest number that can be divided by each of the numbers from 1 to 10 without any remainder.
# What is the smallest positive number that is evenly divisible by all of the numbers from 1 to 20?
import fractions
def compute():
LCM = 1
for i in range(2, 21):
LCM = LCM * i/f... |
4aeec0081864b5c35c98ecf181b662fa59b8ac69 | freebz/Learning-Python | /ch32/ex32-38.py | 2,011 | 3.53125 | 4 | # 협조적 다중 상속 메서드 할당
# 기본: 실제 협조적 super 호출
class B:
def __init__(self): print('B.__init__') # 독자적인 클래스 트리의 가지들
class C:
def __init__(self): print('C.__init__')
class D(B, C): pass
x = D() # 기본으로 가장 왼쪽의 것만 실행
# B.__init__
class D(B, C):
def __init__(self): # 전형적인 형태
... |
1338f9ce2630cc3a4f2c69c75294b37baeb5a559 | msbetsy/morse | /conversion.py | 3,410 | 4.3125 | 4 | """This module allows conversion messages using Morse code."""
from tkinter import messagebox
from data import characters_in_morse
class ConversionManager:
"""This class can be used to encode and decode messages using Morse code."""
def convert_text_to_morse(self, text):
"""Convert text to Morse cod... |
c0f6206b687821a8208cf144b5c8b4e61a817a76 | asierblaz/PythonProjects | /HasierakoAriketak/Ariketa3.py | 333 | 3.609375 | 4 | '''
27/11/2020 Asier Blazquez
3-Zirkunferentzia Baten luzeera eta azalera
'''
print("Programa honek zirkunferentzia baten luzera eta azalera kalkulatzen ditu")
pi = 3.14159
erradioa = float(input("Sartu erradioa "))
luzera = 2 * pi * erradioa
azalera=pi*erradioa**2;
print("Luzera =",luzera,"zm da ")
print("Azalera =... |
acdee6958377f4044f62165ad1f8314b3e08359a | dasfabs/python | /4_Data_Science_Excercise.py | 2,210 | 4.0625 | 4 | #Do the following exercise in a Jupyter Notebook (a GitHub Link would be the best):
import pandas as pd
url = 'https://raw.githubusercontent.com/edlich/eternalrepo/master/DS-WAHLFACH/countries.csv'
df = pd.read_csv (url,error_bad_lines=False)
row_count, column_count = df.shape
print('Basic informations')
print("Number... |
4f36f13c7ded4ad972f3259f5aebac9b5b272edc | carlhinderer/python-exercises | /ctci/code/chapter01/src/one_away.py | 1,034 | 3.890625 | 4 | #
# 1.5 One Away
#
# There are three types of edits that can be performed on strings: insert
# a character, remove a character, or replace a character. Given two strings,
# write a function to check if they are one edit (or zero edits) away.
#
# EXAMPLE pale, ple -> true
# pales. pale -> true
# ... |
faca8c07fab8d6ea7e1c6d5f9c6e435c402d44f8 | apshah007/learnpython | /ex24.py | 1,719 | 4.46875 | 4 | # prints the statement to the screen
print("Let's practice everything.")
# prints the statement to the screen
print('you\'d need to know \'bout escapes with \\ that do:')
# learn to make a new line \n and tab \t
print('\n new lines and \t tabs.')
# here is a poem that is in a string literal
# it has a tab to begin it... |
48b3f11c04e3bc72b325a1dcddb48d726b47722c | Yasmin-Core/Python | /Mundo_1(Python)/importacao(biblioteca)/aula8_desafio20.py | 359 | 3.625 | 4 | import random
aluno1= str(input('Digite o nome do primeiro aluno: '))
aluno2= str(input('Digite o nome do segundo aluno: '))
aluno3= str(input('Digite o nome do terceiro aluno: '))
aluno4= str(input('Digite o nome do quarto aluno: '))
lista= [aluno1, aluno2, aluno3, aluno4]
sorteio= random.shuffle(lista)
print ('A orde... |
f45d84084decdc4dbd23ca9130f27ba69bbcca5f | ILAroy-611/PFUP | /PF/PF-ASSGN - 44.py | 422 | 4 | 4 | #PF-Assgn-44
def find_duplicates(list_of_numbers):
lst=[]
lst1=[]
for x in list_of_numbers:
if list_of_numbers.count(x)>1:
lst.append(x)
for i in lst:
if i not in lst1:
lst1.append(i)
return lst1
#start writing your code here
list_of_number... |
b6604f9b9379719cdd895c5f36e02146a2f5093f | Xuezhi94/learning-and-exercise | /.vscode/数据结构的Python实现/02.数组结构/02.01.一维数组.py | 295 | 3.5 | 4 | score = [87, 66, 90, 65, 70]
total_score = 0
for count in range(len(score)):
print('第{}位学生的分数:{}'.format(count + 1, score[count]))
total_score += score[count]
print('--------------------------------')
print('{}位同学的总分为:{}'.format(len(score), total_score))
|
85142a873e11d93daad121993f1adc14a61cc8e7 | henrique-af/cursoemvideo-python | /Desafio64.py | 288 | 3.578125 | 4 | print('====== DESAFIO 64 ======')
c = 0
tot = 0
n = int(input('Digite um número [999 para parar]: '))
while n != 999:
c += 1
tot = tot + n
n = int(input('Digite um número [999 para parar]: '))
print('Você digitou {} números e a soma entre eles foi de {}.'.format(c, tot)) |
31d3c642ed66b0a5e452a5854e9f9cd0393fe93a | shatheesh171/linked_list | /SinglyLinkedList.py | 3,054 | 4.125 | 4 | class Node:
def __init__(self,value=None):
self.value =value
self.next=None
class SLinkedList:
def __init__(self):
self.head=None
self.tail=None
def __iter__(self):
node=self.head
while node:
yield node
node=node.next
def insertS... |
22d5f6c7064d03330d16588e093f1f2f55b6a6ae | giangduong36/DataScience-Personal | /Coursera_DataScience_Intro/Week1-PythonFundamentals.py | 1,333 | 4.21875 | 4 | # Revisit Python Fundamentals
aTuple = (1, 2, 3)
aList = [1, 2, 3]
aList.append("hello")
print(aList)
print([1, 2] + [3, 4]) # Concatenate list
print([1] * 3) # Repeat lists
# String
x = "This is a string"
print(x + str("!"))
print(x[-1]) # Last element of a string
print(x[-5:-1]) # Slice starting from the 5th el... |
55d36f1e39ea050d90bddebe92513a3938511cfb | dredivaris/data_drop_challenge | /comparison_dict.py | 611 | 3.5 | 4 | from collections import OrderedDict
class ComparisonDict(OrderedDict):
def __eq__(self, other):
if set(self.keys()) != set(other.keys()):
return False
for key in self.keys():
if str(self[key]).strip() != str(other[key]).strip():
return False
return T... |
0455e0b28211b7bd8fd852f8ffdef9018912099f | omrawal/Stable-Matching | /stable_match.py | 3,323 | 3.921875 | 4 | # also known as gale shapley algorithm
# n=int(input("Enter the number of candidates(N): "))
n=5 #test
# n=4 #test
A_B=[]
# print('Enter candidates of group 1:')
# var=list(map(str,input().split()))
# A_B.append(var)
# print('Enter candidates of group 2:')
# var=list(map(str,input().split()))
# A_B.append(var)
A_B=[[... |
eec9d3639a44b16d86b2ff14e81c52ea4385f336 | dheerajdlalwani/PythonPracticals | /Experiment1/code/question2.py | 762 | 4.40625 | 4 | # Question: Write a python program to show output formatting take two values and display them
# Using only one print function amd % operator
print("\n=============================================================\n")
name = input("Please enter your name: ")
age = int(input("Please enter your age: "))
print("\nThis is {... |
7a1fe61c797a70b30d609ba81bc015e51a922115 | heronyang/universities-near-me-in-bay-area | /run.py | 2,191 | 3.90625 | 4 | """This script loads data from a given wiki page for retrieving a list of
universities in the bay area, organizes the data, and displays the ones near a
given location.
"""
import urllib
import googlemaps
import geopy.distance
import pandas as pd
from bs4 import BeautifulSoup
KEY_FILENAME = "key"
OUTPUT_FILENAME = "ou... |
4680899f4900b1c809184606bab1fcfaad0de520 | Thakur-Govind/Vocab-testing-game | /app.py | 2,912 | 3.5625 | 4 | import numpy as np
import pandas as pd
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from random import randint
def auth():
scope = ['https://spreadsheets.google.com/feeds','https://www.googleapis.com/auth/drive']
creds = ServiceAccountCredentials.from_json_keyfile_name('cli... |
b9a29ab7e4089a4c8819b24ebfa594b1bc77a1a3 | zhicheng11/python | /Assignment 1/Sum of numbers.py | 326 | 4.15625 | 4 | # input number
number = int(input("Please enter number: "))
# adding all the numbers
sumofnumber = ((number % 10) + ((number % 100) // 10) + (number // 100))
# printing the final number
if 0 < number < 1000:
print("The sum of your number = {0}".format(sumofnumber))
else:
print("Sorry your number is not accept... |
edbf8027188e2f9f0193d18d9ddf78fcb02553b1 | Edgoldo/python | /basic/multiple_use_python3.py | 7,662 | 3.953125 | 4 | ## https://datawhatnow.com/things-you-are-probably-not-using-in-python-3-but-should/
"""
f-strings (3.6+)
It is difficult to do anything without strings in any programming language and in order to stay sane, you want to have a structured way to work with strings. Most people using Python prefer using the forma... |
8bf03d1a730c932642a96499a53eef60c298c012 | leoGCoelho/Jogo-da-Velha-Minimax | /minimax.py | 1,664 | 3.578125 | 4 | # JOGO DA VELHA - MINIMAX
# AUTOR: LEONARDO COELHO
tab = [' ' for i in range(9)]
#======= FUNCOES ========
#=== TESTE ===
def teste1():
return [' ' for i in range(10)]
def teste2():
return [' ', 'X', 'O', 'X', ' ', 'O', 'X', ' ', ' ']
def teste3():
return ['X', 'O', ' ', 'X', ' ', ' ', ' ', ' ', ' ']
... |
55f097c6e4ac5a5db46350e47b6d4d7068d8ec20 | nucleomis/Archivos_Python | /ejercicios 1er año/ejercicio 2 con diccionarios.py | 2,849 | 4.28125 | 4 | #Se desea almacenar los datos de 3 alumnos.
# Definir un diccionario cuya clave sea el número de documento del alumno.
# Como valor almacenar una lista con componentes de tipo tupla donde almacenamos
# nombre de materia y su nota.
#Crear las siguientes funciones:
#1) Carga de los alumnos (de cada alumno solicitar s... |
7f7ad2bf681111ecaea5071d4e44033a8e888b66 | NishadKumar/leetcode-30-day-challenge | /backspace-string-compare.py | 941 | 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.
# Note that after backspacing an empty text, the text will continue empty.
# Example 1:
# Input: S = "ab#c", T = "ad#c"
# Output: true
# Explanation: Both S and T become "ac".
# Example 2... |
9538c4728f4a46f7e1d35ceec503e370e6505f54 | isaacgrove/lambda-review | /Data_Structures_and_Algorithms/homework/isomorphicStrings.py | 828 | 4 | 4 | def csIsomorphicStrings(a, b):
# takes in two strings a, b
# return boolean: isomorphic
# isomorphic -- preserving order of characters, you can
# do a 1 for 1 replacement of characters to get the new string
# odd --> egg
# hi --> to
# amandita --> anathema
# aaaaa --> aaaaa
if not a... |
b96264d02f509d4df5f01f0e275b0b022ab007bb | Nishadguru/python-sample1 | /15th.py | 291 | 4 | 4 | # 15. Python Program to return true if all characters in the string are alphabetic and there is at least one other character, False.
name = str(input("Enter a name : "))
if name.isalpha():
print("True : It only contains alphabets ")
else:
print("False : It contains specail characters")
|
f35cbaa151008ea37d1de73e3bfb032c82b16d03 | aasthaagrawal/Algorithms_and_Data_Structures | /leetcode/209_Serialize_and_Deserialize_Binary_Tree.py | 1,833 | 3.859375 | 4 | #https://leetcode.com/problems/serialize-and-deserialize-binary-tree/
#Time complexity: O(n)
# Definition for a binary tree node.
# class TreeNode(object):
# def __init__(self, x):
# self.val = x
# self.left = None
# self.right = None
class Codec:
def serialize(self, root):
""... |
3177bc787712977e88acaa93324b7b43c25016f9 | sudharsan004/fun-python | /FizzBuzz/play-with-python.py | 377 | 4.1875 | 4 | #Enter a number to find if the number is fizz,buzz or normal number
n=int(input("Enter a number-I"))
def fizzbuzz(n):
if (n%3==0 and n%5==0):
print(str(n)+"=Fizz Buzz")
elif (n%3==0):
print(str(n)+"=Fizz")
elif (n%5==0):
print(str(n)+"=Buzz")
else:
print(str(n)+... |
d8b2af26d8872247d3cd60edbbf47ad66675cdfd | rdharavath-evoke/python-core-concepts2 | /comprehension/set.py | 538 | 4.09375 | 4 | '''
Set comprehensions are pretty similar to list comprehensions.
The only difference between them is that set comprehensions use curly brackets {}.
'''
input_list = [1,2,3,4,4,5,6,6,6,7,7]
output_set=set()
# Using loop for constructing output set
for var in input_list:
if var%2==0:
output_set.add(var)
pr... |
fad475662f6b5ea2ced27f53930d5249ffd8b1dd | shubhamsinha1/Python | /PythonDemos/2.Data_structure/0.Inbuilt_Data_Structure/4.String/1.StringFormatting.py | 690 | 4.125 | 4 |
firstname="Ravi";lastname='Kumar'
print("First Digit ", firstname[0])
fullname = firstname.__add__(lastname)
#Argument passing
print("My name is %s %s" %(firstname,lastname))
print("My name is {0} {1}".format(firstname,lastname))
print(f"{firstname} {lastname}");
#Escape Sequence
print("Tab involves \t 8 spaces"... |
3f10caa419a2309d3d8c798783ab51998b7c1ab3 | tianniezing/gevpro21 | /week4/extract_sents.py | 2,862 | 3.5625 | 4 | #!/bin/python3
# Program: extract_sents.py
# Author: Tian Niezing
# Date: 02-03-2021
import gzip
import sys
import re
def line_to_sentence_string(inp):
"""This function makes a list of the lines from the \
input file and returns the sentences as a text"""
line_list = []
for line in in... |
dce67e30d7dccd5911adc22ab15fe5547c8877c1 | pavithradheep/pavithra | /tprgm_primearenot.py | 169 | 3.921875 | 4 | n=int(input())
count=0
for i in range(1,n+1):
if (n%i==0):
count=count+1
if(count==2):
print("the no. is prime")
else:
print("the no. is not prime")
|
7dd08bf96babc796aae0ad5d709074217a29f487 | DwiZaki/Dwi-Zaki-Nurfaizi_I0320029_Tiffany-Bella_Tugas4 | /I0320029_exercise 4.1.py | 369 | 3.734375 | 4 | # Operator aritmatika
x = 15
y = 4
# Output: x + y = 19
print ('x + y =', x + y)
# Output: x - y = 11
print ('x - y =', x - y)
# Output: x * y = 60
print ('x * y =', x * y)
# Output: x / y = 3.75
print ('x / y =', x / y)
# Output: x // y = 3
print ('x // y =', x//y)
# Output: x ** y = 50625
print ('x ** y =', x*... |
becbeaf007e6ab473ea2ca25e959dea9c2ae6845 | shimonanarang/Salary-Classification-of-Data-Scientists-based-on-a-survey | /Salary classification_notebook.py | 33,037 | 3.5625 | 4 | #!/usr/bin/env python
# coding: utf-8
# In this notebook, I have analyzed the Machine Learning and Data Science survey with 23860 samples and 50 questions.
#
# This supervised machine learning classification problem has been done through logistic regression.
# Steps involved are:
# 1. Cleaning data and exploring the... |
97788a5fe08f42e04ee2accf7b3e4bed2ebf4e77 | sigilliath/Exercises | /Ex6.py | 362 | 3.9375 | 4 | word = str(input("Podaj słowo: ").lower())
if word[::-1] == word:
print("Słowo %s to palindrom!" % word)
else:
print("Słowo %s to nie palindrom!" % word)
# Udoskonalona wersja
word = str(input("Podaj słowo: ").lower())
print("Słowo %s to palindrom!" % word) if word[::-1] == word[::] else print("S... |
436573c6bb9323c5ba876a79617d54c51c0c548f | DRKn1ght/C-e-Python | /exercicio 08 da lista.py | 712 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Guilherme P. RA: 112679
"""
import math
#Obtenção dos angulos e do módulo
rad1 = float(input("Digite o primeiro ângulo diretor em radianos: "))
rad2 = float(input("Digite o segundo ângulo diretor em radianos: "))
rad3 = float(input("Digite o terceiro ângulo diretor em radianos: "))... |
f4f0c0aeb00ca7aeef895814a25a1cc975217afe | sramyar/algorithm-problems | /staircosts.py | 1,077 | 4.375 | 4 | '''
On a staircase, the i-th step has some non-negative cost cost[i] assigned (0 indexed).
Once you pay the cost, you can either climb one or two steps. You need to find minimum cost to reach
the top of the floor, and you can either start from the step with index 0, or the step with index 1.
Example 1:
Input: cost ... |
2ea1beaea82c3f05425610d36b4eb0a6a67c14bc | j-tyler/learnProgramming | /TheCProgrammingLanguage/python-celsiustofahr-e1p4.py | 178 | 3.5625 | 4 | #!/usr/bin/env python
lower = -20
upper = 100
step = 5
celsius = lower
while celsius <= upper:
fahr = celsius * 9 / 5 + 32
print "%3d %6d" % (celsius, fahr)
celsius += step
|
bece11461c0e26528c4dba8400a1a06f0f022fcb | LeopoldACC/Algorithm | /树/108将有序数组转化为二叉树.py | 611 | 3.6875 | 4 | # Definition for a binary tree node.
class TreeNode:
def __init__(self, x):
self.val = x
self.left = None
self.right = None
class Solution:
def sortedArrayToBST(self, nums):
dic = set()
def partition(l,r):
if l>r:
return None
mid =... |
729a389c68ca312f29ecabe82b9300635f246b16 | r-mishra2126/IT475 | /py36.py | 875 | 4 | 4 | #define python user-defined exceptions
class Error(Exception):
"""base class for other exception"""
pass
class ValueTooSmallError(Error):
"""raised when the input is small"""
pass
class ValueTooLargeError(Error):
"""raised when the input value is too large"""
pass
#our main progr... |
7958323481b43c0b2239388fa6de104fbd37e940 | ivanromanv/manuales | /Python/Edx_Course/Introduction to Programming Using Python/Excercises/W9_ErrorException_E5_Function_concatenar_cadenas.py | 1,100 | 4.28125 | 4 | # Errors and Exceptions Exercise 5
# 0 puntos posibles (no calificados)
# You are trying to concatenate two strings and you need to write a function to perform the task. The function takes two arguments. You do not know the type of the first argument in advance but the second argument is certainly a string. Write a fun... |
92863ea4cdce6c96bfba5c8de9785a00cf2a6f3e | o-bscure/vim-schemes | /eight/boot.py | 1,221 | 3.578125 | 4 | def debug_inf_loop(instructions):
instruction_pointer = 0
instructions_ran = []
acc = 0
def run_instruction(operation, value):
nonlocal acc
nonlocal instruction_pointer
if operation == "acc":
acc += value
instruction_pointer += 1
elif operation ==... |
fb9d5123c6ac8e3247dd44c2151933142ddd0eef | ckasper21/ECEC301 | /Question.py | 2,981 | 3.890625 | 4 | ### Chris Kasper ECE-C301 Lab Week 3 ###
# Declaring Class
class Question(object):
def __init__(self,question=0,answer=0):
self.q=question
self.a=answer
def setText(self,question):
self.q=question
def setAnswer(self,answer):
self.a=answer
def display(self):
print ... |
f8c46dd70d22477f9b6a9b62d490838d014bee14 | Ze-U/DAA | /week3.py | 1,134 | 4.03125 | 4 |
def mergesort(arr,l,r):
if r-l>=1:
m = r-(r-l)//2
mergesort(arr,l,m-1)
mergesort(arr,m,r)
L = arr[l:m]
R = arr[m:r+1]
i = j = 0
k = l
while i<len(L) and j<len(R):
if L[i]<R[j]:
arr[k] = L[i]
i+=1
else:
arr[k] = R[j]
j+=1
k+=1
while i<len(L):
arr[k] = L[i]
k+=... |
be85b58e88bb3f64aa8c62a4ee0294fcc8997806 | secureAImonster/MachineLearning | /BasicML/bitswap.py | 887 | 3.875 | 4 |
def bitswap(bitrow, ideal):
output = ""
count = 1
length = len(bitrow)
i = 0
while True:
if i < length-1:
current_num = bitrow[i]
next_num = bitrow[i+1]
elif i == length-1:
output = output + str(count)
break
if next_num == cur... |
6a2d5435704635a4568419e3cfc2b56759f3ea77 | 21KN/Labs_Python | /Labs_3/3.1.py | 382 | 3.65625 | 4 | # 3.1. Вивести на екран такий рядок:
# n! = 1*2*3*4*5*...*n
# де n – введене з клавіатури число
a = int(input("Введіть число: "))
b = 1
while a > 1:
b *= a
a -= 1
print("Факторіал введеного числа дорівнює:")
print(b)
input("Натисніть enter для завершення") |
642ea6460b96675732be3e64cf5e64b95f302ddb | Dibrary/AMADAS_Flask | /reform_module.py | 226 | 3.875 | 4 |
def tuple_to_list(value): # tuple로 들어온 값을, list로 바꿔서 반환한다.
if value == ():
return None
else:
result = [list(value[i]) for i in range(0, len(value))]
return result[0] |
a8e4850fe2920371991962a6ba56c0d390311215 | dmmceldowney/python-algorithms-examples-notes | /chapter4/ttl.py | 1,484 | 4.4375 | 4 | import turtle as trtl
def drawSpiral(turtle, line_length):
if line_length > 0:
turtle.forward(line_length)
turtle.right(70)
drawSpiral(turtle, line_length-5)
def second():
turtle = trtl.Turtle()
screen = trtl.Screen()
drawSpiral(turtle, 200)
screen.exitonclick()
def dra... |
02bbd7773d4371a39ca6114b823a19f6fb7f3ee8 | techakhil-me/Algo-101 | /2020/graphs/traversal.py | 2,269 | 3.546875 | 4 | #N M
N is total the number of vertices and M is total number of edges
M lines,
a b
a -> b
a <- b
1,2,3,4,5
N 5
M 7
1 2
2 3
3 4
4 5
2 4
2 5
1 5
How to store graph?
graph[N][N];
for i in range(0, M):
graph[b].push(a)
graph[a].push(b)
1 2 5
2 1 3 4 5
3 2 4
4 2 3 5
5 1 2 4
1.4
2. 5 3 2
3. 1 3 2
5. 5
... |
2bb77d1c2ba76f06b76d23e4b697cd103cbb3bfe | cadiente-jomel/data-structures | /Algorithms/Graph Traversing/DFS/dfs.py | 1,601 | 3.734375 | 4 | class DFS:
"""
I used directed graph here
"""
def __init__(self, edges):
self.edges = edges
self.graph_dict = {}
self.visited = []
for start, end in self.edges:
if start in self.graph_dict:
self.graph_dict[start].append(end)
else:
... |
8d27bce56c95a93b1af64c6a91592563489755a2 | baalcota/Python-programs | /RobotArmControl/uploaded to gdrive/Old - add.py | 3,733 | 3.84375 | 4 | import sys
import array as seq
#outstring = [[]]
sequence = [()]
def rotateShoulder(num1, num2):
return
def bendElbow(num1, num2):
return
def twistWrist(num1, num2):
return
def grab(num1, num2):
return
def createSequence():
# sequenceCount = 0
countSeq = int(input("How many separate ope... |
42bdeb874bd045dd3dd456a0c5ea9285b0a78e27 | csula-students/cs4660-fall-2017-nambh | /cs4660/graph/graph.py | 9,452 | 3.984375 | 4 | """
graph module defines the knowledge representations files
A Graph has following methods:
* adjacent(node_1, node_2)
- returns true if node_1 and node_2 are directly connected or false otherwise
* neighbors(node)
- returns all nodes that is adjacency from node
* add_node(node)
- adds a new node to its i... |
69eaa26d515174afe9e6597d46dd5f0dfa03a4d2 | vjasoria/python | /payout.py | 268 | 4 | 4 |
# Hourly pay
Hours = int(input("Please enter the number of hours: "))
RPH = int(input("Please enter the rate per hour: "))
if Hours < 40 :
payout = Hours * RPH
else:
payout = (40 * RPH ) + ((Hours - 40) * RPH * 1.50)
print ("Your Payout is: " +str(payout))
|
3eae88e5744d30ab0ecd1b3850dcfda614f343e5 | tmaria17/learn_python_the_hard_way | /ex5.py | 593 | 4.1875 | 4 | name = 'Zed A. Shaw'
age = 35
height = 74
weight = 180
eyes = 'Blue'
teeth = 'White'
hair = 'Brown'
print(f"Let's talk about {name}. ")
print(f"He's {height} inches tall.")
print(f"He's {weight} pounds heavy.")
print(f"Actually that's not too heavy.")
print(f"He's got {eyes} eyes and {hair} hair.")
print(f"His teeth a... |
131354d98f78cc9102ea504cf48a76bc9cfda802 | Roasters/Practices | /DataStructure_Assignments/RedBlackTree.py | 8,468 | 3.953125 | 4 | """
=========================================
Dept. of Spanish Language and Literature
2012130730 Shim Jaeheon
Data Structure
Final Project
=========================================
"""
class Nil:
def __init__(self):
self.val = None
self.c = 0 # color - 0: blac... |
5eb9cfe8dac8ea073285fcf5b25bd505667ed4ae | sarim26/midpoint-formula- | /main.py | 498 | 3.984375 | 4 | def midpoint():
sarim = input("input x1 ")
shaikh = input("input x2 ")
mohammed = input("input y1 ")
khalil = input("input y2 ")
midpoint1 = (float(sarim)+float(shaikh))/2
midpoint2 = (float(mohammed)+float(khalil))/2
print(str(midpoint1) + "," + str(midpoint2))
QUESTION = inpu... |
33ac892f67fb2f685222f5bffb59aa6e02fd9d3b | andreea200423/06.10.2020 | /Pr.3.py | 140 | 3.5 | 4 | a=int(input("numarul de copii din 1 scoala"))
b=int(input("numarul de copii din a 2 scoala"))
print("in excursie au plecat",a+b+7,"copii") |
2d80715cdaad258c51bd97e494622fdb2efef38d | RanchoCooper/LintCode | /kth-largest-element.py | 1,097 | 3.859375 | 4 | # !/usr/bin/env python
# -*- coding: utf-8 -*-
# @author: Rancho (rancho941110@gmail.com)
# @date : 2016-05-05 13:32:43
# Example
# In array [9,3,2,4,8], the 3rd largest element is 4.
# In array [1,2,3,4,5], the 1st largest element is 5, 2nd largest element is 4,
# 3rd largest element is 3 and etc.
class Solution:
... |
06b94d56612015a482c68429e630c2d6fcbf7809 | apesquero/URI | /PRINCIPIANTE/1051-1100/1060.py | 158 | 3.828125 | 4 | # -*- coding: utf-8 -*-
count = 0
for x in range(6):
valor = float(input())
if valor > 0:
count += 1
print("%d valores positivos" % count)
|
6a152dd4c4e034526f8da80f8177ed82f8f177a7 | gutohertzog/simuladorBD | /actions/operacao_delete.py | 2,093 | 3.609375 | 4 | """
Módulo responsável por realizar as operações de validação e execução com o DELETE.
Sintaxe para criação da table:
DELETE FROM nome_tabela
WHERE coluna = condição;
"""
# from pprint import pprint
def valida_delete(lista_query, termo_meio):
"""
pass
"""
if ve... |
f1d631f92e1fc604f1a62ded00848b60f099c98f | sleevewind/practice | /day01/var_and_datatype.py | 317 | 3.71875 | 4 | # a 我们称之为变量
a = 'hello world'
print('hello world')
print(a)
b = True
print(b)
print((-5) ** 0.5)
# 列表类型
names = ['Andrew', 'Bob', 'Calvin']
# 字典类型
person = {'name': 'Andrew', 'age': 18, 'gender': 'male'}
# 元祖类型
nums = (1,2,3,4,5,6)
# 集合类型
x = {9,'hello','hi',True}
|
7305dd981065df86a9a7d1873418e5d88ff03a8a | spencerjpotts/python-things | /recursive_magic.py | 1,596 | 4.09375 | 4 | """
@file: recursive_magic.py
@author: Spencer j Potts
@Date: 4/18/2019 : 3:00am
@Description: recursive example of guess your number game.
"""
def sortItems(items, iteration=1):
col_1 = []
col_2 = []
col_3 = []
stack = []
stack.append(None)
for x in range(1, 8):
f... |
1fa262760fa241cb55ddc8082ec815ce7f0af631 | khj1259/python_study | /python_study/day2/day2-5.py | 411 | 3.96875 | 4 | #range
#for n in range(0, 3):
# print(n)
#중복 for문, 구구단
for j in range(2, 10):
for i in range(1, 10):
print('{}x{}={}'.format(j, i, j*i))
# comprehension
numbers = [1,2,3,4,5,6,7,8,9,10]
odd_numbers = []
for number in numbers:
if number % 2 == 1:
odd_numbers.append(number)
print(odd_numb... |
f846d29186fb4cf1c57578a589887e42f6eda10a | llovett/dominion-singleplayer | /models/Player.py | 5,546 | 3.53125 | 4 | from Card import TreasureCard, ActionCard, VictoryCard
from random import random
ACTION_PHASE = 0
BUY_PHASE = 1
CLEANUP_PHASE = 2
class Player (object):
def __init__(self,name,game):
self.name = name
self.hand = []
self.active_cards = []
self.discard = []
self.deck = []
... |
780308c8fef0909b7c898b389d6ab38b1705d674 | cgurusm/Challenges | /Hackerrank/WeekOfCode29/bigsorting.py | 152 | 3.84375 | 4 | n = int(input())
unsorted = []
for i in range(n):
unsorted.append(int(input()))
output = sorted(unsorted)
for i in range(n):
print (output[i])
|
747ed1fa36ec69bca34aba8f8462dc04479d70c7 | ecxzqute/python3-basics | /strings.py | 1,449 | 4.46875 | 4 | # Strings in python are surrounded by either single or double quotation marks. Let's look at string formatting and some string methods
name = 'Ja'
age = 31
# CONCATENATION
print("Hi, I am " + name + " and I am " + str(age) + " years old.")
# String Formatting
# POSITIONAL ARGUMENTS
print('Hi, My name is {name} and I... |
6fb7210d87b227d0e47b8e81e913258a8408fd6b | mboehn/aoc2017 | /task05_b.py | 816 | 3.546875 | 4 | #!/usr/bin/env python3
import sys
import math
import csv
import itertools
from pprint import pprint
import func
INPUTFILE = './task05.input'
def main():
with open(file=INPUTFILE, mode='r') as fileinput:
lines = list(map(int, fileinput.readlines()))
steps = 0
index = 0
reading ... |
32c30e583bce42e17fd0592bfa916242aaa2b029 | Sayeem2004/CodingBat | /Python/p118366.py | 117 | 3.5 | 4 | def string_splosion(str):
i = 0
q = ""
while i < len(str):
q = q + str[ :i+1]
i += 1
return q
|
659487d8f66f559c3ab72c1bc2041d97756e41c4 | adamdeprince/safeint | /test_safeint.py | 1,503 | 3.71875 | 4 | from unittest import TestCase
import safeint
class TestInt(TestCase):
def test_10_digits_positive(self):
num = safeint.int('9' * 10)
self.assertEqual(num, 9999999999)
def test_10_digits_negative(self):
num = safeint.int('-' + '9' * 9)
self.assertEqual(num, -999999999)
d... |
749b1d11c4e94bf34ba34c0b5c4f1d02e397ddc8 | yangjiao2/leetcode-playground | /traverse/1466_reorder-routes-to-lead-to-one-node.py | 1,324 | 3.921875 | 4 | # Reorder Routes to Make All Paths Lead to the City Zero
# Add to List
# Share
# There are n cities numbered from 0 to n-1 and n-1 roads such that there is only one way to travel between two different cities (this network form a tree). Last year, The ministry of transport decided to orient the roads in one direction b... |
1ea5a441478d0d9126109200b8b6bf341c215729 | nazzacode/Documents | /Computing/comp_code/leetcode/0001_TwoSum.py | 919 | 3.5 | 4 | """
LeetCode 0001: Two Sum
Question:
Given an array of integers, return indices of the two numbers such that they
add up to a specific target
You may assume that each input hs exactly one solution, and you may not use
the same element twice.
Example 1:
input: numbers = [2,7,11,15], target = 9
output: [0,1]
"""
c... |
f952c2cf9c764faa9ef598365eddc179386fd732 | tejdeep24/Python-Programming | /NumPy Pandas and Matplotlib_case_study_3.py | 3,382 | 3.65625 | 4 |
# coding: utf-8
# In[22]:
#Q1
import pandas as pd
hurricanes_dataset = pd.read_csv('Hurricanes.csv')
#print(hurricanes_dataset)
#Matplotlib
import matplotlib.pyplot as plot
#Bar Graph
year=hurricanes_dataset.Year
num_huricannes=hurricanes_dataset.Hurricanes
plot.bar(year,num_huricannes,color=['b','g'])
plot.show()
... |
831ee328ee89427f35174f20dd28f85ad3245c38 | rwieckowski/project-euler-python | /euler233.py | 520 | 3.734375 | 4 | """
Let <var>f</var><var>N</var> be the number of points with integer
coordinates that are on a circle passing through 00 <var>N</var>00
<var>N</var> and <var>N</var><var>N</var>
It can be shown that <var>f</var>10000thinspthinsp36
What is the sum of all positive integers <var>N</var>thinsplethinsp10
<sup>11</sup> s... |
5634356818c000bf4a6c2d537dbe23248e747c7a | Sk-Aryan/My-Captain_Aryan | /proj1.py | 189 | 4.40625 | 4 | PI = 3.14
radius = float(input('Input the radius of the circle: '))
area = PI * radius * radius
circumference = 2 * PI * radius
print('The area of the circle with radius %d is: %.2f',area)
|
9519f3f70f3ef8b16b277f326c9f5d59ed514c50 | BruceLeonHeart/Partial-Path-Plan | /point.py | 169 | 3.59375 | 4 | #定义点
class Point():
def __init__(self,x,y):
self.x = x
self.y = y
def __str__(self):
return "point x,y : %f \t %f"%(self.x,self.y)
|
cfc58a795208da39d6b17fa7e6a4694f52536593 | dansmyers/IntroToCS-2020 | /Examples/4-Functions/cyoa.py | 2,584 | 4.34375 | 4 | """
A Choose Your Own Adventure Story, featuring functions
CMS 195, Spring 2020
"""
def go_to_house():
print()
print('Congratulations! You made back to your house!')
print('If only there was some way to get inside...')
print()
# Add some more choices
# Each choice corresponds to a fu... |
c8b4b881219b5185819776ebfd8339af19a2ed52 | DeletThis/scrape | /meme.py | 647 | 3.734375 | 4 | import re
INVALID_CHARS = ["'", '"', ',', '.', '!', '?', '(', ')']
class Meme:
"""Stores the name and url of a meme."""
def __init__(self, name=None, url=None):
for ch in INVALID_CHARS:
if ch in name:
name = name.replace(ch, '')
self.name = name
self.url = u... |
257f7a4d1999f4831040f9224984f2a6fd493ff3 | simonhuang/LeetCode | /other_algorithms/binary_search.py | 423 | 3.84375 | 4 | import fileinput
def binary_search(low, high, value, list):
print low, high
if high < low:
return -1
middle = low + (high - low) / 2
if value == list[middle]:
return middle
elif value < list[middle]:
return binary_search(low, middle-1, value, list)
else:
return binary_search(middle+1, high, value, list)... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.