blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
8ac16563cee211e7c1113b4f1d1b3c48a9bfa826
samuelluo/practice
/reverse_linked_list/reverse_linked_list.py
1,395
4.125
4
""" Given the head of a singly linked list, reverse it in-place. """ # --------------------------------------------------------- class Node: def __init__(self, val, next_=None): self.val = val self.next_ = next_ def build_linked_list(vals): head = Node(vals[0]) curr_ = head.next_ prev_...
false
ae9973f853a110f61828cc9302089d194db527ba
lynnemunini/TurtleCrossingGame
/player.py
788
4.1875
4
from turtle import Turtle STARTING_POSITION = (0, -280) MOVE_DISTANCE = 10 FINISH_LINE_Y = 280 UP = 90 # Create a turtle player that starts out at the bottom of the screen and listen for the "Up" keypress to move the # turtle north class Player(Turtle): def __init__(self): super().__init__() sel...
false
620369233f7cb25553ec58246c922b11cca6bbd4
msznajder/allen_downey_think_python
/ch3_ex.py
2,743
4.6875
5
""" Exercise 1 Write a function named right_justify that takes a string named s as a parameter and prints the string with enough leading spaces so that the last letter of the string is in column 70 of the display. """ def right_justify(s): print((70 - len(s)) * " " + s) right_justify("abba") """ Exercise 2 A fu...
true
3eeb1e6de050f71bc4ddbfb76b9c4e111f917c8c
adekunleayodele/test
/venv/Scratch2.py
503
4.15625
4
# num1 = float(input("Enter first number: ")) # oper = input("Enter operation: ") # num2 = float(input("Enter second number: ")) inport pexpert num1 = input("Enter first number: ") oper = input("Enter operation: ") num2 = input("Enter second number: ") import re import pexpect if oper == "+": print(num1 + num2) ...
false
3cf8c28b06e50bf446701066958e4e04079e777d
evural/hackerrank
/cracking/chapter1/is_unique_bitwise.py
535
4.15625
4
# 1. Initialize a checker variable to 0 # 2. For each character in the text, shift left bits of 1 # 3. If bitwise AND of this value returns a number other than 0, return False # 4. Bitwise OR this value with the checker variable def is_unique(text): checker = 0 for c in text: val = ord(c) - ord("a") ...
true
70e9075afd47443a993e4be807274629de87329d
Kevin8523/scripts
/python/python_tricks/class_v_instance_variables.py
1,110
4.15625
4
# Class vs Instance Variable Pitfalls # Two kind of data attributes in Python Objects: Class variables & instance variables # Class Variables - Affects all object instance at the same time # Instance Variables - Affects only one object instance at a time # Because class variables can be “shadowed” by instance variables...
true
701c22b62921af1315710489d3f1935a28079b07
burgonyapure/cc1st_siw
/calc.py
494
4.28125
4
def f(x): return { '+': int(num1) + int(num2), '-': int(num1) - int(num2), '*': int(num1) * int(num2), '/': int(num1) / int(num2) }.get(x, "Enter a valid operator (+,-,*,/)") while True: num1 = input("\nEnter a number,or press a letter to exit\n") if num1.isdigit() != True: break y = input("Enter ...
true
0e76971f4c57f194f05cbccf3803771fa24c9e02
hack-e-d/codekata
/sign.py
216
4.25
4
#to find if positive ,negative or zero n=int(input()) try: if(n>0): print("Positive") elif(n<0): print("Negative") else: print("Zero") except: print("Invalid Input")
true
a8c28d2602f9400fae0baad00135c1612187f4f9
tasnimz/labwork
/LAB 3.py
1,934
4.1875
4
##LAB 3 ##TASK 1 ##TASK 2 ##TASK 3 st = []; # Function to push digits into stack def push_digits(number): while (number != 0): st.append(number % 10); number = int(number / 10); # Function to reverse the number def reverse_number(number): # Function call to push number's...
true
56a99d737a1ae86f6b31a180c5bc9a319bf06461
Alenshuailiu/Python-Study
/first.py
202
4.1875
4
num=input('Enter a number ') print('The number you entered is ',num) num=int(num) if num > 10: print('you enter a number > 10') elif num > 5: print('you enter a number >5 <10') else: print('Others')
true
0501089bafc9bc2a488e9c4cf2e0689e26db6ff7
jenyton/Sample-Project
/operators.py
551
4.34375
4
##Checking the enumerate function print "##Checking the enumerate function##" word="abcde" for item in enumerate(word): print item for item in enumerate(word,10): print item mylist=["apple","mango","pineapple"] print list(enumerate(mylist)) ##Checking the Zip function print "##Checking the Zip function##" name = [...
true
915927d8c4cbf8a7e3637850d3b9d87b98be6c29
mithrandil444/Make1.2.3
/song.py
2,076
4.28125
4
#!/usr/bin/env python """ This is a Python script that will display the lyrics of a song """ # IMPORTS __author__ = "Sven De Visscher" __email__ = "sven.devisscher@student.kdg.be" __status__ = "Finished" # CONFIGURING I/O def main(): class Song: # Define class Song def __init_...
false
c2fbe51a4c53f968c64cf470c86ac1cf6b4b448d
TardC/books
/Python编程:从入门到实践/code/chapter-10/cats&dogs.py
361
4.15625
4
def print_file(filename): """Read and print a file.""" try: with open(filename) as f_obj: contents = f_obj.read() except FileNotFoundError: # msg = "The file " + filename + " does not exist!" # print(msg) pass else: print(contents) print_f...
true
b295d0857648ad8e09a8a484e58d4745ebe74b69
ChastityAM/Python
/Python-sys/runner_up.py
561
4.15625
4
#Given participants score sheet for University, find the runner up score #You're given n scores, store them in a list and find the score of the #runner up. list_of_numbers = [2, 3, 6, 6, 5] print(sorted(list(set(list_of_numbers)))[-2]) #or list2 = [2, 3, 6, 6, 5] def second_place(list2): list2.sort(reverse=True) ...
true
9673488c7cfc5abd1e0339bd5815615780fa8b07
ChastityAM/Python
/Python-sys/lists.py
721
4.21875
4
list_of_numbers = [1, 2, 3, 4, 5, 6, 7, 8] a = list_of_numbers[5] #selecting an index b = list_of_numbers[2:5] #slicing the list #doesn't include last index given in printout print(a) print(b) list_of_numbers[5] = 77 list_of_numbers.append(10) list_of_numbers.pop(4) #removes at this index, if not indi...
true
c4c1bc5ac2c4e5d28656af5dc987968d34c2feaa
ChastityAM/Python
/Python-sys/sqrt.py
231
4.25
4
import math #Create a function that takes a number n from the user. #Return a list containing the square of all numbers between 1 and n num1 = int(input("Please enter a number: ")) def sq_root(num1): return math.sqrt(num1)
true
0005a28c25142263623a6c52686bd0d1ef6def3f
afcarl/PythonDataStructures
/chapter4/exercise_7.py
410
4.25
4
def is_divisible_by_n(x,n): if type(x) == type(int()) and type(n)==type(int()): if x % n == 0: print "yes,"+str(x)+" is divisible by "+ str(n) else: print "no,"+str(x)+" is not divisible by "+str(n) else: print "invalid input" num1 = input("Please input a number ...
true
4a118fbc0b36030195ebc7067b6feb98de8c4945
afcarl/PythonDataStructures
/chapter6/exercise_3.py
606
4.3125
4
def print_multiples(n, high): #initialize and iterator i = 1 #while the iterator is less than high, print n*i and a tab while i <= high: print n*i, '\t', i += 1 print #print a new line def print_mult_table(high): #initialize an interator i = 1 #while the iterator is less...
true
4bad22567b2966e77af73848c19bb95542360a1a
gadi42/499workspace
/Lab4/counter.py
916
4.46875
4
def get_element_counts(input_list): """ For each unique element in the list, counts the number of occurrences of the element. :param input_list: An iterable of some sort with immutable data types :return: A dictionary where the keys are the elements and the values are the corresponding numb...
true
1fe469a732a79d1753a0a886cd9aa6273c84a1fa
RanjitThakur678/new-
/center.py
501
4.3125
4
# name = "Ranjit" # print(name.center(10,"!")) # name= input("enter your name :") # print(name.center(len(name)+8,"*")) def leap(year): "year -> 1 if leap year, else 0." if year % 4 == 0 and (year % 100 != 0 or year % 400 == 0): return f"{year} is a leapyear" return "Not a leap year" def _days_bef...
false
8874c382f717ef3828bda2da5763cb2d833f655b
mentekid/myalgorithms
/Permutations/permutations.py
1,092
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- """ Computes all possible permutations of [0...N-1] for a given N If you need the permutations of another array, just use N = len(alist) and then print alist[perm] for perm in p Author: Yannis Mentekidis Date: April 28, 2015 """ from time import clock import sys def all_...
true
567c3c71afd8baa107f1d3a3a9a130edbb2401f9
Coder2100/mytut
/13_1_input_output.py
2,484
4.4375
4
print("7.1. Fancier Output Formatting") year = 2016 event = 'referendum' print(f"Result of the {year} {event} was BREXIT.") print("The str.format()") yes_votes =42_572_654 no_votes =43_132_495 percentage_yes = yes_votes/(no_votes + yes_votes) results = '{:-9} YES votes {:2.2%}'.format(yes_votes, percentage_yes) p...
true
409f82a86c31c8a4c8d77cf70e817f0c74d64413
Ilya18322/Algoritmss
/2.1alg.lab.py
541
4.3125
4
import math def example (x, R): if x >= -4 and x <= -2: return x + 3 elif x >= -2 and x <= 4: return -(x/2) elif x >= 4 and x <= 6: return -2 elif x >= 6 and x <= 10: return math.sqrt((R ** 2) - (x - 8) ** 2) - 2 else: return("Значение н...
false
46a0a26d0c0ae7ae5eefcf51f5ef47e26d0d175f
gstroudharris/PythonAutomateTheBoringStuff
/Lessons/lists.py
866
4.28125
4
#purpose: place items in a list, put them in a function, then call them myLists = [['Grant', 'Dana', 'ListItem3'], [10, 20, 35]] #index evaluates to a single item at a time print((myLists[0][0]) + str((myLists[1][-2]))) #slice will evaluate to a a whole list print(myLists[1:2]) #replace an item in the list myList...
true
73a636efa993e4df41d2e0d86f14af29d31a8817
eshaang/assignments1
/y.py
1,287
4.1875
4
angle1 = int(input("Enter angle one: ")) angle2 = int(input("Enter angle two: ")) angle3 = int(input("Enter angle three: ")) angletotal = angle1+angle2+angle3 if angletotal == 180: if angle1 == 60 and angle2 == 60 and angle3 == 60: print("equilateral") elif angle1 == angle2 or angle2 == angle3 or angle1 == an...
false
802a63767ddf4ac4449b11045c4e5ee1b2f69e04
Hoverbear/SPARCS
/week4/board.py
1,386
4.125
4
def draw_board(board): """ Accepts a list of lists which makes up the board. Assumes the board is a list of rows. (See my_board) """ # Draw the column indexes. print(" ", end="") for index, col in enumerate(board): # Print the index of each column. # Note: sep="", end="" p...
true
2157ab6936bd0e03959d122e9cc4a0c6908081fd
Hoverbear/SPARCS
/week2/2 - Loops.py
2,579
4.90625
5
# Loops! Loops! Loops! # The above is an example of a loop. Loops are for when you want to do something repeatedly, or to work with a list. # First, some useful things for us to know. my_range = range(10) # This creates an "iterator" which is sort of like a list, in fact, we can use a cast to make a list out of it. pr...
true
3428bb3e2794381738752bb1a368b196fcebee13
14E47/Hackerrank
/30DaysOfCode/day9_recursion3.py
302
4.125
4
#!/bin/python3 import math import os import random import re import sys # Complete the factorial function below. def factorial(n): if n<=1: return 1 else: fac = n*factorial(n-1) return fac n = int(input("Enter factorial no. :")) result = factorial(n) print(result)
true
8d5203e99f35aabfa5710bfae36ba6cc47c479b6
HebertFB/Curso-de-Python-Mundo-1-Curso-em-Video
/Curso de Python 3 - Mundo 1 - Curso em Video/ex010.py
342
4.125
4
"""Crie um programa que leia quanto dinheiro uma pessoa tem na carteira e mostre quantos dólares ela pode comprar""" reais = float(input('Informe quantos Reais a ser convertido para Dólar: ')) cotacao = float(input('Informe a cotação atual do Dólar: ')) print(f'R${reais:.2f} Reais convertidos dará US${reais/cotacao:....
false
a9dc59b43b89dc12b5f2887a61e1857e0affaaa6
HebertFB/Curso-de-Python-Mundo-1-Curso-em-Video
/Curso de Python 3 - Mundo 1 - Curso em Video/ex009.py
508
4.34375
4
"""Faça um programa que leia um número Inteiro qualquer e mostre na tela a sua tabuada""" num = int(input('Informe um número: ')) print(f'=' * 11) print(f'{num} X {1:2} = {num*1}') print(f'{num} X {2:2} = {num*2}') print(f'{num} X {3:2} = {num*3}') print(f'{num} X {4:2} = {num*4}') print(f'{num} X {5:2} = {num*5}') pr...
false
0d19a01a43ef753af9eb1f9f09817c86e99f0dec
jacobbathan/python-examples
/ex8.10.py
344
4.25
4
# a string slice can take a third index that specifies the 'step size' # the number of spaced between successive characters # 2 means every other character # 3 means every third # fruit = 'banana' # print(fruit[0:5:2]) def is_palindrome(string): print(string == string[::-1]) is_palindrome('racecar') ...
true
e857a43a220a5e158610933d8f478046e6559ae8
sheikh210/LearnPython
/functions/challenge_palindrome_sentence.py
345
4.1875
4
def is_palindrome(string: str) -> bool: return string[::-1].casefold() == string.casefold() def is_sentence_palindrome(sentence: str) -> bool: string = "" for char in sentence: if char.isalnum(): string += char return is_palindrome(string) print(is_sentence_palindrome("Was it a...
true
e4e6df7f0136d45eaa671d592b74fe4767774cfe
sheikh210/LearnPython
/functions/challenge_fizz_buzz.py
1,549
4.3125
4
# Write a function that returns the next answer in a game of Fizz Buzz # You start counting, in turn. If the number is divisible by 3, you say "fizz" instead of the number # If the number if divisible by 5, you say "buzz" instead of the number # If the number is divisible by 3 & 5, you say "fizz buzz" instead of the nu...
true
7f5ade077d195863562b3d90d89cf9bebd1d715b
sheikh210/LearnPython
/data_structures/sets/sets_intro.py
1,506
4.25
4
# Sets are unordered and DO NOT contain any duplicate values - Think of sets like a collection of dictionary keys # Elements in a set MUST be immutable (hashable) # DEFINING A SET # ********************************************************************************************************************** # Method 1 - Decla...
true
b56f52a7d452b41506df0b0aba26f8566c2bdc29
trahnagrom/controlled-assessment
/currency-converter2.py
2,102
4.3125
4
currencies= { "Pound Sterling": 1, "Euro": 1.2, "US Dollar": 1.6, "Japanese Yen": 200 } short_hand = { "GBP": "Pound Sterling", "EUR": "Euro", "USD": "US Dollar", "JPY": "Japanese Yen" } c_type1 = raw_input("What Currency are you converting from? GBP/EUR/USD/JPY: ") if ...
false
74269318512c52a38151a35698b3d2e711412bf2
MATTPostx/First
/dat.py
775
4.1875
4
y = "John" print(y) cars = {"Ford", "Volvo", "BMW"} cars.append(cars) for x in cars: print(x) def my_name(): print("hello") my_name() # print(array) # for array in cars: # print(array) # first_number = int(input('Type the first number:')) ;\ # second_number = int(input('Type the second number: ')) ;\...
false
426ed7b6a1db968eac60457221f26c16c3e79887
meechaguep/MCOC-Intensivo-de-Nivelacion
/21082019/000352.py
1,307
4.40625
4
print "Este dia estudiaremos listas" #intento 1 lista1= [14,21,3,-14,-21,-3] print "la lista es:" print lista1 #intento 2 print "agreguemos un numero a la lista" lista1= [14,21,3,-14,-21,-3] lista1.append(1313) print lista1 #intento 3 print "ahora agreguemos una frase a esta lista de numeros" ...
false
db0254a976f098a879546af4851e65a579cdfa5b
meechaguep/MCOC-Intensivo-de-Nivelacion
/29082019/014008.py
2,592
4.1875
4
import numpy as np #intro to numerical computing with numpy l1= [1,3,5,7] l2= [9,11,13,15] print l1 + l2 #agrega l2 a l1 suma_entre_elementos= [] for elemento1, elemento2 in zip(l1, l2): suma_entre_elementos.append(elemento1+elemento2) print suma_entre_elementos #se suma cada elemento gg = l...
false
82cb1fd257e84ba308a2bcf20d6450cfd8fda462
spuentesv/condicionales_python
/ejercicios_profunidzacion/profundizacion_2.py
1,797
4.25
4
# Condicionales [Python] # Ejercicios de profundización # Autor: Inove Coding School # Version: 2.0 # NOTA: # Estos ejercicios son de mayor dificultad que los de clase y práctica. # Están pensados para aquellos con conocimientos previo o que dispongan # de mucho más tiempo para abordar estos temas por su cuenta. # R...
false
0a24d97defcca7fe24bcaec53337ba790151a76f
crystalballz/LearnPythonTheHardWay
/ex3.py
700
4.46875
4
print "I will now count my chickens:" # Hens and Roosters are counted separately print "Hens", 25 + 30 / 6 print "Roosters", 100 - 25 * 3 % 4 # Not too many eggs since there are more Roosters than Hens print "Now I will count the eggs:" print 3 + 2 + 1 - 5+ 4 % 2 - 1 / 4 + 6 # Verifies if the statement that follows is...
true
89d5d07376abc2813ef4c5d556aed9c0e55ba21b
Chitranshuvarshney/Stone-Paper-Scissor-Game
/game.py
1,072
4.21875
4
import random # This is the stone, Paper & Scissor Game! def gameWin(comp, you): if comp == you: return None elif comp == 'stone': if you=='paper': return True elif you=='scissor': return False elif comp == 'paper': if you=='stone': ...
false
64c14de2c423cebafdbd7cc8b4869bd3724c0a4e
ninsamue/sdet
/python/act_4.py
1,487
4.25
4
print("ROCK PAPER SCISSORS") print("-------------------") Name1 = input("Enter Player 1 Name : ") Name2 = input("Enter Player 2 Name : ") player1Score=0 player2Score=0 play="Y" while play=="Y": player1Choice = input(Name1+"'s choice - Enter rock/paper/scissors : ").lower() player2Choice = inp...
true
4cc104ae49f21d9ca55166c2aa5149e646dfda4d
mrparkonline/ics4u_solutions
/10-06-2020/letterHistogram.py
1,080
4.3125
4
# Write a program that reads a string and returns a table of the letters of the alphabet in alphabetical order which occur in the string together with the number of times each letter occurs. Case should be ignored. def letterHistogram(word): ''' letterHistogram tracks the occurance of each alpha characters ...
true
5e018f447d9d13832317ee5720012440a9c73c7c
mrparkonline/ics4u_solutions
/09-14-2020/factoring.py
731
4.3125
4
# 09/14/2020 # Factoring Program num = int(input('Enter a number you want the factors for: ')) # While Loop Solution divisor = 1 while divisor <= num: # we are checking all numbers from 1 to inputted num if num % divisor == 0: # when num is divided by divisor the remainder is 0 ...
true
78fcf013af9f568d0314b181d721acb49cb0f59a
mrparkonline/ics4u_solutions
/10-06-2020/numDict.py
1,333
4.34375
4
''' Q4a) Write a Python program to sum all the items in a dictionary Q4b) Write a Python program to multiply all the items in a dictionary Q5a) Create a function that sorts a dictionary by key → Create a sorted list of keys. Q5b) Create a function that sorts a dictionary by value → Create a sorted list of values....
true
3c91e7f0397bac3d0f7684e95642afbf6183a74d
mrparkonline/ics4u_solutions
/10-19-2020/binarySearch.py
1,119
4.15625
4
# Binary Search Non recursive def binSearch(data, target): left = 0 right = len(data) - 1 while left <= right: middle = (left + right) // 2 if data[middle] == target: return middle elif data[middle] < target: left = middle + 1 else: ...
true
71c8bdc6bf5b8561a8306cf147b782a3266d8bf5
ask-ramsankar/DataStructures-and-Algorithms
/stack/stack using LL.py
1,217
4.15625
4
# creates a node for stack class Node: def __init__(self, data, prev=None): self.data = data self.prev = prev self.next = None class Stack: # initialize the stack object with the top node def __init__(self, data): self.top = Node(data) # push the data to the...
true
6857698560aa61ddccd54c02d71f57b57be8644c
ask-ramsankar/DataStructures-and-Algorithms
/queue/queue using LL.py
1,050
4.125
4
# Node of the queue class Node: def __init__(self, data): self.data = data self.next = None class Queue: # Initialize the queue with the first node def __init__(self, data): self.first = Node(data) # add a node to the queue at last def enqueue(self, data): curre...
true
49d736d6ff76a50557fa392b76d059e7f7d3ad92
jodr5786/Python-Crash-Course
/Chapter 4/4-12.py
289
4.25
4
# More Loops my_foods = ['pizza', 'falafel', 'carrot cake'] friend_foods = my_foods[:] print("My favorite foods are:") for my_food in my_foods: print("- " + my_food) print("\nMy friend's favorite foods are:") for friend_food in friend_foods: print("- " + friend_food)
false
1d86a1f0c018922cff28368903e4a99a1eea139f
jodr5786/Python-Crash-Course
/Chapter 4/4-10.py
329
4.1875
4
# Slices my_foods = ['pizza', 'falafel', 'carrot cake', 'cannoli', 'fish', 'lobster'] friend_foods = my_foods[:] print("\nThe first 3 items in my list are:") print(my_foods[:3]) print("\nThe items in the middle of my list are:") print(my_foods[1:5]) print("\nThe last 3 items in the list are:") print(my_fo...
true
0fc4f859e6d60da22006879b49579dbeb0dd8f6c
noahtigner/InterviewPrep
/CrackingTheCodingInterview/2-LinkedLists/2.4-partition.py
1,449
4.25
4
class Node: def __init__(self, data): self.data = data self.next = None class LinkedList: # Singly Linked def __init__(self): self.head = None def insert(self, data): # O(1) if not self.head: self.head = Node(data) else: n = self...
false
a144ce02685932552a3379d5b6997b3fa01504b4
1411279054/Python-Learning
/Data-Structures&Althorithms/力扣算法/四月份算法题/旋转矩阵.py
1,679
4.15625
4
## 题目:旋转矩阵() import pandas import copy class Solution: ##利用pandas求解 def rotate(self, matrix): """ Do not return anything, modify matrix in-place instead. """ matrix2 = pandas.DataFrame(matrix) num = matrix2[0].size for i in range(num): matrix[i] =matr...
false
9073f99a3d78244b516d34730f0321e01e80f341
ravindra-lakal/Python_new
/mak.py
912
4.3125
4
################################### #1 Find the last element of a list. list = ['a','b','c','d'] #validation list =[] print list[-1:] #print "list[4]",list[4] #2 Find the last but one element of a list. list =['z','w','e','i','t','l','e','t','z','t','e','s'] #validation list=[1] print list[-2:-1] #3 1.03 (*) ...
true
78d323b942aa57366d3a8eb4c9f58bb439f7b66d
Allegheny-Computer-Science-102-F2020/cs102-F2020-slides
/src/fibonacci-generator.py
233
4.125
4
def fibonacci_generator(n): a = 1 b = 1 for i in range(n): yield a a, b = b, a + b print(fibonacci_generator) for fibonacci_value in fibonacci_generator(10): print(fibonacci_value, end=" ") print()
false
000e177fda7bf009742ef757bdd466249e42bd9a
nyeddi/Adv-Python
/class_method_.py
1,745
4.46875
4
class Shape(object): # this is an abstract class that is primarily used for inheritance defaults # here is where you would define classmethods that can be overridden by inherited classes @classmethod def from_square(cls, square): # return a default instance of cls return cls() c...
true
c21643f5c58676f77da8ffbc14d3dc488c5b0d8e
saadkang/PyCharmLearning
/basicsyntax/indexvstring.py
2,088
4.40625
4
""" We will see how the index works in python """ nameOfAString = "This is for educational purposes only" # The : in the [] is has no starting and ending index so it will print the whole String print("There is nothing before or after the : so it will print complete String: "+nameOfAString[:]) # In the example below ...
true
445befab60ef2ad7e87ec1b5ce54925ace4977b8
saadkang/PyCharmLearning
/basicsyntax/tuplesdemo.py
1,493
4.5
4
""" Tuple Like list but they are immutable that means you can't change them """ # What the above line in green is trying to say is that list (also called Array in Java) can be changed # Like in the example below: # The list or Array is defined by the [] my_list = [1, 2, 3] print(my_list) my_list[0] = 0 print(my_list) ...
true
0bb7a577e6dc036a4607eaac1f46ebb10d066b54
saadkang/PyCharmLearning
/basicsyntax/list_demo.py
467
4.1875
4
""" Now, we are going to talk about the list in python """ cars = ["BMW", "Honda", "Audi"] empty_list = [] print(empty_list) print(cars) print("*"*20) print(cars[0]) print("*"*20) print(cars[1]) print("*"*20) print(cars[2]) print("*"*20) numList = [1, 2, 3] sumList = numList[0] + numList[1] print(sumList) print("*"*20...
false
bf1a776903b0befb342dd7b8a8ea0b26d2b307dd
cnrmurphy/python-lessons
/exercises/session_1/calc.py
2,685
4.21875
4
''' Exercise: Implement a basic calculator that supports add,subtract,multiply,divide Basic requirements: four functions that perform the aforementioned operations will suffice. Extending: Implement a function, calculator, that takes 3 inputs: operation (string), num_a, and num_b. the function, calculator, should...
true
a5c1932418534132648d77c240e64e839244fd70
aditparekh/git
/python/lPTHW/ex3.py
460
4.375
4
print 'I will not count my chickens:' print "Hens", 25+30/6 print "Roosters", 100-25*3%4 print 'Now I will coung the eggs:' print 3+2+1-5+4%2-1/4+6 print 4//3 print "is it true that 3+2<5-7" print 3+2<5-7 print "Waht is 3+2?",3+2 print "Waht is 5-7?",5-7 print "Ph, that's why it's False" print "How abot some mo...
true
2badc0380cce0cef6f0b76a76d6164e6f6b51d39
aditparekh/git
/python/lPTHW/ex25.py
837
4.28125
4
def break_words(stuff): """This function will break up words for us""" words = stuff.split(" ") return words def sort_words(words): """Sorts the words""" return sorted(words) def print_first_word(words): """Prints the firs word after popping it off""" word=words.pop(0) print word def print_last_words(words):...
true
d96410728328d7382eefaae6929001873fefa702
ajaymatters/scripts-lab
/script-lab/python-scripts/PartA7/pa7.py
519
4.15625
4
def AtomicDictionary(): atomic = {"H":"Hydrogen", "He":"Helium", "N":"Nitrogen"}; x = input("Enter symbol ") y = input("Enter element name ") if x in atomic.keys(): print("Key already exists. Value will be updated") else: print("New Key with Value added") atomic[x] = y print(atomic) print("Number of el...
true
eeef454dbb42b30cc1c25f99d59a4a5ca9719aae
voodoopeople42/Vproject
/Janus/python-base-unit_11/oop/oop.constructor.test.py
896
4.1875
4
# oop.constructor.test.py # class Person: # def __init__(self, first_name, last_name): # self.first_name = first_name # self.last_name = last_name # конструктор класса не позволит создать объект без обязательных полей: # sam = Person("Sam", "Brown") # print(sam.first_name, sam.last_name) # class...
false
45c036e33d642d8ada09272dec7152a87dea512b
Sridhar-S-G/Python_programs
/Extract_numbers_from_String.py
370
4.125
4
''' Problem Statement A string will be given as input, the program must extract the numbers from the string and display as output Example 1: Input: Tony Stark's daughter says 143 3000 Output: 143 3000 Example 2: Input: There4 I think you will be satis5ed with this tutorial Output: 4 5 ''' #Solution Code import re s=...
true
3c4f4279850d8e2f0bb240fa3c2703b54f2796bc
simiss98/PythonCourse
/UNIT_1/Module1.2/MOD01_1-2.2_Intro_Python.py
1,583
4.21875
4
#creating name variable name = "Petras" # string addition print("Hello " + name + "!") # comma separation formatting print("Hello to",name,"who is from Vilnius.") print("Hello to","Petras","who is from Vilnius.") # [ ] use a print() function with comma separation to combine 2 numbers and 2 strings print("I was born at...
true
9e4156f225546d0808d225b5078af06a872acff6
simiss98/PythonCourse
/UNIT_1/Module4.1/MOD04_1-6.1_Intro_Python.py
1,981
4.15625
4
#Task1 # [ ] Say "Hello" with nested if # [ ] Challenge: handle input other than y/n print("Please Say Hello") hello_decision=input('"y" for yes or "n" for no: ' ) print() #1st nested if if hello_decision.lower()=="y": #select hello type print("Please select hello type.") hello_type = input('"hello" for full ...
false
6c19170153ee9669fbafe02192606989d031e7a5
simiss98/PythonCourse
/UNIT_1/Module1.1/MOD01_1-1.4.py
2,115
4.375
4
Task1 #creating x,y and z integer variables and then adding then calculating sum of 3 integers. x=1 y=2 z=3 x+y+z # displaying sum of float and integer. 65.7+4 #creating string name variable and then using print just for fun to display both strings. name="Evaldas" print("This notebook belongs to "+name) #creating sm_nu...
true
5d22d099a117896b83c84babf34a3916a06504fc
Futi7/AnagramChecker
/main.py
1,949
4.1875
4
class AnagramChecker: list_of_strings = [] first_string_keys = {} second_string_keys = {} list_of_keys = [first_string_keys, second_string_keys] def __init__(self, first_string, second_string): self.list_of_strings.append(first_string) self.list_of_strings.append(second_string) ...
true
9498fe8866498ef6be30b8d8967dad971f09d801
charanchakravarthula/python_practice
/Baics.py
499
4.3125
4
# variable assignment var = 1 print(var) # multiple values assignment to a variable var1,var2 =(1,2) print(var1,var2) #ignoring unwanted values var1,__,__=[1,2,3] print(var1) var1=var2=var3=1 print(var1,var2,var3) # knowing the type of the varible i.e data type of variable var1=[1,2,3] var2=('a',"b","c") var3=1...
true
e3e76c37ff817bae9836c142f0a7113ede554505
bang103/MY-PYTHON-PROGRAMS
/PYTHONINFORMATICS/DictDayOfWeek.py
871
4.25
4
#Exercise 9.2 in Python for INformatics #Exercise 9.2 Write a program that categorizes each mail message by which day of #the week the commit was done. To do this look for lines which start with *From*, #then look for the third word and then keep a running count of each of the days #of the week. At the end of the p...
true
adc3327fe24e67694446fd98f023306cafd012d2
bang103/MY-PYTHON-PROGRAMS
/WWW.CSE.MSU.EDU/STRINGS/Cipher.py
2,729
4.25
4
#http://www.cse.msu.edu/~cse231/PracticeOfComputingUsingPython/ #implements encoding as well as decoding using a rotation cipher #prompts user for e: encoding d: decoding or q: Qui import sys alphabet="abcdefghijklmnopqrstuvwxyz" print "Encoding and Decoding strings using Rotation Cipher" while True: o...
true
dc6af3be13be922128409b78b11cec0001d236ae
judy1116/pythonDemo
/Tester/err_raise.py
2,257
4.15625
4
#因为错误是class,捕获一个错误就是捕获到该class的一个实例。因此,错误并不是凭空产生的,而是有意创建并抛出的。Python的内置函数会抛出很多类型的错误,我们自己编写的函数也可以抛出错误。 #如果要抛出错误,首先根据需要,可以定义一个错误的class,选择好继承关系,然后,用raise语句抛出一个错误的实例: # err_raise.py class FooError(ValueError): pass def foo(s): n = int(s) if n==0: raise FooError('invalid value: %s' % s) retu...
false
0359b15055f14630eac6508c0864216f3ad89225
judy1116/pythonDemo
/OOPAdvance/create_class_on_the_fly.py
2,151
4.375
4
#type() #动态语言和静态语言最大的不同,就是函数和类的定义,不是编译时定义的,而是运行时动态创建的。 #比方说我们要定义一个Hello的class,就写一个hello.py模块: class Hello(object): def hello(self,name='world'): print('Hello,%s.'%name) #当Python解释器载入hello模块时,就会依次执行该模块的所有语句,执行结果就是动态创建出一个Hello的class对象,测试如下: #from hello import Hello h=Hello() print(h.hello()) print(t...
false
a2d0a206f388c10fa50dfc51041efd4fd85bc34b
judy1116/pythonDemo
/FuncCode/doSorted.py
886
4.375
4
#Python内置的sorted()函数就可以对list进行排序: print(sorted([36,5,-12,9,-21])) #sorted()函数也是一个高阶函数,它还可以接收一个key函数来实现自定义的排序,例如按绝对值大小排序: print(sorted([36,5,-12,9,-21],key=abs)) print(sorted(['bob', 'about', 'Zoo', 'Credit'])) #我们给sorted传入key函数,即可实现忽略大小写的排序: print(sorted(['bob', 'about', 'Zoo', 'Credit'],key=str.lower)) #要进行反向...
false
27e4ef0d8bb177a902727eabc24249c933fbb6e2
AO-AO/pyexercise
/ex8.py
653
4.4375
4
""" Define a function called anti_vowel that takes one string, text, as input and returns the text with all of the vowels removed. For example: anti_vowel("Hey You!") should return "Hy Y!". """ def anti_vowel(text): result = "" lenth = len(text) for i in xrange(0, lenth): if i == 0: r...
true
6dad0e0b1ac99cd489e20a297b8b9929a6d8b77e
Trollernator/Lesson
/app.py
929
4.25
4
#variable #data types int, float, str #input(), print(), type() # len() shows the lenght of str # upper() makes the letters BIG # lower() makes the letters smol # capitalize() captitalize the first letter # replace() replace certain letters # FirstName="Tom" # print(FirstName.find("enter search")) # a=58 # b=108 # if ...
true
df6dc1e87f1a2861224107bbba1c901a0b89e094
rajeshvermadav/XI_2020
/character_demo.py
376
4.3125
4
#program to display indivual character name = input("Enter any name") print("Lenght of the string is :", len(name)) print("Location or memmory address of the Character :",len(name)-1) print("Character is :", name[len(name)-6]) print("Substring is :",name[1]) print("Substring is :",name[-1]) print("Substring ...
true
841d3b45c6dd57d8fccbfcc984c26677fe96107e
rajeshvermadav/XI_2020
/relationoper_demo.py
414
4.1875
4
#Relational Operator Demo Program a = int(input("Enter First Number:-")) b = int(input("Enter Second Number:-")) print("A>B is :", a>b) #Greater than print("A<B is :", a<b) #Less than print("A===B is :", a==b) #Equal to print("A!=B is :", a!=b) #Not equal to print("A>=B is ...
false
4849a377f3eb05b5e074e959b1aaf16793754daf
rajeshvermadav/XI_2020
/sample3no_if.py
498
4.15625
4
#Program to input three numbers calculate sum of numbers and non duplicate numbers s1 = s2 = 0 a = int(input("Enter first number: ")) b = int(input("Enter Second number: ")) c = int(input("Enter Third number: ")) s1 = a + b + c if a != b and a != c: s2= s2 + a print(a) if b!= a and b != c: s2 = s2 ...
false
cdc710c7c64c2029fa2b53f210689162fcaf1931
acs/python-red
/leetcode/two-sum/two-sum.py
746
4.15625
4
from typing import List, Tuple def twoSum(nums, target): twoSumTargetTuples = [] for (i, number) in enumerate(nums): for otherNumber in nums[i+1:]: print(number, otherNumber) # Move this logic to a function if (number + otherNumber) == target: if [nu...
true
7f8b3ceeff28f59b0b186d3b3dbd8a7bafd24fdc
Environmental-Informatics/building-more-complex-programs-with-python-roccabye
/Program_7.1.py
2,669
4.375
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Tue Jan 28 09:55:50 2020 Lab Assignment02 ThinkPython 2e, Chapter 7: Exercise 7.1 This program finds the Square Root of a number by using the famous newton's Method approach and using the function from 'math' library. And compares the absolute values estimat...
true
1d21943dace332bd3f0e6a601808cdbb9bf9fe72
Gchesta/assignment_day_2
/fizz_buzz.py
341
4.1875
4
def fizz_buzz(entry): if entry % 3 == 0 and entry % 5 == 0: #tests for numbers that are divisible by both three and five return "FizzBuzz" elif entry % 3 == 0: #tests for numbers that are divisible by three return "Fizz" elif entry % 5 == 0: #tests for numbers that are divisible by five return "Buzz" e...
false
d6aa20a31894a3f6e94e0d964de05c0e2c232f50
RuthieRNewman/hash-practice
/hash_practice/exercises.py
2,735
4.125
4
#This is a solution that I worked out with a study group hosted by a TA and Al. It was working #until I made some changes and now I cant seem to figure out what I did or how it was #really working in the first place. I will continue to work on it but I didnt feel it was worthy #turning in fully. def anagram_he...
true
f43686010662ea48a1eb685b277f3b991b2d9092
angminsheng/python-learn
/data-type.py
983
4.15625
4
user_age = int(input("What is your age?")) user_age_month = user_age * 12 print(f"you are {user_age}years old or {user_age_month} months old.") l = ["bob", "john", "sally"] t = ("bob", "john", "sally") h = {"bob", "john", "sally"} l.append("rosie") h.add("molly") friends = {"bob", "ken" , "simon"} other_friends = {...
false
9958cd212de0d2c36d608a088f100429c95dd6ff
jadeaxon/hello
/Python/generator.py
772
4.46875
4
#!/usr/bin/env python # Python has special functions called generators. # All a generator is is an object with a next() method that resumes where it left off each time it is called. # Defining a function using yield creates a factory method that lets you create a generator. # Instead of using 'return' to return a valu...
true
711b0da87e3c90aa3fd25c9d902d2c8433d796ea
jadeaxon/hello
/Python 3/interview/singly_linked_list.py
2,260
4.21875
4
#!/usr/bin/env python3 """ A singly-linked list class that can be reversed in place. Avoids cycles and duplicate nodes in list. """ class Node(object): """A node in a singly-linked list.""" def __init__(self, value): self.next = None self.value = value class SinglyLinkedList(object): """A...
true
ea91e41e939909b6d58f425c36b4f4203ce7de72
jadeaxon/hello
/Python/LPTHW/example33.py
315
4.15625
4
#!/usr/bin/env python i = 0 numbers = [] while i < 6: print "At the top, i is %d." % i numbers.append(i) # i++ -- Are you joking? No ++ operator!!! i += 1 print "Numbers now: ", numbers print "At the bottom, i is %d" % i print "The numbers: " for number in numbers: print number
true
af1558e78172d696613b99a8a110d69ba8751db2
SheezaShabbir/Python-code
/Date_module.py
546
4.4375
4
#Python Dates #A date in Python is not a data type of its own, but we can import a module named datetime to work with dates as date objects. #Example #Import the datetime module and display the current date: import datetime x = datetime.datetime.now() print(x.year) print(x.strftime("%A")) print(x) x = da...
true
f07443f0174818f2a9abadcd724ce6b60d9ebdd1
SheezaShabbir/Python-code
/finaltestithink.py
889
4.1875
4
def str_analysis(pass_argument): if(pass_argument.isdigit()): int_conversion=int(pass_argument) if(int_conversion>90): printvalue=str(int_conversion)+" "+"is pretty big number." return printvalue elif(int_conversion<90): printvalue=str(int_conversion)+" "+"is p...
true
6a20b87f76f5e01dab9552208c1a42b197199e9a
jmavis/CodingChallenges
/Python/DecimalToBinary.py
1,796
4.3125
4
#--------------------------------------------------------- # Author: Jared Mavis # Username: jmavis # Problem name: Decimal To Binary # Problem url: https://www.codeeval.com/open_challenges/27/ #--------------------------------------------------------- import sys import math #-------------------------------...
true
b2d2dd3baed364c81e22d193586c21f0abbd56d0
jmavis/CodingChallenges
/Python/Star.py
898
4.4375
4
#------------------------------------------------------------------------------ # Jared Mavis # jmavis@ucsc.edu # Programming Assignment 2 # Star.py - Creates an n-pointed star based on user input #------------------------------------------------------------------------------ import turtle numPoints = int(inpu...
true
daaf1572ef7bf3971cd3a1e27c3397622aa0a172
schoentr/data-structures-and-algorithms
/code-challanges/401_code_challenges/linked_list/linked_list.py
2,852
4.25
4
from copy import copy, deepcopy class LinkedList(): head = None def __init__(self, iterable=None): """This initalizes the list """ self.head = None if iterable: for value in iterable: self.insert(value) def __iter__(self): """This makes...
true
78a6e7972a8960932922e1aad5982183086a8670
schoentr/data-structures-and-algorithms
/code-challanges/401/trees/fizzbuzz.py
809
4.15625
4
from tree import BinaryTree def fizzbuzz (self, node = None): """ This Method traverses across the tree in Order. Replacing the value if divisable by 3 to Fizz, if divisibale by 5 to buzz and if divisiable by both 3 and 5 to fizzbuzz """ rtn = [] if node is None: ...
true
8e3a079278d9a5c59df34cbbe77c2b10a47449f6
schoentr/data-structures-and-algorithms
/code-challanges/401_code_challenges/sorts/radix_sort/fooradix_sort.py
2,103
4.125
4
def radix_sort(inpt_list, base=10): """This sort takes in a list of positive numbers and returns the list sorted in place. Arguments: inpt_list {[list]} -- [Unsorted List] Keyword Arguments: base {int} -- [description] (default: {10}) Returns: [list] -- [Sorted List] """...
true
c0a814a1761bd9b11510500386eee4044f4f3d75
abhinab1927/Data-structures-through-Python
/ll.py
1,631
4.21875
4
class Node: def __init__(self,val): self.next=None self.value=val def insert(self,val): if self.value: if self.next is None: self.next=Node(val) else: self.next.insert(val) else: self.v...
true
e556737d693fb598ee89751696aa05ff4b791e9a
moemaair/Problems
/stacks/python/sort_stack.py
2,680
4.1875
4
from Stack import Stack from Stack import build_stack_from_list """ Sort Stack Write a method to sort a stack in ascending order Approaches: 1) 3 stacks - Small, Large, Current 2) Recursive - Sort and Insertion Sort """ def sort_stack_recursive(stack): if len(stack) == 0: return ele...
true
176d58d5bd2b5c3148c3882d9010a9be36568071
moemaair/Problems
/strings/python/is_rotation.py
2,181
4.375
4
#Cases """ 1) Empty string 2) Normal is rotation 1-step 3) Normal is rotation multistep 4) Normal no rotation same chars 5) 1,2,3+ length 6) Strings not same length == False """ #Approaches """ 1) Submethod called "rotate" which rotates string one-place, main method rotates str2 len(str1) times, checks if strings are ...
true
e37c22e6e03c1a576b264ae00769edbf084fcc4b
moemaair/Problems
/graphs/python/pretty_print.py
1,411
4.125
4
from Graph import Graph from Graph import build_test_graph from Vertex import Vertex """ Pretty Print Starting with a single Vertex, implement a method that prints out a string representation of a Graph that resembles a visual web Approach: 1) Using BFS, extract all unique vertices from the graph into set 2) Loop ...
true
469a59d991f878a9a668df228b310a9d633a60f4
moemaair/Problems
/stacks/python/stacks_w_array.py
1,569
4.125
4
from Stack import Stack from Node import Node """ Stacks with Array Implement 3 stacks using a single array Approaches 1) Index 0, 3, 6.. first stack. 1, 4, 7.. second stack. 2, 5, 8.. third stack. """ class StacksWithArray(object): def __init__(self): self.array = [None for x in range(99)] # Represent next av...
true
1043391288e9b6b26e2feeff248cee4ebefcc085
moemaair/Problems
/stacks/python/evaluate_expression.py
2,374
4.3125
4
from Stack import Stack """ Evaluate Expression Evaluate a space delimited mathematical that includes parentheses expression. e.g. "( 1 + ( ( 2 + 3 ) * ( 4 * 5 ) ) )" == 101 Approaches: 1) Use two stacks, one for operators, one for operands. If you get to close paren?, then pop last two operands off and combine u...
true