blob_id string | repo_name string | path string | length_bytes int64 | score float64 | int_score int64 | text string | is_english bool |
|---|---|---|---|---|---|---|---|
f3d0c405d9c2efc27f90738fe3b46e7837dcf8e6 | manishhedau/ineuron-assignment | /Assignment-2/1.py | 298 | 4.1875 | 4 | # 1. Create the below pattern using nested for loop in Python.
"""
*
* *
* * *
* * * *
* * * * *
* * * *
* * *
* *
*
"""
m = int(input('Enter the number of columns : '))
for i in range(1):
for j in range(m):
print('* '*j)
for k in range(m):
print('* '*(m-k-2))
print() | false |
5a69d46e14b7668fe2a346b53af0d969578a4345 | KarlYYY/LearnPython | /Python demo/test2.py | 500 | 4.3125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
list1=['Alice','Bob','Chris','Dean'] # list
print('The first list element is %s'%list1[0])
print('The last list element is %s'%list1[-1])
list1.pop()
print('The last list element is %s'%list1[-1])
list1.append('Eric')
print('The last list element is %s'%list1[-1])
tuple1=... | false |
4266fac216ad1d316fc296b75728ee21f701d3c9 | Fhernd/Python-CursoV2 | /parte11/11.1_intro_funciones.py | 2,212 | 4.59375 | 5 | # Introducción a las funciones - Unidades de reutilización y encapsulación de información:
# 1. Creación de una función:
print('1. Creación de una función:')
def sumar(numero_1, numero_2):
"""
Suma dos números (sean enteros o punto flotante).
Parameters:
numero_1: primer valor a sumar.
numero_2: ... | false |
ea222b881da640760d645bdaf33788f89d74aade | Fhernd/Python-CursoV2 | /parte11/ex11.03_producto_lista_tupla.py | 1,646 | 4.21875 | 4 | # Ejercicio 11.3: Crear una función para multiplicar todos los números en una lista o tupla.
def multiplicar(valores):
"""
Multiplica el conjunto o grupo de valores de una lista o tupla:
Parameters:
valores: Lista o tupla con los valores a multiplicar.
Returns:
Multiplicar de los valores en l... | false |
3956bde95df92f0d42cfe5b3971f0ec8be4b61a1 | momentum-cohort-2018-10/w1d2-house-hunting-meagabeth | /house_hunting.py | 611 | 4.21875 | 4 | annual_salary = float(input("Enter your annual salary: "))
portion_saved = float(input("Enter the percent of your salary to save, as a decimal: "))
total_cost = float(input("Enter the cost of your dream home: "))
# portion_down_payment = total_cost*.25
# current_savings = current_savings + current_savings*r/12
num_of_... | true |
309e576a8590e23e5e56f91b57385772f2466526 | mddeloarhosen68/Swap-Two-Variable | /swap.py | 290 | 4.25 | 4 | #Ex:1
a = 5
b = 6
temp = a
a = b
b = temp
print(a)
print(b)
#Ex:2
a = 5
b = 6
a = a + b
b = a - b
a = a - b
print(a)
print(b)
#Ex:3
a = 5
b = 6
a = a ^ b
b = a ^ b
a = a ^ b
print(a)
print(b)
#Ex:4
a = 5
b = 6
a,b = b,a
print(a)
print(b) | false |
bea263655e559f8f6a6e699a1483cf2263e3b2cb | spreadmesh/fastcampus_wps2 | /DAY_10/homework_2.py | 1,090 | 4.125 | 4 | ## 2. replace 함수의 구현 - 문자열을 치환하는 Python 내장 함수인 replace 를 직접 구현하세요.
"""
해결 방법
1. while문으로 직접 위치제어를 하자
2. 비교할 위치의 문자 갯수가 다르면 곤란한데 그냥 반복문이 끝나고 나머지 부분을 붙이는 형태로 정리
"""
def word_replace(string, before, after):
output=""
index=0
while index < len(string)-len(before)+1:
if before != string[0+index:len... | false |
a66060ca33414a76e51665db90a2aaea6c00bc63 | williechow97/String-Lists---Palindrome | /String List -- Palinedrome.py | 1,880 | 4.21875 | 4 | # Palindrome
# Ask the user for a string and print out whether this string
# is a palindrome or not. (A palindrome is a string that reads the same forwards and backwards.)
'''
fix to catch numbers
make so ignores spaces and exclamation
best to separate string into list of char and check conditions and create... | true |
8dc25f4ce9c7d748f487d04975862f4a25d5496c | jjmanjarin/MathNStats | /_build/jupyter_execute/03_Graphs_with_Pandas.py | 2,954 | 4.375 | 4 | # Graphics with Pandas
We have seen how to use **matplotlib** to generate the basic graphs we may need in our statistical analysis. However, since the main data structure we are going to work with is the data frame which is defined in **pandas**, we may want to fully use this library to make the graphs.
If we use thi... | true |
b244c6a422b05a1ea159cdbc5cb207f23c793e51 | pereiradaniel/python_experiments | /raw_input/greeting.py | 441 | 4.15625 | 4 | # Prompt user for name
name = input("What is your name?: ")
# Print name if name is greater than 0 and consists of alphabetic characters
if len(name) > 0 and name.isalpha():
print ("Hello " + name)
# Print everything from the second letter onward
first = name[0]
new_word = name + first + "ay"
new_w... | true |
f1efa39e2e495d688f5737ce11ee14be81256a4c | c34809368/260201053 | /lab8/example5.py | 607 | 4.28125 | 4 | def password_checker(password):
level=0
if (len(password)<8) or (" " in password):
print("It is not valid")
return level
else:
for char in password:
if char.isdigit():
level+=1
break
for char in password:
if char.isalpha():
level+=1
break
for char in... | true |
3df662f8b4851d35f4af76d83f49e05e71711efe | iguerrexo/111 | /111/intro.py | 871 | 4.15625 | 4 | print('Hello form Python')
last_name = 'Guerrero'
age = 20
found = False
total = 13.44
print(last_name)
print("Nora"+last_name)
print(age + age)
#this will give an error
print(last_name + str(age))
print (age + total)
#math
print('----------------------------------')
print(1 + 1)
print(42 - 21)
p... | true |
f55009a4529b27991dda38b278478ce5aae01d3c | takashimokobe/algorithms | /lab3/array_list.py | 2,678 | 4.3125 | 4 | import unittest
from sys import argv
# A List is one of
# None
# A reference to an arrary and a int representing size
class List:
def __init__(self, list, size):
self.list = list
self.size = size
def __eq__(self, other):
return (type(other) == List
and self.list == other.list
an... | true |
b6ff2566f5eef857b5d4687db07366a1ac0a0edc | poonam5248/MachineLearning | /Day1____14-June-2019/4.TypeCasting.py | 407 | 4.28125 | 4 | #TYPE CASTING
#TYPE CASTING COMMANDS
## int
## str
## chr
## float
## bin
## hex
## ord(original data of any letter)
## ------------
## ------------
## ------------
## ------------
a="Hello "
b=100
c=a+str(b)
print(c)
a='100'
b=5
c=int(a)+b
print(c)
a=65
print("Char of 'a' is: ",chr(a))
p... | false |
be02dcd7076cb523940bfa85edf459f657cb358a | poonam5248/MachineLearning | /Day2____15-June-2019/1.Dictionary.py | 635 | 4.3125 | 4 | #DICTIONARY
# Dictionary is a Key-Value Pair Collection
dict={'abc':1000,10:123,1.5:'Hello','xyz':15,15.8:10,'m':'a','ab':'xyz'}
print(dict)
print(dict['abc'])
# print(dict[1]) It will Show Error Because there is no index postions in dictionary
print(dict[1.5])
##b=dict.values
##c=dict.keys
##print("Values are:... | false |
4706aa47eeac1008a1289a7a9958364916fe43e0 | shrikantpadhy18/interview-techdev-guide | /Algorithms/Searching & Sorting/Insertion Sort/InsertionSort.py | 1,088 | 4.15625 | 4 | class InsertionSort():
def __init__(self, list_to_sort):
self.sorted_list = list_to_sort
self.__sort()
def __sort(self):
i = 1
while i < len(self.sorted_list):
x = self.sorted_list[i]
j = i - 1
while j >= 0 and self.sorted_list[j] > x:
... | true |
0d94ee7adf61e4e1c20935b03cc42db3f408698e | quantacake/Library | /backend.py | 2,430 | 4.1875 | 4 | # Archive Application (Backend)
import sqlite3
"""
Backend:
Attach functions to all objects (e.g. listbox, butotns,
entries, etc) which will retreive data from an
SQLite database.
"""
class Database:
# initializer / constructor
# this gets executed when you call an instance of the class.
... | true |
0ad89a8b136632ad52a1fdd383702bf6642a14c5 | AAJAL/Simple-Python-Programs | /alphabet.py | 525 | 4.40625 | 4 |
def display_alphabet_by_code(preference):
if preference == "lowercase":
number = 97
for i in range(26):
print(chr(number))
number += 1
elif preference == "uppercase":
number = 65
for i in range(26):
print(chr(number))
number += 1
... | true |
16b6c2d14666968fe3be9d1f6f167c65b5637887 | aadithpm/code-a-day | /py/Isograms.py | 479 | 4.15625 | 4 | """
An isogram is a word that has no repeating letters, consecutive or non-consecutive. Implement a function that determines whether a string that contains only letters is an isogram. Assume the empty string is an isogram. Ignore letter case.
is_isogram("Dermatoglyphics" ) == true
is_isogram("aba" ) == false
is_isogra... | true |
f77bb1ffce190ffa43009580fa1374d3bf911776 | UmbertoFasci/CodewarsWriteups | /Give_me_a_diamond.py | 1,388 | 4.46875 | 4 | #! /usr/bin/python3
"""
Jamie is a programmer, and James' girlfriend.
She likes diamonds, and wants a diamond
string from James. Since James doesn't know
how to make this happen, he needs your help.
You need to return a string that looks like a
diamond shape when printed on the screen,
using asterisk(*) characters. T... | true |
aa8a549d51c9e261e32e905417ddae45cb56dc5a | yuliaxxx/homework_python | /easy/two_numbers.py | 355 | 4.21875 | 4 | first = int(input("Enter first number:"))
second = int(input("Enter second number:"))
operation = input("Enter operator:")
if operation == '+':
print(first+second)
elif operation == '-':
print(first-second)
elif operation == '*':
print(first*second)
elif operation == '/':
print(first/second)
else:
p... | false |
c1452de1dde5bbe0dfe70fe1a1b5b50dcab271b0 | neeleshcrasto/Assignments | /MIT/assn1.py | 1,244 | 4.125 | 4 |
from math import *
# ----------------------------#
## COMPUTING PRIMES NUMBERS ##
# ----------------------------#
# function to compute product of primes
product = log(2)
def prdtprime (prdt):
global product
product = product + log(prdt)
return product
# function to check whether a number is prime
def ... | false |
132d82ea41a401eac464184e1c8045aa20df014b | neeleshcrasto/Assignments | /100Plus/quest8.py | 458 | 4.28125 | 4 | #-------------------------------------------------------------------------------------#
## This accepts a comma separated sequence of words as input ##
## Then prints the words in a comma-separated sequence after sorting them alphabetically ##
#---------------------------------------------------------------------------... | true |
4d7998320a4e5dae8ecff7148d07892f1e59c774 | neeleshcrasto/Assignments | /100Plus/quest4.py | 378 | 4.28125 | 4 | #---------------------------------------------------------------------------------#
## Accept a string of comma separated values and print out as list & tuple ##
#---------------------------------------------------------------------------------#
values = input('Enter values separated by comma\n')
liszt = values.spli... | true |
8225842771ab1017d304cf92c62de5b86f86bd65 | nkhaja/Data-Structures | /queue.py | 1,379 | 4.125 | 4 | #!python
from linkedlist import LinkedList
class Queue(LinkedList):
def __init__(self, iterable=None):
"""Initialize this queue and enqueue the given items, if any"""
super(Queue, self).__init__()
if iterable:
for item in iterable:
self.enqueue(item)
def _... | true |
f2926a48ba00c6344cfab1dd4ee6c280c6352071 | TeoBlock/cti110 | /M3T1_AreaOfRectangles_McIntireTheodore.py | 1,693 | 4.5625 | 5 | # CTI-110
# Module 3 Tutorial 1
# Theodore McIntire
# 05 October 2017
# This program gets user input and then outputs which rectangle has the greater area
# variables for rectangle 1 and 2 length and width
length1 = 0
width1 = 0
area1 = 0
length2 = 0
width2 = 0
area2 = 0
# initial variable values are set... | true |
734f158b54c8d856de0a2e81e59397b69399ddbf | TeoBlock/cti110 | /M5T2_McIntireTheodore.py | 1,073 | 4.34375 | 4 | # CTI-110
# Module 5 Tutorial 2
# Theodore McIntire
# 12 October 2017
# This program totals the number of bugs collected in a week
#def main() uses a for loop
def main():
# This program uses these variables
# ? ? ? I DO NOT UNDERSTAND WHY THIS PROGRAM DOES NOT RUN
# IF THESE VARIABLES ARE DEFIN... | true |
6f71141dc458512bd412f4f4351ae6ca9ad029fa | Trex275/C---97 | /C97.py | 468 | 4.1875 | 4 | #Write a program to count the number of words in the input by user
userinput = input("Enter any sentence :")
print(userinput)
numberofwords = 1
numberofcharachters = 0
for i in userinput:
if i==' ':
numberofwords = numberofwords + 1
else:
numberofcharachters = numberofcharachters + 1... | true |
f71b8ff05499b70dc7d062c09c60ffa566ce9e2e | jashburn8020/design-patterns | /python/src/prototype/prototype_test.py | 1,907 | 4.21875 | 4 | """Prototype pattern example."""
import copy
class Address:
"""A person's address."""
def __init__(self, street: str, city: str, country: str):
self.country = country
self.city = city
self.street = street
def __eq__(self, other: object) -> bool:
"""Two `Address` objects ... | true |
4a8634e9e9e8b767a7c36e57c6a1ee559c271a5e | sidhanshu2003/Python-assignments-letsupgrade | /Batch 6 Python Day 3 Assignment.py | 871 | 4.125 | 4 | #!/usr/bin/env python
# coding: utf-8
# In[36]:
# Sum of n numbers with help of while loop
#Input from user
num = eval(input("Please enter the number "))
sum = 0
while num >0:
sum = sum + num
print(f"Number is --> {num} Sum is --> {sum}")
num= num -1
print ("Final Sum is ", sum)
print (f"Final Sum is ... | true |
5ec55686e4dfb98d372ea6537a8a01c2ed893fb1 | asleake/AdventOfCode2020 | /Day3.py | 740 | 4.21875 | 4 | """Day 3 of Advent of Code 2020. Running this file will print out the correct answers to the two
puzzles from Day 3."""
from common.imports import importAdventFile
from common.slope_functions import findTreesOnSlope
data = importAdventFile('data/Day3Input')
def FirstPart():
""" Find the number of trees for the gi... | true |
c52d1872447e2ae0d2fce6e2b62517f892ac1af2 | SACHSTech/ics2o1-livehack---2-GavinGe3 | /problem1.py | 966 | 4.21875 | 4 |
"""
-------------------------------------------------------------------------------
Name: problem1.py
Purpose: Given an input of the number of antennas and eyes, determines the alien lifeform
Author: Ge.G
Created: 23/02/2021
------------------------------------------------------------------------------
"""
pri... | true |
c3d9fbf50cc43b31032aa5a80a0433998774fa75 | Bedrock02/Interview-Practice | /CSSpartans/quiz3.py | 1,457 | 4.15625 | 4 | '''
Implement the function makeChange(cents, coins)
Given an input cents and coins, makeChange should output an object that contains
the minimum amount of coins needed to equate to cents in value.
Coins is an array that contains the coin values.
Input
makeChange will take in 2 parameters,
an integer cents,
and a... | true |
357f133aa1d44da3baa30b32d2260f7edfcf0d51 | Bedrock02/Interview-Practice | /Array_Strings/string_compression.py | 1,259 | 4.34375 | 4 | '''
Implement a method to perform basic string compression using the counts
of repeated characters. For example, the string aabcccccaaa would become
a2blc5a3.
If the "compressed" string would not become smaller than the
original string, your method should return the original string
My Solution
1. Iterat through string... | true |
cff73d26ab370d55660d3817b6b4d41527228fdc | Bedrock02/Interview-Practice | /Stacks_Queues/sort_stack.py | 1,536 | 4.1875 | 4 | '''Write a program to sort a stack in ascending order. You should not make any assump- tions
about how the stack is implemented. The following are the only functions
that should be used to write this program: push | pop | peek | isEmpty.'''
# Solution Explanation
# In order to sort a stack we need another stack
# 1 ... | true |
2affdb4fbe889a193f4f33973d3de94c63e76325 | PhoenixTAN/CS-591-Parallel-Computing | /Code/merge-k-lists/merge_lists_pairs.py | 2,298 | 4.34375 | 4 | import random
from typing import List
def merge_lists(inputs: List[List[int]]) -> List[int]:
"""
Merges an arbitrary number of sorted lists of integers
into a single sorted list of integers.
Iterates over the input list of lists.
On each iteration, selects pairs (a, b) of lists to merge,
copyi... | true |
69d946050b26fe6412d1436e0bbcc049be9cca14 | engemp/holbertonschool-higher_level_programming | /0x01-python-if_else_loops_functions/8-uppercase.py | 268 | 4.21875 | 4 | #!/usr/bin/python3
def uppercase(str):
for character in range(len(str)):
letter = ord(str[character])
if str[character].islower():
letter = letter - 32
letter = chr(letter)
print("{}".format(letter), end="")
print()
| false |
183c733935f791b6a73f6b6e45e176a9e5b12f0d | engemp/holbertonschool-higher_level_programming | /0x0B-python-input_output/1-number_of_lines.py | 320 | 4.125 | 4 | #!/usr/bin/python3
'''
Returns the number of lines in a txt
'''
def number_of_lines(filename=""):
'''
Returns the number of lines in a txt
'''
numberLines = 0
with open(filename, mode='r', encoding='utf-8') as filet1:
for line in filet1:
numberLines += 1
return numberLines
| true |
cf1f24787a41a57682780db8e785f1cc76536f33 | VPatel5/CS127 | /nameOrganizer.py | 424 | 4.21875 | 4 | # Name: Vraj Patel
# Email: vraj.patel24@myhunter.cuny.edu
# Date: September 13, 2019
# This program organizes the names inputted
#Cohn, Mildred; Dolciani, Mary P.; Rees, Mina; Teitelbaum, Ruth; Yalow, Rosalyn
message = input("Please enter your list of names using '; ' to separate each name: ")
list = message.split('... | false |
3e39177428ef1421e0e47fd943c17924c9a45570 | whiterabbitsource/pyhello | /hello.py | 361 | 4.21875 | 4 | # Hello! World!
print("Hello, World!")
# Learning Strings
my_string = "This is a string"
## Make string uppercase
my_string_upper = my_string.upper()
print(my_string_upper)
# Determine data type of string
print(type(my_string))
# Slicing strings [python is zero-based and starts at 0 and not 1]
print(my_string[0:4])
pri... | true |
711dc1eca9d23e169eec6c52bd038f5e0671bb0b | Riopradheep007/Searching-and-Sorting-Algorithms | /Sorting/Selection Sort/selection_sort.py | 465 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Mar 20 14:50:08 2021
@author: pradheep
"""
"""
find the minimum value placed in the left side
very worst algorithm
Best case O(n^2)
worst case O(n*2)
"""
def selection_sort(ls):
for i in range(len(ls)):
min_var=i
for j in range(i,len(ls)):... | false |
0d1f9138991dee73f157d07adff1dba350647ba2 | NagaManjunath/algorithms | /stack/is_sorted.py | 1,238 | 4.34375 | 4 | """
Given a stack, a function is_sorted accepts a stack as a parameter and returns
true if the elements in the stack occur in ascending increasing order from
bottom, and false otherwise. That is, the smallest element should be at bottom
For example:
bottom [6, 3, 5, 1, 2, 4] top
The function should return false
bottom... | true |
40f29fc621c51c189e097f3515a0ce7507e88d8d | manisha2412/SimplePythonExercises | /exc17.py | 829 | 4.34375 | 4 | """
Write a version of a palindrome recognizer that also accepts phrase palindromes such as "Go hang a salami I'm a lasagna hog.", "Was it a rat I saw?", "Step on no pets", "Sit on a potato pan, Otis", "Lisa Bonet ate no basil", "Satan, oscillate my metallic sonatas", "I roamed under it as a tired nude Maori", "Rise to... | true |
79f762282c13ba6765ca4509a9bcebff60213892 | annesels/innlevering_1 | /oppgave_2.py | 592 | 4.125 | 4 | #!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
a = input("Vil du finne (m), (v) eller (E)? " )
if a == "E":
m = float(input("Hva er massen (m)? "))
v = float(input("Hva er farten (v)? "))
E =(m*v**2)/2
print("Den kinetiske enegien til legemet er",E,"J")
elif a == "m":
E = float(input("H... | false |
048aefeb9045a6163d2707a54c4bc9b256ab231a | doron04/dsf | /block_1/sort_algorithms.py | 1,469 | 4.125 | 4 | import random
import time
num_elements = 10000
S = [random.randint(0,1000000) for x in range(num_elements)]
def bubble_sort(array):
'''Bubble Sort Algorithm. Takes an unsorted list as input and returns a sorted list'''
k = len(array)
S = array
while k>0:
for i in range(k-1):
if S... | true |
36e9aeb82022742bc55ff804dff18410942d2bf5 | ikapoor/Project-Euler- | /palindromeChecker.py | 450 | 4.1875 | 4 | string = str(input("Please Enter a word: "))
string = string.replace(" ","")
length = len(string)
forwardString = []
for x in range(len(string)):
forwardString.append(string[x])
backwardsString = []
for x in range(len(string)):
backwardsString.append(string[length-1])
length = length -1
if (forwardSt... | true |
add28130e02da71486ecdba1da96381c2d983f96 | shincap8/holbertonschool-machine_learning | /math/0x00-linear_algebra/2-size_me_please.py | 273 | 4.15625 | 4 | #!/usr/bin/env python3
"""Function to return the shape of the matrix"""
def matrix_shape(matrix):
"""Function to return the shape of the matrix"""
shape = []
x = matrix
while type(x) is list:
shape.append(len(x))
x = x[0]
return shape
| true |
bca6fc69f750a8fe2067266eafcdd8aa1355dee0 | shincap8/holbertonschool-machine_learning | /math/0x00-linear_algebra/8-ridin_bareback.py | 654 | 4.1875 | 4 | #!/usr/bin/env python3
"""Function to return two multiply matrices"""
matrix_shape = __import__('2-size_me_please').matrix_shape
def mat_mul(mat1, mat2):
"""Function to return two multiply matrices"""
if matrix_shape(mat1)[1] != matrix_shape(mat2)[0]:
return None
mul = []
shapem = [matrix_sh... | false |
1610f9978876e43a5a97fe90a43bcb8fbe22f58e | ravichalla/wallbreaker | /week4/implement_stacks_using_queues.py | 1,764 | 4.21875 | 4 | '''
QUESTION:
225. Implement Stack using Queues
Implement the following operations of a stack using queues.
push(x) -- Push element x onto stack.
pop() -- Removes the element on top of the stack.
top() -- Get the top element.
empty() -- Return whether the stack is empty.
Example:
MyStack stack = new MyStack();
stac... | true |
88a14c40c2dd670acdd6ac98d4c40893e7f5502c | skyaiolos/AByteOfPython3 | /SEC08-Func/func_param.py | 317 | 4.15625 | 4 | def printMax(a, b):
if a > b:
print(f'{a} > {b}, {a} is the maximum')
elif a == b:
print(f'{a} = {b} , {a} is equal to {b}')
else:
print(f'{a} < {b} , {b} is the maximum')
printMax(3, 4) # directly give literal valuse
x = 5
y = 7
printMax(x, y) # give variables as arguments
| true |
cd74a9c17acda27bbafb8496da772ef319d467a6 | BrandonLMorris/InterviewPrep | /CrackingTheCodingInterview/Python/Chapter1/q3.py | 709 | 4.1875 | 4 | #!/usr/bin/env python3
"""Solution to question 3 of chapter 1"""
def is_perm(s1, s2):
"""Return true if s1 is a permutation of s2, assuming spaces count"""
if len(s1) != len(s2):
return False
# Add for occurences in s1, subtract for occurences in s2
counts = [0 for _ in range(128)]
for c i... | true |
39349ad653d01cf8eeaeed04e271b9057c770eb1 | ImagClaw/Python_Learning | /Classes&Objects/pet.py | 1,419 | 4.28125 | 4 | #! /bin/usr/env python3
#
# Author: Dal Whelpley
# Project: Pet Class build and then instantiation or the class
# Date: 4/25/2019
class Pet:
def __init__(self, name, animal_type, age):
self.__name = name
self.__animal_type = animal_type
self.__age = age
def set_name(self, name):
... | true |
e1670d7b94b07d53ff54f582e94097ee1b31409f | ImagClaw/Python_Learning | /proj4.py | 477 | 4.28125 | 4 | #! /bin/usr/env python3
#
# Author: Dal Whelpley
# Project: Project 4 (convert Celsius to Fehrenheit)
# Date: 4/22/2019
print("Converts Celsius to Fehrenheit.") # Tells user about program
c = input("Enter the temp in Celsius: ") # input tempurature in celsius
f = float(9/5)*float(c)+32 # converts input t... | true |
6db10de58682123f5dde420eb216c98efe1a2120 | Otabek-KBTU/PT-Python | /project/10ball.py | 670 | 4.25 | 4 | def count_words(text):
#google how to split text to words with multiple delimiters ' ', '-', '.' etc
# words = input(text)
words = special_split()
counter = {}
simbol = ('я', 'ты', 'он', 'она', 'оно', 'мы', 'вы', 'они','мой','твой','.',',','!','?')
#убрать местоимения, предлоги и другие лишные слова
words... | false |
4451ca66232d7465fa9084de2b3cb3085e61069f | lbs1991/py | /isnotin.py | 482 | 4.21875 | 4 | #!/usr/bin/python27
x = [x for x in range(1,10)]
print(x)
y =[]
result = True if 12 not in x else False # this is the best way
print(result)
result = True if not 12 in x else False # this way just like as " (not 12) in x"
print(result)
print(x is y)
print(x is not y) # this is the best way
print(not x is y) # ... | true |
946b7da8a38704cd49fd96392a2a61deefbd8680 | tamarameisman/cse210-student-mastermind | /mastermind/game/player.py | 2,391 | 4.125 | 4 | class Player:
"""A person taking part in a game. The responsibility of Player is to keep track of their identity and last guess.
Stereotype:
Information Holder
Attributes:
_name (string): The player's name.
_guess (guess): The player's last guess.
"""
def __init__... | true |
993d9ab91794f3e07d2259146c4132ef65fabc62 | F4r4m4rz/MyPython | /Math/Fibonnacci.py | 223 | 4.125 | 4 |
def Fibonacci(seq):
if type(seq) != int:
raise ValueError("Expecting integer")
if seq==0 or seq == -1:
return 0
if seq == 1:
return 1
return Fibonacci(seq-2) + Fibonacci(seq-1)
| false |
bab22d104eb534c15aa529daab3e577603aca08d | KRHS-GameProgramming-2018/Lucas-and-Owen-Madlibs | /getInput.py | 2,985 | 4.125 | 4 | def getMenuInput():
goodInput = False
while not goodInput:
response = raw_input(" > ")
if (response == "1"
or response == "One"):
response = "1"
goodInput = True
elif (response == "2"
or response == "Two"):
response = "2"
... | true |
0acd460f7ebbfcbbc4b5ea4395c0798d61940f01 | NestY73/Algorythms_Python_Course | /Lesson_1/line_equation.py | 809 | 4.28125 | 4 | #-------------------------------------------------------------------------------
# Name: line_equation
# Purpose: Homework_lesson1_Algorythms
#
# Author: Nesterovich Yury
#
# Created: 16.03.2019
# Copyright: (c) Nesterovich 2019
# Licence: <your licence>
#--------------------------------------... | false |
977fb7c55a7c2c5e15fd9062d50a2574783ec6c6 | NestY73/Algorythms_Python_Course | /Lesson_1/bit_operations.py | 978 | 4.125 | 4 | #-------------------------------------------------------------------------------
# Name: bit_operations
# Purpose: Homework_lesson1_Algorythms
#
# Author: Nesterovich Yury
#
# Created: 16.03.2019
# Copyright: (c) Nesterovich 2019
# Licence: <your licence>
#-------------------------------------... | false |
d562002df8df8225ecc1f967b62807c98208c089 | prachived/PlagiarismDetector | /PlagiarismDetector/plagiarism-detector/factorial1.py | 294 | 4.28125 | 4 | #Test for comments
def factorial():
#this is a comment
if number < 0:
print("Sorry, factorial does not exist for negative numbers")
elif number == 0:
print("The factorial of 0 is 1")
else:
for i in range(1,number + 1):
fact = fact*i
print("The factorial of",number,"is",fact) | true |
4a9e51b13e70e3d92bcdaa654fe612841975d40a | wspasindupanthaka/hands-on-nlp-with-python | /Python Crash Course/data_structures.py | 728 | 4.15625 | 4 |
#Non homegeneos list
list1 = [12,12.1,"Hi"]
#Printing a list
print(list1)
print(list1[0])
print(list1[1])
print()
#Inserting elements
list1.append(15)
print(list1)
list1.insert(0,"Inserted")
print(list1)
print()
#Updating list
list1[0]=125
print(list1)
print()
#Delete element
list1.pop()
print(list1)
... | false |
bc94f3dd8cc1a0a90e16dd506213791166996311 | 1232145/Rock_paper_scissor | /Rock_Paper_Scissor.py | 1,123 | 4.15625 | 4 | from random import randint
computer = randint(0,2)
if computer == 0:
computer = "rock"
if computer == 1:
computer = "scissor"
if computer == 2:
computer = "paper"
def main():
run = True
while run:
player = input("rock, paper, or scissor? ").lower()
if player == "rock" or player == "paper"... | true |
bbf0d945f52849a9bf1c0e67ade855e1716c9d49 | Nmewada/hello-python | /15_lists.py | 323 | 4.1875 | 4 | # List
# Create a list using []
a = [1, 2 , 4, 50, 6]
print(a) # Print the list using print() function
# List Indexing
# Access using index using a[0], a[1], a[2]
print(a[2])
# Change the value of list using
a[0] = 90
print(a)
# We can create a list with items of different types
b = [15, "Nitin", False, 6.9]
print... | true |
bf117ed9ea57d686ca00d55fe788f1cbd2dac122 | alainno/fibras | /old_fibergen/rotation.py | 626 | 4.125 | 4 | import math
import matplotlib.pyplot as plt
def rotate(origin, point, angle):
"""
Rotate a point counterclockwise by a given angle around a given origin.
The angle should be given in radians.
"""
ox, oy = origin
px, py = point
qx = ox + math.cos(angle) * (px - ox) - math.sin(angle) * (py ... | true |
868e5fc193c8a6982c1de1937e0f089adb9f9455 | vaibhavg12/Problem-Solving-in-Data-Structures-Algorithms-using-Python3 | /Algorithms/2 Array Recursion/Segrigate.py | 1,568 | 4.1875 | 4 | """Segregate even odd.
"""
def SegregateEvenOdd(arr):
first = 0
second = len(arr) - 1
while first < second:
if arr[first] % 2 == 0:
first += 1
elif arr[second] % 2 != 0:
second -= 1
else:
arr[first], arr[second] = arr[second], arr[first]
"""
Segr... | true |
9f592349b2200db2fd3fa16a555026eb5d6781aa | vaibhavg12/Problem-Solving-in-Data-Structures-Algorithms-using-Python3 | /Algorithms/2 Version/minimalSwap.py | 1,861 | 4.28125 | 4 | """
Minimum swaps required to bring all elements less than given value together at the start of array.
Use quick sort kind of technique by taking two index from both end
and try to use the given value as key.
Count the number of swaps that is answer.
"""
def minSwaps(arr, val):
swapCount = 0
first = 0
... | true |
629cc6420969359ac91259b2f817535966bd73f5 | Jasonhou209/notes | /leetcode/206_reverse_linked_list.py | 916 | 4.21875 | 4 | """
206.反转链表
反转一个单链表。
示例:
输入: 1->2->3->4->5->NULL
输出: 5->4->3->2->1->NULL
进阶:
你可以迭代或递归地反转链表。你能否用两种方法解决这道题?
"""
# Definition for singly-linked list.
class ListNode:
def __init__(self, x):
self.val = x
self.next = None
class Solution:
def reverseList(self, head: ListNode) -> ListNode:
p... | false |
e1f076daa1983954c7c42fb70a35e2b2b428a50d | anjaandric/Midterm-Exam-2 | /task3.py | 572 | 4.25 | 4 | """
=================== TASK 3 ====================
* Name: Recursive Sum
*
* Write a recursive function that will sum given
* list of integer numbers.
*
* Note: Please describe in details possible cases
* in which your solution might not work.
*
* Use main() function to test your solution.
=========================... | true |
b7bd510c8bac072a3183ce280105511722fa7f71 | pranshu1921/RockPaperScissors | /rock_paper_scissors.py | 1,048 | 4.1875 | 4 | # -*- coding: utf-8 -*-
"""
Created on Sun Sep 6 17:25:10 2020
@author: Pranshu Kumar
"""
from random import randint
#creating play options list
t = ['Rock', 'Paper', 'Scissors']
#assigning random play to computer
computer = t[randint(0,2)]
#player set to False
player = False
while player == Fa... | true |
f12d7347615cdedcb9e8614d2220a462083739e3 | victorcabral029/zipFunctionPython | /zip.py | 483 | 4.125 | 4 |
#Exemplo basico
lista1 = ['Um','Dois','Tres','Quatro']
lista2 = [1,2,3,4]
listaZip = zip(lista1,lista2)
print(listaZip)
#Exemplo Operacao
a = [1,3,5,6]
b = [2,6,7,9]
for i in zip(a,b):
print(i[0]*i[1])
#Exemplo Dicionario
fruits = {
'Laranjas': 7,
'Abacaxis': 3,
'Mangas': 5,
'Goiabas': 5,
'... | false |
2675cf36e2898ca831f0f3c88d25fdb556414002 | grickoff/GeekBrains_3HW | /6.py | 1,365 | 4.15625 | 4 | # Реализовать функцию int_func(), принимающую слово из маленьких латинских букв
# и возвращающую его же, но с прописной первой буквой.
# Например, print(int_func(‘text’)) -> Text.
def my_title (word):
word = word.title()
return word
print(my_title(input('Введите слово из маленьких латинских букв: ')))
# Продо... | false |
ef2bea49c58a2e7dda39534533fae90292d44f72 | SACHSTech/ics2o-livehack1-practice-SurelyH | /days_hours.py | 531 | 4.34375 | 4 | '''
-------------------------------------------------------------------------------
Name: days_hours.py
Purpose: Hours to days
Author: Huang.S
Created: date in 03/12/2020
------------------------------------------------------------------------------
'''
# input number of hours
hours = float(input("Enter the number... | true |
597fe17d3975420cda713999ac3e449ac364225f | stemasoff/CrackingTheCodinglnterview | /Stack/3.2.py | 830 | 4.25 | 4 | '''
Как реализовать стек, в котором кроме стандартных функций push и рор будет
поддерживаться функция min, возвращающая минимальный элемент? Все
операции - push, рор и min - должны выполняться за время 0( 1 ).
'''
class Stack:
minimum = None
def __init__(self):
self.items = []
def push(self, x):
... | false |
7274e6dfff8a8a440251c5540b5486ab0851adef | Helblindi/ProjectEuler | /21-40/Problem30.py | 1,157 | 4.15625 | 4 | """
Surprisingly there are only three numbers that can be written as the sum of fourth powers of their digits:
1634 = 1^4 + 6^4 + 3^4 + 4^4
8208 = 8^4 + 2^4 + 0^4 + 8^4
9474 = 9^4 + 4^4 + 7^4 + 4^4
As 1 = 1^4 is not a sum it is not included.
The sum of these numbers is 1634 + 8208 + 9474 = 19316.
Find the sum of all... | true |
631e0b3445d7469c373ee3b920de47c5f78d395e | Helblindi/ProjectEuler | /21-40/Problem26.py | 1,144 | 4.1875 | 4 | """
A unit fraction contains 1 in the numerator. The decimal representation of the unit fractions with
denominators 2 to 10 are given:
1/2 = 0.5
1/3 = 0.(3)
1/4 = 0.25
1/5 = 0.2
1/6 = 0.1(6)
1/7 = 0.(142857)
1/8 = 0.125
1/9 = 0.(1)
1/10 = 0.1
Where 0.1(6) means 0.166666..., and has a 1-digit recurring cycle. ... | true |
0ac6d8684baa9490415a0c5e3df994b575040647 | Helblindi/ProjectEuler | /21-40/Problem35.py | 1,891 | 4.15625 | 4 | """
The number, 197, is called a circlar prime because all rotations of the digits: 197, 971, and 719, are themselves prime.
There are thirteen such primes below 100: 2, 3, 5, 7, 11, 13, 17, 31, 37, 71, 73, 79, and 97.
How many circular primes are there below one million?
"""
import time
# driver function for our p... | true |
e3ea659a83119fbf64ad07c6abfa835118a6e58f | arti-shok/my_python | /.ipynb_checkpoints/table-checkpoint.py | 510 | 4.125 | 4 | value = int(input("Введите номер химического элемента:\n"))
if value:
number_of_element = value
if number_of_element == 3:
print("Li")
elif number_of_element == 25:
print("Mn")
elif number_of_element == 80:
print("Hg")
elif number_of_element == 17:
print("Cl")
els... | false |
2aabdcae8e38d6ab206ce7ab6973cd82073d425b | IMDCGP105-1819/portfolio-DarrylJF | /ex8.py | 853 | 4.21875 | 4 | portion_deposit = 0.2
current_savings = 0
r = 0.04
months = 0
annual_salary = float(input("Enter your annual salary: "))
semi_annual_raise = float(input("What is the semi-annual raise you expect to recieve (As a decimal): "))
portion_saved = float(input("Enter the percentage of your salary to save (As a decimal): "))
... | true |
13abb2314b335eae9c64df4c716899c62a12e100 | IMDCGP105-1819/portfolio-DarrylJF | /ex4.py | 732 | 4.15625 | 4 | # replace these with your own values!
my_name = 'Chris Janes'
my_age = 21 # maybe
my_height = 67 # inches
my_weight = 160 # pounds
my_eyes = 'Green'
my_hair = 'Ginger'
is_heavy = my_weight > 3000
to_kilo = my_weight * 0.45 # kilograms
to_cent = my_height * 2.54 # centimetres
print(f"Let's talk about {my_name}.")
# swa... | true |
8359343663507cf04b96b677d7aa9ce22d8df538 | vikumkbv/Hacktoberfest-2k19 | /python/isPrime.py | 821 | 4.21875 | 4 | # Run `python isPrime.py` for a standalone prime number checker.
# Import `check_prime` function if integrating into another program.
from math import sqrt
def check_prime(val):
if val <= 1:
return False
else:
for i in range(2, int(sqrt(val)) + 1):
if val % i == 0:
return False
return True
def main... | true |
126d2d9e537ba919529a95f6304ca38408756d3e | CTEC-121-Spring-2020/mod-3-programming-assignment-blymatthew20 | /Prob-4/Prob-4.py | 1,502 | 4.28125 | 4 | # Module 3
# Programming Assignment 4
# Prob-4.py
# Matthew Bly
# Author: Bruce Elgort
# Date: July 12, 2017
"""
The Elgorte coffee shop sells coffee at $16.50 a pound
plus the cost of shipping. Each order ships for $0.76
per pound plus $1.25 fixed cost for overhead. If the
number of pounds of the coffee order... | true |
ef0b1c7fd00a3b3c75d0fd2e6e6d9dc235088828 | gabrielluchtenberg/Padawan | /Exercicios/blackjack_21/services/somethings.py | 259 | 4.125 | 4 | def proxima():
while True:
choose = input("Quer virar mais uma carta? (S/N): \n").upper()
if choose == 'S':
return True
elif choose == 'N':
return False
else:
print('Opção inválida!')
| false |
6a75f749c80ae40152aac987780fffa1170603b1 | ztxm/Python_level_1 | /lesson3/task6.py | 1,132 | 4.3125 | 4 | """
6) Реализовать функцию int_func(), принимающую слово из маленьких латинских букв и возвращающую его же,
но с прописной первой буквой. Например, print(int_func(‘text’)) -> Text.
Продолжить работу над заданием. В программу должна попадать строка из слов, разделенных пробелом.
Каждое слово состоит из латинских букв в ... | false |
1bc86bd7d9d64b8ff9f5bb97ba6cce372896ebd0 | ztxm/Python_level_1 | /lesson1/task2.py | 693 | 4.3125 | 4 | """
2. Пользователь вводит время в секундах. Переведите время в часы,
минуты и секунды и выведите в формате чч:мм:сс. Используйте форматирование строк.
"""
time_in_seconds = int(input("Введите время в секундах: "))
if time_in_seconds <= 0:
print("Ошибка, время в скундах должно быть больше 0")
else:
hours = tim... | false |
e94eeb996218f6f88b3116cca09142cb6fe9f8f9 | ztxm/Python_level_1 | /lesson4/task2.py | 736 | 4.1875 | 4 | """
2) Представлен список чисел. Необходимо вывести элементы исходного списка, значения которых больше предыдущего элемента.
Подсказка: элементы, удовлетворяющие условию, оформить в виде списка. Для формирования списка использовать генератор.
Пример исходного списка: [300, 2, 12, 44, 1, 1, 4, 10, 7, 1, 78, 123, 55].
Ре... | false |
be3dd70643347324b6611aff9577ab07fe706d27 | guptaavani/Image-Filter | /Code.py | 887 | 4.1875 | 4 | #! /usr/bin/env python3
from PIL import Image
im=Image.open(input("Enter image path \n")) #Taking the image path as input and saving it to im
print("This is the original image you entered \n")
im.show() #Showing the original image
while(True):
n=int(input(" Enter 1 for black and white filter \n Enter 2 for ma... | true |
2d6678f45d8734eefe8ff7033927e0df2337bf39 | LimZheKhae/DPL5211Tri2110 | /Lab5.3.py | 1,024 | 4.125 | 4 | #Student ID :1201200825
#Student Name :Lim Zhe Khae
#display the menu
# ask user to enter their choice [1 or 2].
#if choice is 1 call function get_cm()
#if choice is 2 call function get_meter()
# Else print "Invalid choice"
# In get_cm();
#Get the value of centimetre from the user
# Call function cm_to_meter()... | true |
168774838d17c2fffdae061bfb064a9430102ce6 | pekkipo/DataStructures | /Queue/linkedqueue.py | 675 | 4.25 | 4 | from linkedlist import LinkedList
class LinkedQueue:
"""
This class is a queue wrapper around a LinkedList.
This means that methods like `add_to_list_start` should now be called `push`, for example.
"""
def __init__(self):
self.__linked_list = LinkedList()
def push(self, node):
... | true |
3da2bf281a303c2d0010173ffcf1441300c66c58 | patdflynn95/Recreational-Projects | /primefactors.py | 944 | 4.46875 | 4 | # Python program to print prime factors
import math
# A function to print all prime factors of
# a given number n
def primefactors(n):
if n < 2:
primefactors(int(input("Please choose a number greater than 1: ")))
return None
# First check if number is even
if n %... | true |
2220e3c8cd04f1a04524e4e0b9c8d0753695c0f7 | moura-pedro/CS106A | /assignment02/khansole_academy.py | 785 | 4.34375 | 4 | """
File: khansole_academy.py
-------------------------
Add your comments here.
"""
import random
GOAL = 3
def main():
correct = 1
while (correct <= GOAL):
num1 = random.randint(10, 99)
num2 = random.randint(10, 99)
answer = num1 + num2
print(f"What is {num1} + {num2}?")
... | true |
183e78aae1a73b7b0f9533b4874e06828c7a9233 | aditya0697/SortingAlgorithms | /merge_sort.py | 1,426 | 4.125 | 4 | #function of merge
def merge(arr, first, middle, last):
n1 = middle - first + 1
n2 = last - middle
left_array = [0]*n1
right_array = [0]*n2
for i in range(n1):
left_array[i] = arr[first+i]
for i in range(n2):
right_array[i] = arr[middle+1+i]
l_ptr = 0
r_ptr = 0
i=firs... | false |
ea7c6189e4214742f6ac654205a0687596bdc9a5 | Nithy-Sree/Crazy-Python- | /colorChanger tkinter.py | 938 | 4.3125 | 4 | # pip install tkinter
# random is built-in module in python
import tkinter as tk
import random
colours = [
'red', 'blue', 'green',
'pink','black', 'yellow',
'orange','white','purple',
'brown']
# create a GUI Window
root = tk.Tk()
# set the size of the window
root.geometry("400x400")... | true |
fe5710b591c22d818d09fe50e1b2a115ca424b42 | gauffa/mustached-dubstep | /wip/ch4ex10.py | 1,125 | 4.90625 | 5 | ## Matthew Hall
## ISY150
## Chapter 4
## Exercise 10
## 09/23/2013
##Write a program that calculates and displays a person's BMI. The BMI is
##often used to determine whether a person is overweight or underweight
##for their height.
##A person's BMI is calculated with the following formula:
##BMI = weight *... | true |
d7fba79908b4eca52d30955abdb6282c917b7e83 | gauffa/mustached-dubstep | /ch7/ch7ex7.py | 700 | 4.15625 | 4 | #Matt Hall
#ISY 150
#Chapter 7 Exercise 7
#10/14/2013
#Write a program that writes a series of random numbers to a file.
#Each random number should be in the range of 1 through 100.
#The application should let the user specify how many random numbers
#the file will hold.
import random
def main():
#take u... | true |
a0bf4ef24f31754d6916877dea5de800a6bb8a29 | gauffa/mustached-dubstep | /complete/ch3exr6.complete.py | 817 | 4.90625 | 5 | ## Matthew Hall
## ISY150
## Chapter 3
## Exercise 6
## 09/16/2013
##Write a program that calculates and displays a person's BMI. The BMI is
##often used to determine whether a person is overweight or underweight
##for their height.
##A person's BMI is calculated with the following formula:
##BMI = weight * ... | true |
59d2d20a01653c324ec54b86a61e6d15232eda93 | gauffa/mustached-dubstep | /complete/ch2exr9.complete.py | 2,585 | 4.4375 | 4 | ## Matthew Hall
## ISY150
## Chapter 2
## Exercise 9
## 09/05/2013
## Write a program that converts Celsius temperatures to Fahrenheit temperatures.
## The formula is as follows: F = (9/5) * C + 32 ##triple check this formula!
## The program should ask the user to enter a temperature in Celsius, and then
## display th... | true |
580f2b7cbc7424123d3c8d0a6ce57af596740384 | gauffa/mustached-dubstep | /ch9/ch9ex5.py | 2,746 | 4.53125 | 5 | #Matt Hall
#ISY 150
#Chapter 9 Exercise 5
#10/27/2013
#Write a program that asks the user to enter a 10-character telephone number in
#the format XXX-XXX-XXXX. The program should display the telephone number with any
#alphanetic characters that appeared in the orignal translated to their numeric
#equivalent. For examp... | true |
95950e0f1122293126a093150b3ae6154a305f49 | SusyVenta/TrigoPy | /radians_degrees_converter.py | 913 | 4.1875 | 4 | import math
def convert_to(number, to="radians"):
"""
:param number: number to convert
:param to: end unit of measure. default = 'radians'. Alternative = 'degrees'
:return: converted number
"""
if to == "degrees":
print("--------------- degrees to radians: deg * 180 / pi")
retu... | true |
44e548fe4582127455aab4aa14d5e87aca51b4a6 | Akshatha-Udupa/AITPL2108 | /larestofthree.py | 529 | 4.28125 | 4 | #largest of 3 numbers
a = 100
b= 500
c = 00
if a > b and a > c:
print("{0} is largest number".format(a))
elif b > c:
print("{0} is largest number".format(b))
else:
print("{0} is largest number".format(c))
#using function
def largest(a,b,c):
if a > b and a > c:
print("{0} is larg... | true |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.