blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
836e57879b40ec2e28484ddfda310704dfe30705 | prise-3d/rawls | /rawls/scene/vector.py | 738 | 4.125 | 4 | """3D vector representation
"""
class Vector3f():
"""3D vector represention constructor
Arguments:
x: {float} -- x axis value
y: {float} -- y axis value
z: {float} -- z axis value
"""
def __init__(self, x, y, z):
"""3D vector represention constructor
... | false |
973dbd6c6cacda7b83e94d537eef50d729701423 | srivenkat13/OOP_Python | /Association _example.py | 892 | 4.25 | 4 | # two classes are said to associated if there is relation between classes without any rule
# be it aggregation , association and composition the object of one class is 'owned' by other class, this is the common point
# In composition they work together but, if one classes dissapears other will also sieze to exist
class... | true |
192e5f3604b9d11c1192fa42aabcc8b0d130d36e | RaghaviRShetty/pythonassignment | /ebill.py | 307 | 4.125 | 4 | # -*- coding: utf-8 -*-
units = int(input(" Please enter Number of Units you Consumed : "))
if(units <=100):
amount = units * 2
elif(units > 100 and units<=200):
amount = units*3
elif(units > 200 and units<=300):
amount = units*5
else:
amount =units*6
print("\nElectricity Bill = ",amount) | true |
80b10f042795a094b4b72b22a3fca9f153ffeb02 | Sinfjell/FOR14 | /Workshops/week_36 - Variables_and_strings/exercise_4.py | 810 | 4.625 | 5 | # -*- coding: utf-8 -*-
"""
@author: Isabel Hovdahl
"""
"""
Exercise 4
Modify this week’s class exercise so that the temperature conversion program
instead converts temperatures from celsius to fahrenheit.
The program should:
- prompt the user for a temperature in celsius
- display the conve... | true |
e51133c3d5c0a4389a342db4d71dd204146e8ac3 | Sinfjell/FOR14 | /Workshops/week_38 - loops/Exercise_1a.py | 1,294 | 4.53125 | 5 | # -*- coding: utf-8 -*-
"""
@author: Isabel Hovdahl
"""
"""
Exercise 1a
Modify the random number generator from last workshop so that the
program now draws multiple random numbers within the given bounds.
The program should now:
- prompt the user for a lower and upper bound, and for the numbe... | true |
0001040e8215e2f2e687d3d162a6c0812bc67d01 | Sinfjell/FOR14 | /Workshops/week_41 - Lists/Exercise_1b.py | 1,332 | 4.4375 | 4 | # -*- coding: utf-8 -*-
"""
@author: Isabel Hovdahl
"""
"""
Exercise 1b:
Write a program that creates a table with the tests scores of students.
The table should be in the form of a nested list where each sublist
contains the tests scores for a spesific student.
The program should:
- prompt... | true |
f482dd234cd32a129e1e19db26dac4bd0cbf9ed3 | Sinfjell/FOR14 | /Workshops/week_37 - Decisions/Exercise_3.py | 1,241 | 4.28125 | 4 | # -*- coding: utf-8 -*-
"""
@author: Isabel Hovdahl
"""
"""
Exercise 3
The prisoner’s dilemma is a common example used in game theory.
One example of the game is found in the table below (see slide).
Write a program that implements the game. The program should:
- prompt the user for two inputs... | true |
4d3cc4a33f6b0a0f13c703a7a5eeca8a52eb83cf | jlyu/chain-leetcode | /expired/algorithm/341. Flatten Nested List Iterator.py | 2,826 | 4.5625 | 5 | # -*- coding: utf-8 -*-
import time
"""
https://leetcode.com/problems/flatten-nested-list-iterator/
Given a nested list of integers, implement an iterator to flatten it.
Each element is either an integer, or a list -- whose elements may also be integers or other lists.
Example 1:
Given the list [[1,1],2,[1,1]],
By ... | true |
038b2a2e1d1515decbf7a42cab33f3573e94c071 | whitem1396/CTI110 | /P5HW1_RandomNumber_White.py | 994 | 4.28125 | 4 | ''' P5HW1 Random Number
Matthew White
03/18/2019
Random number generator '''
# Display a random number in the range of 1 to 100
import random
def get_number():
# Get the random number
number = random.randint(1, 100)
# Ask the user to guess the number
guess = int(input("Gues... | true |
d41ebd2cfa5967513e89ecc7080b64c7786ae9bf | fhansmann/coding-basics | /mini-programs/birthdays.py | 1,139 | 4.40625 | 4 | birthdays = {'Alice' : 'Apr 1', 'Bob' : 'Dec 12', 'Carol' : 'Mar 4'}
while True:
print('Enter a name: (blank to quit)')
name = input()
if name == '':
break
if name in birthdays:
print(birthdays[name] + ' is the birthday of ' + name)
else:
print('I do not have birthday inform... | true |
8d941369d1a3d3caa1b19dfb0a24e9fa6e740bc1 | blazehalderman/PythonAlgorithms | /ThreeNumberSum/threenumbersum.py | 765 | 4.34375 | 4 | """
Write a function that takes in a non-empty array of distinct integers and an
integer representing a target sum. The function should find all triplets in
the array that sum up to the target sum and return a two-dimensional array of
all these triplets. The numbers in each triplet should be ordered in ascendin... | true |
acb9969798a28f201ebba4e1262e75db79d86f69 | blazehalderman/PythonAlgorithms | /Two Number Sum/Two-Number-Sum.py | 597 | 4.1875 | 4 | """
Write a function that takes in a non-empty array of distinct integers and an
integer representing a target sum. If any two numbers in the input array sum
up to the target sum, the function should return them in an array, in any
order. If no two numbers sum up to the target sum, the function should return
... | true |
0e998e3b9d5aaa520356a2ccdcaf14f61bc8a935 | SupriyaRadhakrishnan/Python_Learning | /FirstProject/ForLoopSample.py | 321 | 4.15625 | 4 |
friends = ["Jim" , "Karen" , "Joey"]
for letter in "My Acamedy" :
print(letter)
#prints from 0-9
for index in range(10) :
print(index)
#prints from 3-9
for index in range(3,10) :
print(index)
for friend in friends :
print(friend)
for i in range(len(friends)) :
print(friends[i])
print(i)... | false |
bacfee8695b0ea151fb60d82b4e308c17c798bb4 | apeterlein/A-Short-Introduction-To-Python | /AShortIntroductionToPython/9_Intro_To_Euler_Problems.py | 2,497 | 4.15625 | 4 | # A Short Introduction To Python
# FILE 9 - INTRO TO EULER PROBLEMS
# Adam Peterlein - Last updated 2019-01-29 with python 3.6.5 and Visual Studio 15.7.1.
# Any questions, suggestions, or comments welcome and appreciated.
# For the remainder of this tutorial series we will focus on something called "Euler proble... | true |
f9c881baee98ff82427dbe5b13a8d53e83386671 | rohira-dhruv/Python | /Blackjack/main.py | 2,657 | 4.125 | 4 |
from art import logo_blackjack
import os
import random
def clear():
"""This function is used to clear the terminal window for a better user experience"""
os.system('cls')
def deal_card():
"""This function returns a randomly drawn card from a deck of cards"""
cards = [11, 2, 3, 4, 5, 6, 7, 8, 9, 10,... | true |
0d5af65d27b460db68f7d33f251e6c320783a649 | LeandroAzevedo-1/Listas_Dicion-rio_python | /Listas_ex_Valores_unicos.py | 1,461 | 4.25 | 4 | '''Crie um programa onde o usuário possa digitar vários VALORES NUMÉRICOS e cadastre-se
em uma LISTA. Caso o número já exista lá desntro, ele não será adcionado. No final
,serão exibidos todos os VALORES ÚNICOS digitados, em ordem CRESCENTE'''
'''Vamos criar uma lista que não sabemos quantos valores podem serem acresc... | false |
61261f7f230376b91f30c878c441383af2f60d16 | evelandy/Remove-Headers-from-CSV-Files | /HeaderRemoveCSV.py | 1,171 | 4.15625 | 4 | #!/usr/bin/env python3
"""evelandy/W.G.
Nov. 3, 2018 7:31pm
Remove-Headers-from-CSV-Files
Python36-32
Removes Headers from .CSV files
"""
import csv
import os
# This makes a new folder in the directory that you input and leaves the one there if one exists
directory = input("Enter the directory for your .csv files: ")... | true |
083eb84db09598f89b5c2b12c4e919f72fd2cc3b | SwapnilBhosale/DSA-Python | /bit_manipulation/chek_pow_2.py | 937 | 4.625 | 5 | '''
Check whether given number is power of 2.
The logic is , if we AND the power of 2 number with the number one less that that,
the output will be zero
example: We are checking if 8 is power of 2
8 -> 1000
7 -> 0111
8 & 7 = 1 0 0 0
0 1 1 1
---------
0 ... | true |
36e466e0b67dabeb375aebce6023f9ef35bc39ba | aaaaatoz/leetcode | /algorithms/python/powerofN.py | 770 | 4.1875 | 4 | """
Given an integer (signed 32 bits), write a function to check whether it is a power of 4.
Example:
Given num = 16, return true. Given num = 5, return false.
Follow up: Could you solve it without loops/recursion?
Credits:
Special thanks to @yukuairoy for adding this problem and creating all test cases.
Subscribe ... | true |
763a9b03eb618d6b69a4b5b8a9f29cfff0ea5347 | shangpf1/python_study | /2017-11-30-01.py | 818 | 4.15625 | 4 | """
我的练习作业02-pytho 逻辑运算符
"""
a = 10
b = 20
if ( a and b ):
print ("line 1 - 变量 a 和 b 都为 true")
else:
print ("line 1 - 变量 a 和 b 有一个不为true")
if ( a or b ):
print ("line 2 - 变量 a 和 b 都为true,或其中一个变量为true ")
else:
print ("line 2 - 变量 a 和 b 都不为true")
# 修改变量 a 的值
a = 0
if ( a and b ):
print ("line 3... | false |
428811ce79e144a62db247e7776c4c36fb716bc8 | JAreina/python | /4_py_libro_1_pydroid/venv/4_py_libro_1_pydroid/COLECCIONES/py_10_collec_ordered_dict_1.py | 475 | 4.125 | 4 | '''
The OrderedDict is a subclass of the dictionary and it remembers the order in which the
elements are added:
'''
import collections
print ('Regular Dictionary'
)
d = {}
d['g']= "aaaa"
d['a']= 'SAS'
d['bbbb']= 'PYTHON'
d['c']= 'R'
for k,v in d.items():
print (k, ":",v
)
print( '\... | false |
ce978e0784cb039c045e88b380012bc85d08f3fd | JAreina/python | /3_py_libro_1/venv/py_7_operadores.py | 852 | 4.25 | 4 |
'''
MATEMATICOS
'''
print( 3 % 2)
print( 3.0 % 2)
print("DIVISION" ,3 / 2)
print("floor division", 3 // 2 ) # redondea hacia abajo
print(2 ** 2)
'''
prioridad operadores
parentesis
exponentes,
multiplicacion
division
suma
resta
'''
a = 2 + 2 * 5
print(a)
a = (2 + 2) * 5
print(a)
print (5 - 6 * 2)
print ((5 -... | false |
bdfb06de8553a2b56cb68d014e23526387cab600 | SomyaRanjanMohapatra/DAY-14-SOLUTION | /DAY 14 SOLUTION.py | 258 | 4.125 | 4 | S=input("The original string is :")
nsub=input("\nThe substring you want to replace :")
nrep=input("\nThe string you want to use instead :")
nl=S.split()
for i in range(len(nl)):
if nsub == nl[i]:
nl[i]=nrep
n=" ".join(nl)
print("\n",n)
| false |
bd2a7b005121f31fe646f34ab4bdca6aca6a9662 | Amjad-hossain/algorithm | /basic/reverse_string.py | 1,246 | 4.625 | 5 | # /**
# * Reverse a string without affecting special characters
# * Given a string, that contains special character together with alphabets
# * (‘a’ to ‘z’ and ‘A’ 'Z’), reverse the string in a way that special characters are not affected.
# *
# * Examples:
# *
# * Input: str = "a,b$c"
# * Output: str = "c,b... | true |
428c32f4557f6d8d903a785ea2e3944e5b325b20 | euphwes/Project-Euler-Python | /problems/problem_9.py | 989 | 4.40625 | 4 | """
Special Pythagorean triplet
---------------------------
A Pythagorean triplet is a set of three natural numbers, a < b < c, for which,
a^2 + b^2 = c^2
For example, 3^2 + 4^2 = 9 + 16 = 25 = 5^2.
There exists exactly one Pythagorean triplet for which a + b + c = 1000.
Find the product abc.
"""
from utils.timer i... | false |
63f4ed10ed7f58c2c2f0b8f2c531f270ad12894e | euphwes/Project-Euler-Python | /problems/problem_38.py | 1,833 | 4.15625 | 4 | """
Pandigital multiples
--------------------
Take the number 192 and multiply it by each of 1, 2, and 3:
192 × 1 = 192
192 × 2 = 384
192 × 3 = 576
By concatenating each product we get the 1 to 9 pandigital, 192384576.
We will call 192384576 the concatenated product of 192 and (1,2,3)
The same can be achieved by sta... | true |
50a19f4ee8a2ec28b9281bce67ed39693ea93574 | katsuunhi/PythonExercises | /ex3.py | 673 | 4.125 | 4 | # 三、猜数字的AI
# 和猜数字一样,不过这次是设计一个能猜数字的AI。
# 功能描述:用户输入一个单位以内的数字,AI要用最少的次数猜中,并且显示出猜的次数和数字。
import random
digit = int(input("input a digit:"))
times = 0
answer = 100//2
middle = 100//4
times = times + 1
while digit != answer:
if answer < digit:
print(answer, " too small")
answer = answer + middle
times = times + 1... | false |
4b419589c596829305b2cb76999ea64a59c207ac | translee/learn_python_answers | /even_or_odd.py | 219 | 4.1875 | 4 | number=input("Enter a number.and I'll tell you if it's even or odd: ")
number=int(number)
if number%2==0:
print("\nThe number "+str(number)+" is even.")
else:
print("\nThe number "+str(number)+" is odd.")
| true |
99b3bde0232a3f0fb8fd7188f738de98671bfb1a | mkvenkatesh/CrackTheCode | /Stack & Queue/three_in_one.py | 2,599 | 4.4375 | 4 | # Describe how you could use a single array to implement three stacks.
# push top of the array, pop top of the array, peek top of the array, is_empty() - O(1)
# solutions
# 1. use array of arrays
# 2. if you have a fixed size array, divide by 3 and use modulo to define the
# lower and upper limits of each stack. u... | true |
1fff0364d53459a4d557796e07f73e0741c68fef | mkvenkatesh/CrackTheCode | /Linked List/delete_middle_node.py | 1,316 | 4.15625 | 4 | # Implement an algorithm to delete a node in the middle (i.e., any node but the
# first and last node, not necessarily the exact middle) of a singly linked
# list, given only access to that node.
# EXAMPLE
# Input:the node c from the linked list a->b->c->d->e->f
# Result: nothing is returned, but the new linked list l... | true |
7a8165c6de5b7c049c8ff0ab2f34bb61fd47b5cb | mkvenkatesh/CrackTheCode | /Trees & Graphs/validate_bst_recrusion.py | 1,562 | 4.25 | 4 | # Implement a function to check if a binary tree is a binary search tree.
# example 1
# 10
# 4 17
# 3 5 11 18
# example 2
# 10
# 4 17
# 3 5 6 18
# solution
# 1. maintain two vars - MIN and MAX that you keep updating as you traverse down
# the tree. Moving to the left, update... | true |
ba6827952b6e40869c6df721fcb32333cd8f6daa | mkvenkatesh/CrackTheCode | /Trees & Graphs/check_balanced.py | 2,420 | 4.21875 | 4 | # check balanced - Implement a function to check if a binary tree is balanced.
# For the purposes of this question, a balanced tree is defined to be a tree
# such that the heights of the two subtrees of any node never differ by more
# than one.
# examples
# 9
# 8 7
# 6 5 1 8... | true |
a39775a0b1be47236a09fb74e26f06e45d79442b | jsdeveloper63/Python-Sqlite | /ConditionSearchGet.py | 1,062 | 4.375 | 4 | import sqlite3
#Create the database
conn = sqlite3.connect("Electricity.db")
#Cursor method is used to go through the database
c = conn.cursor()
#Select individual column from the table
#c.execute("SELECT period FROM electricity")
#Prints/Gives data from all columns
#c.execute("SELECT * FROM electricity")
#data = ... | true |
dbe87a4561b3faf45aa1ab441173161cfd9ce755 | Alwayswithme/LeetCode | /Python/092-reverse-linked-list-ii.py | 1,193 | 4.1875 | 4 | #!/bin/python
#
# Author : Ye Jinchang
# Date : 2015-09-14 23:56:48
# Title : 092 reverse linked list ii
# Reverse a linked list from position m to n. Do it in-place and in one-pass.
#
# For example:
# Given 1->2->3->4->5->NULL, m = 2 and n = 4,
#
# return 1->4->3->2->5->NULL.
#
# Note:
# Given ... | false |
39441d61b7d370db5d9092b149b224ea9d02eacb | Alwayswithme/LeetCode | /Python/116-populating-next-right-pointers-in-each-node.py | 1,835 | 4.1875 | 4 | #!/bin/python
#
# Author : Ye Jinchang
# Date : 2015-10-08 13:23:10
# Title : 116 populating next right pointers in each node
# Given a binary tree
#
# struct TreeLinkNode {
# TreeLinkNode *left;
# TreeLinkNode *right;
# TreeLinkNode *next;
# }
#
# Populate each next poi... | true |
7c3b522f1f6a70dd4f718297f4077801f2664f6f | Alwayswithme/LeetCode | /Python/098-validate-binary-search-tree.py | 1,134 | 4.15625 | 4 | #!/bin/python
#
# Author : Ye Jinchang
# Date : 2015-09-17 20:10:24
# Title : 098 validate binary search tree
# Given a binary tree, determine if it is a valid binary search tree (BST).
#
# Assume a BST is defined as follows:
#
# The left subtree of a node contains only nodes with keys less tha... | true |
78d1084a4dcf796b06973f9f66fc737a51737b20 | tahabroachwala/hangman | /ExternalGuessingGame.py | 1,109 | 4.28125 | 4 | # The Guess Game
# secret number between 1 and 100
import random
randomNumber = random.randrange(1, 100) # changed from 10 to 100
#print randomNumber #check if it's working
# rules
print('Hello and welcome to the guess game !')
print('The number is between 1 and 100')
guesses = set() # your set of guesses
gues... | true |
179b10a76d7f45d72b940df327b3130df69c6aac | mrmufo/learning-python | /dates-and-datetime/challenge.py | 2,824 | 4.1875 | 4 | # Create a program that allows a user to choose one of
# up to 9 time zones from a menu. You can choose any
# zones you want from the all_timezones list.
#
# The program will then display the time in that timezone, as
# well as local time and UTC time.
#
# Entering 0 as the choice will quit the program.
#
# Display the... | true |
e7ca99c8556e63e0ab6dc1ab1d0a951cfad3feab | LGMart/USP-CC-Python | /4-Ex1-FizzBuzz.py | 724 | 4.25 | 4 | #Escreva a função fizzbuzz que recebe como parâmetro um número inteiro e retorna
#'Fizz' se o número for divisível por 3 e não for divisível por 5;
#'Buzz' se o número for divisível por 5 e não for divisível por 3;
#'FizzBuzz' se o número for divisível por 3 e por 5;
#Caso a função não seja divisível 3 e também não sej... | false |
6f998d7918322d4c8934e7a690cbf10e8e59eb7e | imranmohamed1986/cs50-pset01 | /pset6/caesar/caesar.py | 1,469 | 4.125 | 4 | from cs50 import get_string
from sys import argv
def main():
key = get_key()
plaintext = get_plaintext("plaintext: ")
print("ciphertext:", encipher_text(plaintext, key))
# Get key
def get_key():
# Check if program was executed with an argument and only one
# If yes, produce an int from it
if... | true |
bbecc9c3de6b21ecc7981e6da0d1c37a7937b792 | Topazoo/Machine_Learning | /collab_filter/euclid_dist/euclid_dist.py | 1,964 | 4.34375 | 4 | from math import sqrt
import recommendations
'''Code for calculating Euclidean Distance scores.
Two preferences are mapped on axes to determine
similarities'''
def distance(y1, y2, x1, x2):
'''Calculating Distance:
1. Take the difference in each axis
2. Square them
3. Add them
... | true |
0e16302bcec94857f4f3bae43d638df597f8b191 | Haridhakshini/Python | /selectionsort.py | 674 | 4.28125 | 4 | #Program for Selection Sort
#Array Input
array_num = list()
num = raw_input("Enter how many elements in the array:")
print "Enter elements in the array: "
for i in range(int(num)):
n = raw_input("num :")
array_num.append(int(n))
#Selection Sort function
def selectionsort(array_num):
for slot in range... | true |
1c66c415554e0d1d60effecd3ecd42ce7165551e | amanewgirl/set09103 | /Python_Tutorials_Continued/exercise16.py | 638 | 4.25 | 4 | #Exercise 16 from Learn Python the Hard way- Reading and writing
from sys import argv
script, filename = argv
print "Opening the file: "
target = open(filename, 'w')
print "Now I'm going to ask you for three lines."
line1 = raw_input("line 1: ")
line2 = raw_input("line 2: ")
line3 = raw_input("line 3: ")
print "I'... | true |
7dc0ccdce064edf0d8cda6eaf90ec44a73da1416 | frapimoneto/CodeStart | /Aula_1/3.py | 405 | 4.3125 | 4 | '''
Faca um programa em Python que recebe tres
numeros e calcule sua media.
'''
# Recebe os numeros do teclado:
n1 = input ("Informe o primeiro numero: ")
n2 = input ("Informe o segundo numero: ")
n3 = input ("Informe o terceiro numero: ")
# Converte para numerico:
n1 = float (n1)
n2 = float (n2)
n3 = fl... | false |
0c53d752d09b426a810792bbc244d653a775e55f | Tarun-coder/Data-science- | /table14.py | 597 | 4.15625 | 4 | # Print multiplication table of 14 from a list in which multiplication table of 12 is stored.
number=int(input("Enter the number to Find Table of: "))
table=[]
for i in range(1,11,1):
numb=number*i
table.append(numb)
print("Table of Number",number,"is",table)
print("---------------table of 2-------------------... | true |
889d67897848f4b7ec25397bfb6825378fbc7cc5 | Tarun-coder/Data-science- | /evenno.py | 509 | 4.21875 | 4 | # Write a Python function to print the even numbers from a given list.
a =int(input("Enter the size of the list : " ))
li=[]
for i in range(a):
number=int(input("Enter the Number to add into list: "))
li.append(number)
print("The value of the list",li)
print("The Final list is :",li)
print("--------------... | true |
933286a486e6e386fac2064ae8616225f6bf4817 | Tarun-coder/Data-science- | /function9.py | 237 | 4.1875 | 4 | # Print multiplication table of 12 using recursion.
num=int(input("Enter the Number:"))
def mult12(num,i=1):
if i<11:
mul=num*i
print(num,"x",i,"=",mul)
i+=1
mult12(num,i)
mult12(num) | false |
97dbe152ca65123ee746e5ec222aec6f51cc0cd8 | Tarun-coder/Data-science- | /Roman2.py | 461 | 4.3125 | 4 | # Write a Python script to check if a given key already exists in a dictionary.
new={1:"one",2:"two",3:"Three",4:"Four",5:"Five",6:"Six",7:"Seven",8:"Eight",9:"Nine",10:"Ten"}
keys=[1,2,3,4,5,6,7,8,9,10]
values=["one","two","Three","Four","Five","Six","Seven","Eight","Nine","Ten"]
number=int(input("Enter the Key : "))... | true |
b526c782ab5c09113d16827fcf81e8eb7d8da8eb | Tarun-coder/Data-science- | /function7.py | 358 | 4.25 | 4 | # Write a function to calculate area and perimeter of a rectangle.
lenth=int(input("Enter the Lenth of Rectangle:"))
width=int(input("Enter the Breadth of the Rectangle:"))
def rectangle(lenth,width):
print("The Permiter of the Rectangle is:",2*lenth+2*width,"cm")
print("The Area of the Rectangle is:",lenth*wid... | true |
76dbfeb357c5f237f3c1c803ed110fca8807b5cf | Tarun-coder/Data-science- | /tempcon.py | 762 | 4.53125 | 5 | # If we want to Print the value from farenheit to celsius
Converter=input("Enter the Converter Name: ")
print("The Converter Selected is : ",Converter)
if Converter=="cels to far":
celscius=int(input("Enter the Temperature in celscius : "))
farenheit=(celscius*9/5)+32
print("The Value in Farenheit is {}F:... | true |
5231ad5e30fdb1102c98f309ab30c80a37f257e0 | Tarun-coder/Data-science- | /functionq 5.py | 465 | 4.15625 | 4 | a=int(input("Enter the Number a: "))
b=int(input("Enter the Number b: "))
c=int(input("Enter the Number c: "))
def findmax(a,b,c):
if a==b==c:
print("All are Equal")
exit()
if a>b:
if a>c:
print("a is Greater than all")
else:
print("c is Greater than all... | true |
8f2994a49203bc8dcae758fad8fd848dc212c7b9 | NikaZamani/ICS3U-Unit3-03-Python-Number_Guessing_Game | /Number_Guessing_Game.py | 808 | 4.28125 | 4 |
#!/usr/bin/env python3
# Created by: Nika Zamani
# Created on: April 2021
# This program will generate a random number between 0 and 9
# and then checks if it matches the right number.
import random
def main():
# this function generates a random number between 0 and 9
random_number = random.randint(0, 9) ... | true |
260332aa405a51e0666c247002196d69b8e959ba | zhubiaook/python | /syntax/built_in_functions/filter_function.py | 852 | 4.21875 | 4 | """
filter(function, iterable)
function: 函数
iterable: 可迭代对象
filter()用于过滤iterable, 返回符合function条件的可迭代对象
iterable的每个元素作为function的参数传入,进行判断,然后返回True或False
最后将返回True的元素形成一个可迭代对象。
Version: 0.1
Author: slynxes
Date: 2019-01-13
"""
def odd_list(list_data):
"""
过滤出列表中所有的奇数
:param list_data:
... | false |
3950ced96153a601310a17980f9031013b82d59d | shafirpl/InterView_Prep | /Basics/Colt_Data_structure/Queue/Queue.py | 1,196 | 4.125 | 4 | class Node:
def __init__(self, val):
self.val = val
self.next = None
# in java, use a LinkedList class, use add method (compared to push method which
# adds item at the front/head) to enqueue/add item to the end, and pop to remove item from head/front/begining
class Queue:
def __init__(self)... | true |
e370ad016d1c193084a224df6a3f8f347b4ac595 | weak-head/leetcode | /leetcode/p0023_merge_k_sorted_lists.py | 1,743 | 4.125 | 4 | from queue import PriorityQueue
from typing import List
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
def mergeKLists(lists: List[ListNode]) -> ListNode:
"""
Divide And Conquer
Time: O(n * log(k))
n - total number of nodes
k - total number of l... | true |
fde9c44a1de285bb11bb2d24b3e07c5c74747022 | weak-head/leetcode | /leetcode/p0212_word_search_ii.py | 2,581 | 4.125 | 4 | from typing import List
def findWords_optimized(board: List[List[str]], words: List[str]) -> List[str]:
"""
Backtracking with trie and multiple optimizations
to prune branching
Time: O(r * c * (3 ** l))
Space: O(l)
r - number of rows
c - number of cols
l - max length of th... | true |
d743e7c63ddee5169e99773c615f3a2cb63613bf | weak-head/leetcode | /leetcode/p0609_find_duplicate_file_in_system.py | 2,447 | 4.15625 | 4 | from typing import List
from collections import defaultdict
def findDuplicate(paths: List[str]) -> List[List[str]]:
"""
* 1. Imagine you are given a real file system, how will you search files? DFS or BFS?
BFS explores neighbors first.
This means that files which are located close to each other are al... | true |
b88e80385800a44af25da1f0ab75ccfbca9387d8 | candyer/learn-python-the-hard-way | /airport-board.py | 1,741 | 4.15625 | 4 | def next_letter(letter):
return chr(ord(letter) + 1)
def initialize_array(city):
"""
create a list of "a" the same length as city
"""
list_city = []
while len(list_city) < len(city):
list_city.append('a')
return list_city
def list_to_string(list_city):
"""
take a list, make what's inside to a string.
"""
... | true |
03abde311519c576eed418644098b09848945806 | deepakag5/Data-Structure-Algorithm-Analysis | /Sorting/InsertionSort.py | 477 | 4.21875 | 4 | def insertion_sort(arr):
for i in range(1,len(arr)):
# create a temp variable to store current value
temp = arr[i]
position = i
# keep swapping the elements until the previous element is greater than the element at position
while position > 0 and temp < arr[position - 1]:
... | true |
eb3f98069aa33aeabac448c00c91085d54de9576 | deepakag5/Data-Structure-Algorithm-Analysis | /leetcode/array_merge_intervals_two_lists.py | 1,226 | 4.1875 | 4 | # Time Complexity: Best case : O(m+n)
# Space Complexity - O(m+n) for holding the results
def merge(list1, list2):
# base case
if not list1:
return list2
if not list2:
return list1
# first we need to merge both lists in sorted order (on basis of first element) so that we can then merg... | true |
d0bb05a35c89ba9729417de48331a660d6ffe6b1 | sureshkanna-alg/python | /new_file1.py | 393 | 4.1875 | 4 | n = input("Enter your number: ")
if n==1:
print "English"
elif n==2:
print "Telugu"
elif n==3:
print "Maths"
elif n==4:
print "Social"
elif n==5:
print "Science"
else:
print "Enter Valid Number"
n = input("Enter Your Number: ")
if type(n) == int:
if n%2 == 0:
print "E... | false |
eb104e1a0f8d6a13ef93c7b3e46385dd32480d97 | dackour/python | /Chapter_23/01_Module_Usage.py | 1,675 | 4.125 | 4 | # The import statement
import module1 # Get module as a whole (one or more)
module1.printer('Hello world!') # Qualify to get names
# The from Statement
from module1 import printer # Copy out a variable (one or more)
printer('Hello world!') # No need to qualify name
# The from * Statement
from module1 import * ... | true |
8b763a0c00f8caa70c566c3ea5c7cb3d66c24164 | mavamfihlo/Mava059 | /calculatorSprint4.py | 1,627 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
@author: Mava Mfihlo
"""
# below we are importing all of the functions that were created in the CalculatorFunctions.py file
from CalculatorFunctions import*
#this function import sys from os which will allow exit or quit the program
from os import sys
# while loop will remain... | true |
11dd15d44a03f915db6ef221040d47cce032ca1f | akash95khandare/Functional-Algorithm-Object-Oriented-program-in-python | /Month1/algorithm/Anagram.py | 309 | 4.125 | 4 | from util.Utility import is_anagram
def main():
str1 = input("Enter first string : ")
str2 = input("Enter second string : ")
if is_anagram(str1.strip(), str2.strip()):
print("String is anagram.")
else:
print("String is not anagram.")
if __name__ == '__main__':
main()
| false |
6385a5bed6596c002b1363c69c4320bd88a32957 | akash95khandare/Functional-Algorithm-Object-Oriented-program-in-python | /Month1/OOPS/StockReport.py | 1,986 | 4.15625 | 4 | """
Overview : Stock Report
purpose : writing new json data into json file
class name : StockReport
author : Akash Khandare
date : 05/03/2019
"""
import json
class StockReport:
def __init__(self):
self.list = []
with open("Json_Files/Stock.json", 'r') as data:
try:
data... | true |
28e79fcbf38289d6608ccc1aff49a1b949ba558c | UltraChris64/Learn-Python-the-Hard-Way | /labs/ex6.py | 886 | 4.5625 | 5 | types_of_people = 10
# lines 3 and 7 format (the beginning f) inside the variable to replace any
# variable used in the curly brackets when that variable is used
x = f"There are {types_of_people} types of people."
binary = "binary"
do_not = "don't"
y = f"Those who know {binary} and those who {do_not}."
print(x)
print... | true |
30e72d54c31ba3eee6d041862264d2627ea4bfb4 | AnetaStoycheva/Programming0_HackBulgaria | /Week 10/dict_reverse.py | 289 | 4.25 | 4 | # {key:value} --> {value: key}
# {'A': 'abc'} --> {'abc':'A'}
def dict_reverse(dictionary):
new_dictionary = {}
for key in dictionary:
value = dictionary[key]
new_dictionary[value] = key
return new_dictionary
print(dict_reverse({'A': 'abc', 'B': 'def'}))
| false |
ad76f9a4e39a8cfb270db88be5c54bbe5633f2ec | Hroque1987/Exercices_Python | /Functions_examples/string.format.py | 1,036 | 4.1875 | 4 | #str.format()
#animal ='cow'
#item = 'moon'
#print('The '+animal+' jumped over '+item)
#print('The {} jumped over the {}'.format(animal, item))
#print('The {1} jumped over the {0}'.format(animal, item)) #positional argument
#print('The {animal} jumped over the {item}'.format(animal='cow', item='moon')) # keyword ... | true |
ec0bf97fb5cbf2fea670da8b29442993345fc565 | fredericyiding/algorithms | /numsIslands.py | 2,454 | 4.21875 | 4 | from Queue import Queue
class Solution:
"""This is to calculate the number of Islands based on
binary list of lists.
Attributes:
"""
def numsIslands(self, grid, method='bfs'):
"""This function calculates the number of Islands.
Both BFS and DFS implementations were presented.
... | true |
990578d0a0ed269d519392e7a4b58177fe0ebb59 | wojtas2000/codewars | /number_expanded_form.py | 873 | 4.375 | 4 | # Write Number in Expanded Form
# You will be given a number and you will need to return it as a string in Expanded Form. For example:
# expanded_form(12) # Should return '10 + 2'
# expanded_form(42) # Should return '40 + 2'
# expanded_form(70304) # Should return '70000 + 300 + 4'
# NOTE: All numbers will be whole numb... | true |
d0aa7d38ff7a446a47e562265d16f9416ed6774d | mcavalca/uri-python | /2846.py | 208 | 4.125 | 4 | def fibonot(n):
a = 1
b = 2
c = 3
while n > 0:
a = b
b = c
c = a + b
n -= (c - b - 1)
n += (c - b - 1)
return b + n
n = int(input())
print(fibonot(n))
| false |
fba00850481a6a5df77e86977cc07d11d60c05ec | Zmontague/PythonSchoolWork | /asciiArt.py | 1,896 | 4.40625 | 4 | """
Author: Zachary Montague
Date: 4/19/2021
Description: Program which prompts user for file name, reads the file
name in, line by line iterates through the file and then decrypts the text, finally displaying the art and asking the
user if they wish to read more files, until blank line is entered
"""
# CONSTANT DECLA... | true |
082cae899e0314834cbbc83c9f3043a4ae13d9c0 | codrWu/py-codewars | /get_the_mid_char.py | 900 | 4.3125 | 4 | # -*- coding: utf-8 -*-
"""
You are going to be given a word. Your job is to return the middle character of the word. If the word's length is odd,
return the middle character. If the word's length is even, return the middle 2 characters.
获取字符串中间的字符,字符串长度为奇数返回中间一个字符,长度为偶数返回中间两个字符
Created on 2018/7/4
@author: codrwu
"""... | true |
dd174d1a4f71b9583c1280b55bd1132511338c1b | amari-at4/Duplicate-File-Handler | /Topics/Loop control statements/Prime number/main.py | 233 | 4.1875 | 4 | number = int(input())
times_divisible = 0
for _i in range(1, number + 1):
if number % _i == 0:
times_divisible += 1
if times_divisible == 2:
print("This number is prime")
else:
print("This number is not prime")
| true |
021e2c922e635be0cadc325bbbc78f738f024e69 | sam-kumar-sah/Leetcode-100- | /451s.sort_character_by_frequency_in_string.py | 663 | 4.1875 | 4 | //451. Sort Characters By Frequency
'''
Given a string, sort it in decreasing order based on the
frequency of characters.
Example 1:
Input: "tree"
Output: "eert"
Example 2:
Input: "cccaaa"
Output: "cccaaa"
Example 3:
Input: "Aabb"
Output: "bbAa"
'''
//code:
class Solution(object):
def fs(self,s):
... | true |
b7bab5235de87b65aa8fe8c7c8bdb26debdf3e35 | marcowchan/holbertonschool-higher_level_programming | /0x07-python-test_driven_development/2-matrix_divided.py | 1,417 | 4.28125 | 4 | #!/usr/bin/python3
"""Defines matrix_divided"""
def matrix_divided(matrix, div):
"""Divides all elements of a matrix.
Args:
matrix: A list of lists of integers or floats.
div: The divisor to divide the elements of the matrix by.
Raises:
TypeError: If the matrix is not a list of li... | true |
5747ce73e516a8a66c6668f7ca3d9ea389fac79f | gerpsh/backtoschool | /imgEditor/editor/processing/bw.py | 1,748 | 4.3125 | 4 | def applyFilter(pixels):
# This is an array where we'll store pixels for the new image. In the beginning, it's empty.
newPixels = []
# Let's go through the entire image, one pixel at a time
for pixel in pixels:
# Let's get the Red, Green and Blue values for the current pixel
inputRed ... | true |
34d222f0a98b6d90711a37661c30bddb450b09db | randm989/Euler-Problems | /python/p14.py | 891 | 4.15625 | 4 | #!/usr/bin/python
#The following iterative sequence is defined for the set of positive integers:
#
#n n/2 (n is even)
#n 3n + 1 (n is odd)
#
#Using the rule above and starting with 13, we generate the following sequence:
#
#13 40 20 10 5 16 8 4 2 1
#It can be seen that this sequence (starting at 13 and fini... | true |
9b6c8d5b353f452cfd2809c57d3a521fa0aa553c | mattcucuzza/pyLinearAlgebra | /main.py | 2,060 | 4.125 | 4 | # Matthew Cucuzza
# 2/18/17
# Python program doing various operations with vectors from linear algebra
import math
# Find the sum of two vectors combined
def addVectors(x1, y1, x2, y2):
x = x1+x2
y = y1+y2
return x,y
# Find the length of two vectors combined
def lengthOfVector(x,y):
x = x**2
y =... | true |
4cf83df6618978bd041bfa78af67e33a73818663 | atriadhiakri2000/Algorithm | /Tree/Merge two BST 's.py | 2,677 | 4.375 | 4 | # Data structure to store a BST node
class Node:
# Constructor
def __init__(self, data, left=None, right=None):
self.data = data
self.left = left
self.right = right
# Helper function to print a doubly linked list
def printDoublyList(head):
while head:
print(head.data, end=" -> ")
head = he... | true |
74d0229c22b3083e4a0a0d45636fc01fa735bdc8 | MMDIOUF/basic_python | /exercise/palindrome.py | 279 | 4.15625 | 4 | def palindrome(mot):
mot_inverse=mot[::-1]
return mot == mot_inverse
m=input("Veuillez saisir un mot?\t")
resultat=palindrome(m)
reponse=f"{m} est un palindrome"
if resultat:
print(reponse)
else:
reponse = reponse.replace("est","n'est pas")
print(reponse) | false |
59e4e85b1be563055dc3a616b72e07d1e188c009 | btjd/coding-exercises | /array_strings/toeplitz_matrix.py | 1,006 | 4.15625 | 4 | """
LeetCode 766
A matrix is Toeplitz if every diagonal from top-left to bottom-right has the same element.
Now given an M x N matrix, return True if and only if the matrix is Toeplitz.
"""
def toeplitz(matrix):
nr = len(matrix)
nc = len(matrix[0])
for r in range(nr - 1):
c = 0
curr = matr... | false |
0137bccec4aecafec20f89a64077fee732221da4 | priyanka090700/hacktoberfest2021 | /multiply.py | 367 | 4.375 | 4 | #Taking input from the user.
num1 = int(input("Enter first number: "))
num2 = int(input("Enter second number: "))
#Defining a function to calculate multiplication of the two numbers.
def multiply(a,b):
result = a * b
print("Product of two given numbers is: ", result)
#Calling the function to ... | true |
c6fae1838643eddada768c1cefff9508b6001ed7 | zeeshanhanif/ssuet-python | /4June2017/DataScienceChap4/Demo1.py | 945 | 4.125 | 4 | data = [
[26,30],
[28,50],
[30,70]
]
def vector_add(v, w):
"""adds corresponding elements"""
return [v_i + w_i
for v_i, w_i in zip(v, w)]
def vector_subtract(v, w):
"""subtracts corresponding elements"""
return [v_i - w_i
for v_i, w_i in zip(v, w)]
def vector_sum(vectors)... | false |
f00c9f561c037c9bbc0fbbb8c12b6339719c1116 | zeeshanhanif/ssuet-python | /9April2017/DemoList/StudentTerminal.py | 1,256 | 4.28125 | 4 |
studentslist = ["zeeshan","saad","osama"]
print("Welcome to student portal")
print("Please enter 1 to list student names")
print("Please enter 2 to add student names")
print("Please enter 3 to search student names")
print("Please enter 4 to delete particular student names")
print("Please enter 5 to sort student name... | true |
00e40c3ec5331789c75a00ed50e44e0d7f0de932 | josias-natal/learning-python | /aulas/aula017_listas.03_copiar_listas.py | 631 | 4.15625 | 4 | '''NOTE: When one list is matched to another in Python, when modifying one, the other is also modified together.'''
a = [2, 3, 4, 7]
b = a # Cria uma lista "b" idêntica à lista "a", tornando-as intrinsecamente ligadas
b[2] = 8
print(f'Lista A: {a}')
print(f'Lista B: {b}')
print('')
"""
Para criar duas listas com ite... | false |
451e9c53ffbf4a4d5e888765fd00cca8f933306d | xyismy/py | /if.py | 358 | 4.15625 | 4 | # -*- coding: utf-8 -*-
# str = 5
# #第一种
# if str > 10:
# print(str)
# #第二种
# if str > 10:
# print(str)
# elif str > 1:
# print('yes')
# else:
# print('no')
# #第三种,非0,非空str,list则true,反之false
# if str:
# print(str)
str = 'ABC'
str2 = 'abc'
print(str.lower())
print(str.upper())
print(str2.isupper()) | false |
835476ef90f3f6c91c00eaccc427af5cfaec0e89 | susbiswas/DSAlgo | /MaxHeap.py | 2,141 | 4.1875 | 4 | # The following code implements a **max** Heap
#
# Strictly speaking, the following functions will take O(n) time
# in Python, because changing an input array within the body of a function
# causes the language to copy the entire array. We will soon see how to do this
# better, using Python classes
# function for in... | true |
05ca6f981f767455a9dfb99592821976c09c6f4b | MyHackInfo/Python-3-on-geeksforgeeks | /035- Mouse and keyboard automation using Python.py | 1,409 | 4.125 | 4 | '''
#### Mouse and keyboard automation using Python ####
-The pyautogui is a module that help us control mouse and keyboard with code.
## Some Functions
1-size(): This function is used to get Screen resolution.
2-moveTo(): use this function move the mouse in pyautogui module.
3-moveRel() functi... | true |
32eda3cbc67f060040a8eed5ba02e29dde62b512 | MyHackInfo/Python-3-on-geeksforgeeks | /048-enum in Python.py | 930 | 4.46875 | 4 | '''
#### Enum in Python ####
-Enumerations in Python are implemented by using the module named “enum“.
-Enumerations are created using classes. Enums have names and values associated with them.
## Properties of enum:
1. Enums can be displayed as string or repr.
2. Enum can be checked fo... | true |
8bb072d3d1a21338fd3b206de442f13e94badb01 | MyHackInfo/Python-3-on-geeksforgeeks | /020-Generators in Python.py | 1,170 | 4.625 | 5 | '''
#### Generators in Python ####
1-Generator-Function:
A generator-function is defined like a normal function,
but whenever it needs to generate a value, it does so with
the yield keyword rather than return. If the body of a def
contains yield, the f... | true |
f37ada6908329b162e40f9486a0228be999983b0 | MyHackInfo/Python-3-on-geeksforgeeks | /017-Using Iterations in Python.py | 878 | 4.75 | 5 | # Accessing items using for-in loop
cars = ["Aston", "Audi", "McLaren"]
for x in cars:
print (x)
# Indexing using Range function
for i in range(len(cars)):
print (cars[i])
# Enumerate is built-in python function that takes input as iterator
for q, x in enumerate(cars):
print (x)
for x in enumerate(cars... | true |
b2c38cdbf324a30dff7fef4116d3b620d3691dd0 | MyHackInfo/Python-3-on-geeksforgeeks | /057-Python tkinter Button and Canvas.py | 1,469 | 4.3125 | 4 | '''
## 1- Button:->> To add a button in your application, this widget is used.
## format of the Buttons:>
1->activebackground:-> to set the background color when button is under the cursor.
2->activeforeground:-> to set the foreground color when button is under the cursor.
3->bg:-> to s... | true |
7f2e1c54a6c5df0f7d1ebc56667e465831d875cd | MyHackInfo/Python-3-on-geeksforgeeks | /014-Inplace vs Standard Operators in Python.py | 1,503 | 4.625 | 5 | '''
# Inplace vs Standard Operators in Python
-Normal operators do the simple assigning job. On other hand, Inplace operators behave
-similar to normal operators except that they act in a different manner in case of
-mutable and Immutable targets.
Immutable=> such as numbers, strings and tuples. >>Updation But... | true |
f65250794c2b2f3fa49927b3e37786978215dfce | MyHackInfo/Python-3-on-geeksforgeeks | /036-Object Oriented Programming in Python.py | 1,823 | 4.40625 | 4 | '''
#### Object Oriented Programming in Python ####
# Class, Object and Members #
* The __init__ method:>>
The __init__ method is similar to constructors in C++ and Java.
It is run as soon as an object of a class is instantiated.
The method is useful to do any initialization you wan... | true |
7d95dc42bae43085f729ee5d037b9cc144c51d5e | MyHackInfo/Python-3-on-geeksforgeeks | /047-Heap queue (or heapq) in Python.py | 2,260 | 4.1875 | 4 | '''
### Heap Queue in python ###
-Heap data structure is mainly used to represent a priority queue.
-In Python, it is available using “heapq” module. The property of this
-data structure in python is that each time the smallest of heap element is popped(min heap).
-Whenever elements are pushed or po... | true |
7052094ebf233f0fa595080757162a7882589e55 | CSmel/pythonProjects | /average_rainfall2/average_rainfall2.py | 1,062 | 4.5 | 4 |
# Ask user for how many years of rainfall to be used in calculations.
num_years = int(input('How many years? '))
# Determine how many years.
print()
for years in range(num_years):
total = 0 # Initialize an accumulator for number of inches of rainfall.
print('---------------')
... | true |
02e8b105d9395302f5a9452f81aa0c5ede756db0 | CSmel/pythonProjects | /feet_to_inches/feet_to_inches.py | 458 | 4.25 | 4 | # Constant for thenumber of inches per foot
INCHES_PER_FOOT = 12
# Main functions.
def main():
# Get the number of feet from the user
feet = int(input('How many feet? '))
# Display and convert feet to inches
print(feet,'feet converted to inches is:',feet_to_inches(feet),'inches.')
# Th... | true |
139f211d82629d5c2946b2b9a514bcc1b50f6934 | pmkiedrowicz/python_beginning_scripts | /random_string.py | 370 | 4.21875 | 4 | '''
Generate random String of length 5.
String must be the combination of the UPPER case and lower case letters only. No numbers and a special symbol.
'''
import random
import string
def generate_string(length):
base_chars = string.ascii_letters
return ''.join(random.choice(base_chars) for i in range(length... | true |
e4c272f006a7210ca82b2d331cd8198ceb47deed | pmkiedrowicz/python_beginning_scripts | /select_multiple_columns_csv.py | 394 | 4.1875 | 4 | '''
Find each company’s Higesht price car
'''
import pandas
# Read .csv file
pd = pandas.read_csv("Automobile_data.csv")
# Create multidimension list grouped by company
companies = pd.groupby('company')
# Use below script for debugging
# for i in companies:
# print(i)
# Select from each group row with max price ... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.