blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
34cd3453ff8de1f95b60e93bd24e575870bcc669
Thiksha/Pylab
/prog7.py
439
4.21875
4
# Python program using NumPy # for some basic mathematical # operations import numpy as np # Creating two arrays of rank 2 x = np.array([[1, 2], [3, 4]]) y = np.array([[5, 6], [7, 8]]) # Creating two arrays of rank 1 v = np.array([9, 10]) w = np.array([11, 12]) # Inner product of vectors print(np.dot(v, ...
true
1359d33adaa10e2ba9022cc703ef855ccf7c9355
distracted-coder/Exercism-Python
/yacht/yacht.py
2,602
4.125
4
""" This exercise stub and the test suite contain several enumerated constants. Since Python 2 does not have the enum module, the idiomatic way to write enumerated constants has traditionally been a NAME assigned to an arbitrary, but unique value. An integer is traditionally used because it’s memory efficient. It is a...
true
2c28a743d2e170b3380b74bb4bec5d0867b6c373
rlawjdgus199/python
/python/chapter_03.py
1,136
4.40625
4
# Chapter03-1 # 숫자형 # 파이썬 지원 자료형 """ int : 정수 float : 실수 complex : 복소수 bool : 불린 str : 문자열(시퀀스) list : 리스트(시퀀스) tuple : 튜플(시퀀스) set : 집합 dict : 사전 """ # 데이터 타입 str1 = "Python" bool = True str2= 'Anaconda' float = 10.0 # 10 == 10.0 int = 7 list = [str1, str2] print(list) dict = { "name" : "Machine Learning", ...
false
669ed897002906ec966e9e6c7d06a97230402f0a
noalez/Assignment1
/Q3.py
1,371
4.21875
4
def compare_subjects_within_student(subj1_all_students, subj2_all_students): """ Compare the two subjects with their students and print out the "preferred" subject for each student. Single-subject students shouldn't be printed. Choice for the data structure of ...
true
48dba6ea3eab7303ec08688d1964730d12a64a51
affandhia/ifml-pwa
/main/utils/naming_management.py
1,875
4.125
4
import re def dasherize(word): """Replace underscores with dashes in the string. Example:: >>> dasherize("FooBar") "foo-bar" Args: word (str): input word Returns: input word with underscores replaced by dashes """ s1 = re.sub('(.)([A-Z][a-z]+)', r'\1-\2', word) ...
true
da8d524c61d86ce53ee5015ab6d9d577bba38054
DamianArado/OneDayOneAlgo
/odd-even.py
248
4.15625
4
#the given program is for brick sort/odd even sort arr=[2,1,3] for i in range(0,len(arr)-1,2): if(arr[i+1]<arr[i]): arr[i+1],arr[i]=arr[i],arr[i+1] for i in range(1,len(arr)-1,2): if arr[i+1]<arr[i]: arr[i+1],arr[i]=arr[i],arr[i+1] print(arr)
false
0c781cdc145f18c892b5eb8a6cfc5548451f1b85
abhishekk3/Practice_python
/monotonic_array.py
758
4.25
4
#Problem Statement: Given an array of integers, we would like to determine whether the array is monotonic (non-decreasing/non-increasing) or not. #Examples: #1 2 5 5 8->true #9 4 4 2 2->true #1 4 6 3->false #1 1 1 1 1 1->true def monotonic_arr(arr): num = arr[1] if arr [0] < arr [1]: ...
true
43a6ed3e8d2afe9b208f4d790d2c784593bb16ce
djangoearnhardt/Exercism
/acronym.py
254
4.15625
4
# Convert a long phrase to its acronym print("Enter your long phrase, and I'll convert it to an acronym.") str = input() # str = str.split() str_len = len(str) output = '' for i in str.upper().split(): output += i[0] print(f"Your acronym is", output)
true
c375d8474b784e3f52b30b6469c79ba237266ebb
acLevi/cursoemvideo-python
/Mundo 3 - Estruturas Compostas/Exercícios/EX088.py
950
4.15625
4
# Exercício Python 088: Faça um programa que ajude um jogador da MEGA SENA a criar palpites.O programa vai perguntar quantos jogos serão gerados e vai sortear 6 números entre 1 e 60 para cada jogo, cadastrando tudo em uma lista composta. from random import randint from time import sleep qnt = int(input('Quantidade de...
false
b3cb22cbf696e9f6f15007875200cee80562e244
acLevi/cursoemvideo-python
/Mundo 3 - Estruturas Compostas/Exercícios/EX075.py
920
4.3125
4
# Exercício Python 075: Desenvolva um programa que leia quatro valores pelo teclado e guarde-os em uma tupla. No final, mostre: # A) Quantas vezes apareceu o valor 9. # B) Em que posição foi digitado o primeiro valor 3. # C) Quais foram os números pares # Declarando a tupla nums = tuple() # Lendo os quatros números e...
false
b7805ef70e9bb17b571c33df2a615fb1148846f0
MarcoBertoglio/Sistemi-e-reti
/es_3_vacanze.py
486
4.21875
4
#Nella serie di Fibonacci, ciascun numero della serie è la somma dei due numeri nella serie che lo precedono, ad esempio: #1, 1, 2, 3, 5, 8, 13 (...) #Scrivi una funzione ricorsiva che restituisce in output i numeri della sequenza di Fibonacci, #entro una soglia specifica impostata dall'utente. def fibonacci(v...
false
b0df635bce8cec3906bce434e50bb3b2420bb360
MrsPsRobot/1-reposit-rio
/tulpas.py
753
4.4375
4
print ("Tuplas são como lista mas não pode adicionar e nem remover 1 objeto, apenas a tupla inteira") tuplas=("tiago", "Python","udemy") print(tuplas) print ("Quantidade de posições na tuplas") print (len (tuplas)) print("\nO que tem em qual posição tuplas[]") print("tuplas[0]",tuplas[0]) print ("tuplas[1]",tupl...
false
dd1f5d1c90422bbb32d0e1303b576e6b1ea25c38
RodrigoNeto/cursopythonyt
/aula3/aula3.py
633
4.40625
4
""" STR - String Linguagem de tipagem dinamica Tudo que estiver dentro de aspas simples ou duplas é consideravél uma string """ print('Essa é uma string') print("Essa é uma string") print("Essa é uma 'string' (str).") #Exemplo de string com aspas para exibição, serve para simples e dupla print('Essa é uma "s...
false
f3f454964a38f7dcada615b606faf856005691d5
shadumdum/basic-pyhthon-
/quiz.py
334
4.15625
4
nama = input("masukan nama:") umur = input("masukan umur:") alamat = input("masukan alamat anda:") print("nama saya adalah"+ " "+ nama) print("umur saya adalah"+ " "+ umur) print("alamat saya di"+ " "+ alamat) #problem di format print ("nama saya adalah {}, umur saya{},dan alamat saya di {}".format(nama,umu...
false
2ad6f815dbd3d0bdc29d9902486701b6790dbfa5
Emaasit/think-python
/card.py
1,757
4.5625
5
"""This is Chapter 18: Inheritance Learning Python programming using the book titled Think Python, 2nd Edition by Allen Downey http://thinkpython2.com Copyright 2017 Daniel Emaasit License: http://creativecommons.org/licenses/by/4.0/ """ from random import shuffle class Card: """Represents the cards in deck ...
true
71c6620a5721da6a501c998fe24e8809e5ba7961
tentao7/Python
/Learn+Python_Full+course+for+beginners-Copy1.py
952
4.15625
4
# coding: utf-8 # In[1]: print("hello world") # In[2]: print(" /l") print(" / l") print(" / l") print(" /___l") # In[3]: print("There once a man named George,") print("he was 70 years old.") print(" He reallly like the name George,") print("but did't like being 70.") # In[4]: character_name = "T...
false
166a849b4c82c1f0486cce56a0dcf17cf9e0ca9f
foureyes/csci-ua.0479-spring2021-001
/resources/code/class11/fraction.py
1,429
4.125
4
class Fraction: def __init__(self, n, d): self.n = n self.d = d # this means that this method can be called without instance # and consequently, no self is needed # instead, you call it on the actual class itself # Fraction.gcf() @staticmethod def gcf(a, b): # go t...
true
5ce4d0d839d165438d3149d00e6ceea0bd48d2fa
foureyes/csci-ua.0479-spring2021-001
/assignments/hw03/counting.py
593
4.46875
4
""" counting.py ===== use *while* loops to do the following: * print out "while loops" * use a while loop to count from 2 up-to and including 10 by 2's. * use another while loop to count down from 5 down to 1 use *for* loops to do the following: * print out "for loops" * use a for loop to count from 2 up-to and in...
true
c9f5850173477fdec74a2cf3eeaea216a5d221b7
foureyes/csci-ua.0479-spring2021-001
/_includes/classes/17/count.py
315
4.1875
4
def count_letters(letter, word): """returns the number of times a letter occurs in a word""" count = 0 for c in word: if c == letter: count += 1 return count assert 3 == count_letters("a", "aardvark"), "should count letters in word" assert 0 == count_letters("x", "aardvark"), "zero if no letters in word"
true
33827cee45fdaf7aa3210750392d51b51c4a58f9
foureyes/csci-ua.0479-spring2021-001
/resources/code/class04_return.py
766
4.375
4
""" return is a statement a value has to be on the right hand side that value can be an expression (that will be evaluated before the return) and it does 2 things: * immediately stops the function * gives back the value / expression to the right of it return statements have to be in a function they can be in a ...
true
2275341721c13fc2d71d67e2ffa1ea7d5cb81bcc
foureyes/csci-ua.0479-spring2021-001
/_includes/classes/18/caesar_encrypt_v3.py
738
4.25
4
def caesar_encrypt(s): """encrypts a string by rotating each letter 23 places to the right""" uppercase_start, lowercase_start = 65, 97 alphabet = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' shift = 23 translation = '' for c in s: letter_pos = alphabet.find(c.upper()) offset = (letter_pos + shift) % 26 if c.isupper(): ...
false
3df9bf90f72f82039043e5db9b15d36424e2a5b6
foureyes/csci-ua.0479-spring2021-001
/_includes/classes/15/factorial_iterative_version_user_input.py
214
4.21875
4
def factorial(n): product = 1 for i in range(n, 0, -1): product = product * i return product user_input = input("Give me a number, I'll give you the factorial\n>") num = int(user_input) print(factorial(num))
true
244f4199d414d124c61646de18df4e6cfa1f30b8
foureyes/csci-ua.0479-spring2021-001
/resources/code/class05.py
2,109
4.46875
4
# go over some of the "old" slides # try a sample "quiz" question(s) ... practice for the upcoming # field some homework questions # go over strings # or go over more intermediate level stuff w/ lists """ >>> def foo(bar): ... """ """foo will print out the argument passed in""" """ ... print(bar) ... >>> ...
true
0497b83fab0d8c6f4eb21717c2ffdb9f4717f926
foureyes/csci-ua.0479-spring2021-001
/resources/code/class07_redact_dna.py
1,561
4.21875
4
""" redact(words, illegal_words) word is a list of strings illegal_words also a list of strings if one of the strings in words exists in illegal words then "replace" the first three letters with dashes otherwise, word stays the same if less than 3, then all chars returns an entirely new list composed of censored word...
true
58a7b172b7f719eca24e0f98780dc5056daa0a3e
foureyes/csci-ua.0479-spring2021-001
/assignments/hw03/grade.py
1,073
4.5
4
""" grade.py ===== Translate a numeric grade to a letter grade. 1. Ask the user for a numeric grade. 2. Use the table below to calculate the corresponding letter: 90-100 - A 80-89 - B 70-79 - C 60-69 - D 0-59 - F 3. Print out both the number and letter grade. 4. If the value is not numeric, all...
true
64153c77965ffd4fc5ecab9c382e17c496b9ed6b
foureyes/csci-ua.0479-spring2021-001
/assignments/hw06/translate_passage.py
2,885
4.25
4
""" translate_passage.py ===== Use your to_pig_latin function to translate an entire passage of text. Do this by importing your pig_latin module, and calling your to_pig_latin function. You can use any source text that you want! For example: Mary Shelley's Frankenstein from Project Gutenberg: http://www.gutenberg....
true
1fb70af92655eb5feeefcdb9b69a6eac5bab9db7
julienawilson/data-structures
/src/shortest_path.py
1,492
4.15625
4
"""Shortest path between two nodes in a graph.""" import math def dijkstra_path(graph, start, end): """Shortest path using Dijkstra's algorithm.""" path_table = {} node_dict = {} # try: # infinity = math.inf # except: infinity = float("inf") for node in graph.nodes(): path...
true
4713b6f84dd3413a20d71fe230fdcf2b499a2621
fermolanoc/sw-capstone
/lab2/student_dataclass.py
676
4.3125
4
from dataclasses import dataclass @dataclass # dataclass decorator to simplify class definition class Student: # define attributes with data types -> this usually goes on __init__ method along with self name: str college_id: int gpa: float # override how info will be printed def __str__(self...
true
9697410fe37ce6a23ed05209a1f203ffd532cbc1
codingram/courses
/python-for-everybody/08_file_count.py
712
4.28125
4
# Exercise 5: # # Open the file mbox-short.txt and read it line by line. When you find a line # that starts with 'From ' like the following line: # # From stephen.marquard@uct.ac.za Sat Jan 5 09:14:16 2008 # # You will parse the From line using split() and print out the second word in # the line (i.e. the entire add...
true
ead7827cba391e26589a66717709406c0a27001b
codingram/courses
/python-for-everybody/08_list_max_min.py
586
4.46875
4
# Exercise 6: # # Rewrite the program that prompts the user for a list of numbers and prints out # the maximum and minimum of the numbers at the end when the user enters “done”. # Write the program to store the numbers the user enters in a list and use the # max() and min() functions to compute the maximum and minimum ...
true
d847f9cc90b307d3f6aeb41d3841b26fe94fdf66
codingram/courses
/MITx6001x/edx/ps1/ps1_3.py
815
4.34375
4
""" Assume s is a string of lower case characters. Write a program that prints the longest substring of s in which the letters occur in alphabetical order. For example, if s = 'azcbobobegghakl', then your program should print: Longest substring in alphabetical order is: beggh In the case of ties, print the first...
true
db451f5ab9deb908f5bb811ec0ceb2b881c86305
stepik/SimplePyScripts
/is_even__is_odd.py
402
4.15625
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- __author__ = 'ipetrash' def is_even(num): return num % 2 == 0 def is_odd(num): return not is_even(num) def is_even_2(num): return num & 1 == 0 if __name__ == '__main__': for i in range(10): print('{} is even: {}, {}'.format(i, is_even(i), i...
false
8f8c494b841104a69bea119b5a278f74479070a3
bestyoucanbe/joypython0826-b
/dictionaryOfWords.py
1,599
4.8125
5
# You are going to build a Python Dictionary to represent an actual dictionary. Each key/value pair within the Dictionary will contain a single word as the key, and a definition as the value. Below is some starter code. You need to add a few more words and definitions to the dictionary. # After you have added them, us...
true
b9ed663fdd97171b8ddeb8bb848b83645a93bf8e
frubilarz/datainfo
/python/main.py
795
4.1875
4
#!/usr/bin/env python # -*- coding: utf-8 -*- import random def quicksort(lista): if len(lista) > 1: pivote = lista[0] # Escogemos el pivote, por defecto será el primer elemento de la lista menores = [x for x in lista[1:] if x < pivote] # Una sublista con los elementos menores o iguales al pivote ...
false
752c3be3dfe48be63fee20b97a213c3b6c3a2afc
mrodolfo1981/python
/ordenandolistas.py
449
4.125
4
lista = [124,345,5,72,46,6,7,3,1,7,0] print("lista desordenada") print (lista) lista.sort()#esse metodo faz a ordenacao da lista print("Lista Ordenada") print(lista) lista1 = [40,39,33,20,11,5,8,2,1] print("lista1 desordenada") print(lista1) print("lista1 ordenada pelo metodo sorted") lista1 = sorted(lista1)#esse meto...
false
0b7e61fb66ee63523dd111eec1e8b4184d373191
Ayush05m/coding-pattern
/Python Codes/longestSubString.py
682
4.125
4
def longest_unique_subString(str1): windowstart = 0 max_length = 0 index_map = {} for windowend in range(len(str1)): right = str1[windowend] if right in index_map: windowstart = max(windowstart, index_map[right] + 1) index_map[right] = windowend max_length = m...
true
68f7c4431ce6d5e6ba0cff983ed6f23603434d22
zahraishah/zahraishah.github.io
/ErdosRenyi_graphs.py
1,217
4.3125
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Sat Jun 13 11:43:46 2020 @author: malaikakironde """ #This document goes over implementing a random graph using #the Erdos-Renyi Model import sys import matplotlib.pyplot as plt import networkx as nx import random def erdos_renyi(G,p): #finding a...
true
c085dc3d74bbb82b00b1de60f434a9a0dd53be3e
milenacudak96/python_fundamentals
/labs/04_conditionals_loops/04_07_search.py
365
4.15625
4
''' Receive a number between 0 and 1,000,000,000 from the user. Use while loop to find the number - when the number is found exit the loop and print the number to the console. ''' number = int(input('enter the number between 0 and 1000000000: ')) while number in range(1, 1000000000): print(number) break els...
true
ec8885cb263e5d23fc69f837f83882bab1d48d23
milenacudak96/python_fundamentals
/labs/04_conditionals_loops/04_01_divisible.py
333
4.40625
4
''' Write a program that takes a number between 1 and 1,000,000,000 from the user and determines whether it is divisible by 3 using an if statement. Print the result. ''' number = int(input('enter the number between 1 and 1000000000: ')) if number % 3 == 0: print('its divisible by 3') else: print('its not div...
true
d12615c7de5b1a340a8469fb265b15aa3c5fc7b3
milenacudak96/python_fundamentals
/labs/07_classes_objects_methods/07_02_shapes.py
797
4.5
4
''' Create two classes that model a rectangle and a circle. The rectangle class should be constructed by length and width while the circle class should be constructed by radius. Write methods in the appropriate class so that you can calculate the area (of the rectangle and circle), perimeter (of the rectangle) and cir...
true
35968dce2d4f437986f46c8762d798a869a32eec
ashutoshnarayan/Coursera
/guess_the_number.py
2,461
4.34375
4
# "Guess the number" mini-project # input will come from buttons and an input field # all output for the game will be printed in the console import simplegui import math import random # initialize global variables used in your code count_of_guesses = 7 game_range = 100 secret_number = random.randrange(0, 1...
true
654adb4d0cfffff4f410b5408e631eeeb9d4856e
mannhuynh/Python-Codes
/OOP/APP_1/water.py
1,271
4.5625
5
class Water: """ How do you access a class variable (e.g., boiling_temperature ) from within a method (e.g., from state)? The answer is: You can access class variables by using self. So, in our example, you would write self.boiling_temperature. See the state method below for an illustration. The key...
true
f78b8aa5f0118d4dc47e1e667a1c97dfe2c12f3b
lionel-antony/pycode
/py01/string_use_02.py
718
4.34375
4
#first_name = 'Lionel' #last_name = 'Antony' #print(first_name + last_name) #print('Hello ' + first_name + ' ' + last_name) first_name = input('What is your first name? ') last_name = input('What is your last name? ') #print('Hello ' + first_name + ' ' + last_name) #print('Hello ' + first_name.capitalize() + ' ' + la...
false
051dc584bef186573140404b6de74f8ba9fc1fdf
Mariobouzakhm/Hangman
/hangman.py
2,574
4.1875
4
import filemanager, random def createWordList(word): lst = list() for i in range(len(word)): lst.append('-') return lst def modifyWordList(lst, word, letter): for i in range(len(word)): if word[i] == letter: lst[i] = letter return lst #Open a File Handle with the file ...
true
7ccc450c398e40e9e8c97b927d20dbf0d4f83b7b
sergiosanchezbarradas/Udemy_Masterclass_Python
/sequences/automate boring.py
551
4.1875
4
# This program says hello and asks for my name. print('Hello, world!') print('Whats your name') your_name = input() print('nice to meet you ' + your_name) length_name = (len(your_name)) print('your name is {} characters long'.format(length_name)) print("What's your age") age = input() print("You will be " + str(int(a...
true
c17dcbc7c35639c2aef6d0a4d7fc8371b05b7620
ParkHanBin0820/Python
/reversed.py
280
4.1875
4
list_a = [1, 2, 3, 4 ,5] list_reversed = reversed(list_a) print("# reversed() 함수") print("reversed([1, 2, 3, 4, 5]):", list_reversed) print("list_reversed([1, 2, 3, 4, 5])):", list(list_reversed)) print() print("# reversed() 함수와 반복문") print("for i in reversed")
false
2ed3de8d74a1df5c2a32776675614f670af9b7bc
eraldomuha/software_development_projects
/rock_paper_scissors.py
2,995
4.21875
4
#!/usr/bin/env python3 from random import choice """This program plays a game of Rock, Paper, Scissors between two Players, and reports both Player's scores each round.""" moves = ['rock', 'paper', 'scissors'] """The Player class is the parent class for all of the Players in this game""" class Player...
true
2a53202790f416952f3e0eeaf46eeffda1b2440f
lachilles/oo-melons
/melons2.py
2,009
4.25
4
"""This file should have our order classes in it.""" class AbstractMelonOrder(object): """Default melon order """ def __init__(self, species, qty): self.species = species self.qty = qty self.shipped = False self.flat_rate = 0 def get_total(self): """Calc...
true
56fe479ffd914e40a60ecdd381d7dbfe37163c32
Tonyynot14/Textbook
/chapter5.10.py
339
4.15625
4
students = int(input("How many students do you have?")) highest = 0 secondhighest = 0 for i in range(students): score = int(input("What are the scores for the test?")) if score > highest: secondhighest=highest highest = score print("The highest test score was", highest, "\nThe second highest wa...
true
7eb418fe5e33623b74ee446a4d515e32afa5c82c
Tonyynot14/Textbook
/nsidepolygonclass.py
1,229
4.1875
4
#Tony Wade # Class for regular polygons # Class that defines a polygon based on n(number of sides), side(length of side) # x(x coordinate) y(y coordinate) import math class RegularPolygon: # initalizer and default constructor of regular polygon def __init__(self, n=3, side = 1, x = 0, y = 0 ): self.__...
true
c5634614d01183874ccc6c7e0a0f651e9cd345ca
coldmanck/leetcode-python
/0426_Convert_Binary_Search_Tree_to_Sorted_Doubly_Linked_List.py
1,445
4.28125
4
# Runtime: 36 ms, faster than 55.87% of Python3 online submissions for Convert Binary Search Tree to Sorted Doubly Linked List. # Memory Usage: 14.8 MB, less than 100.00% of Python3 online submissions for Convert Binary Search Tree to Sorted Doubly Linked List. # Definition for a Node. class Node: def __init__(sel...
true
e0453bfe71a01326909b1105ad8333463af4d7a4
coldmanck/leetcode-python
/0077_Combinations.py
1,190
4.15625
4
class Solution: '''Backtrack. Time: O(k*C^n_k) Space (C^n_k)''' def combine(self, n: int, k: int) -> List[List[int]]: def backtrack(i, cur_arr, ans, arr): if len(cur_arr) == k: ans.append(cur_arr) return for j in range(i, n): backtr...
true
4bdb539d304920611d832ccf249baa155666b01b
JelenaKiblik/School-python
/kt1/exam.py
1,672
4.125
4
"""Kontrolltoo.""" def capitalize_string(s: str) -> str: """ Return capitalized string. The first char is capitalized, the rest remain as they are. capitalize_string("abc") => "Abc" capitalize_string("ABc") => "ABc" capitalize_string("") => "" """ if len(s) >= 1: return s[0].upper...
true
6c0e0a844f7b4a863884ece04c4560c09167bb17
lkrauss15/Old-School-Stuff
/CarCalc.py
660
4.1875
4
# Programmer: Luke Krauss # Date: 9/15/14 # File: Wordproblems.py # This program allows a user to input specific numbers for a word problem. In this case, the user is saing up to purchase a car. def main(): print ("So you're saving up to buy a car?") carCost = input("How much is the car? ") currentCash =...
true
5a95e84b87d787067f4acd7eb422549a772e1bf0
goodseeyou/python_small_function
/src/listTool/listTool.py
2,235
4.125
4
''' Select kth value number from list in order of (n) time complexity. However, comparing to sorted list and select kth value (order of nlogn), sorting by build-in function is faster. ''' import sys NUMBER_OF_ELEMENT_IN_COLUMN = 7 def select_the_kth_small_element(_list, k): len_list = len(_list) if k > len_l...
false
3d9b540022732b42d3cb58317f9ac9c0fd2193cb
lcarbonaro/python
/session20161129/guess.v1.py
336
4.15625
4
from random import randint rand = randint(1,20) print('I have picked a random integer between 1 and 20.') guess = input('Enter your guess: ') if guess<rand: print('That is too low.') if guess>rand: print('That is too high.') if guess==rand: print('That is correct.') print('The random integer was:...
true
71f1ded188070d203f547339a60416e50744e880
allen-studio/learn-python3-records
/ex34.py
951
4.4375
4
animals = ['bear', 'python3.6', 'peacock', 'kangaroo', 'whale', 'platypus'] print(animals[0]) #列表第一个元素位置是[0] print(animals[-1]) #列表第一个元素位置是[-1] print(animals[-2]) # 倒数第二个元素就是[-2] print(animals[5]) # 当然也可以从[0]开始数到第六个[5] print(animals[0:]) # 获取列表中从 [0] 到结尾的元素 print(animals[:-1]) # 获取列表中从开头 到 [-1]的元素 print(animals[:]) # ...
false
5f241775792987d41cda409b63a38a36cf5981b7
KevinMFinch/Python-Samples
/productCommercial.py
591
4.125
4
print("Hello! I am going to ask you questions about your device to create a commercial.") yourObject = input("What is your object? ") yourData = input("What data does it take? ") how = input("How will you record the "+yourData+" from your "+yourObject+"?") where = input("Where will the "+how+" be located? ") cost = inp...
true
1782393b95763d826526de9d77d77df2ae89d038
brunoleonpuca/PYTHON
/learning-python/CONTROL DE FLUJOS.py
561
4.15625
4
"""CONTROL DE FLUJO""" """IF""" #IF condicion: # true #IF condicion1 and condicion2: # ambas devuelven true (si hay una falsa, no se va a mostrar) #IF condicion1 or condicion2: # una de ambas devuelve true """"IF - OPERADOR TERNARIO""" #print("cuando devuelve true") if 5 > 2 else print:("cuando devuelve false") ...
false
a69bfc55246f403b8b5711818e6591e150739c09
jaysonmassey/CMIS102
/Assignment_2_CMIS_102_Jayson_Massey.py
2,585
4.53125
5
# Assignment 2 CMIS 102 Jayson Massey # The second assignment involves writing a Python program to compute the price of a theater ticket. # Your program should prompt the user for the patron's age and whether the movie is 3D. # Children and seniors should receive a discounted price. x # There should be a surcharg...
true
9fa7ba142e1959040911fd07092dabf96e018ecf
gasgit-cs/pforcs-problem-sheet
/es.py
2,040
4.3125
4
# program to read in a file and count ocurrence of a char # author glen gardiner # run program calling es.py and passing the name of a file to read # example: python es.py Lorem-ipsum.txt # for this task its es.py md.txt import sys # fn - filename # i - input from user # uc - uppercase i # lc - lowercase i fn = sys...
true
c180f15dab31da69c0dc146ff04827f7d36289dc
leandroradusky/embnet-argentina
/embnet/Upload/module1.py
872
4.25
4
# REPASO # Defino la funcion x que devuelve el entero 3 x = 3 # Defino una funcion "inline" pordos = lambda y: y*2 # Defino una funcion comun def portres(y): return y*3 # Aplicar tenia la caracteristica de recibir # funciones como parametros, aca todo es una funcion!! aplicar = lambda y,z: y(z) apli...
false
3a676e0797232de364f8e1db7b5bdf858c8035a5
MandragoraQA/Python
/DZ_13.py
1,847
4.15625
4
#Пользователь вводит с клавиатуры строку, слово для поиска, слово для замены. Произведите в строке замену одного слова на другое. stroka = input("Введите строку: ") slovo = input("Введите слово для поиска: ") zamena = input("Введите слово для замены: ") #ищем слово и заменяем его сразу в цикле for a in range (len(...
false
df03082be153b1535a15ba6a35f9fbfd8c6480e5
robertggovias/robertgovia.github.io
/python/cs241/w04/assignment04/customer.py
2,220
4.1875
4
from order import Order from product import Product class Customer: '''id=0 price quantity''' def __init__(self): ''' Construction of an empty object to receive the id from the customer, and his name. Then will receive the list of orders ''' self.id = "" self.nam...
true
b403438ea29fd5b24d4379fec9d6fc503c686ebc
robertggovias/robertgovia.github.io
/python/cs241/w07/fibonnacy.py
459
4.125
4
def fib(n): fib_list = [0,1,1] if n < 0: return if n >= 0 and n < 3: return fib_list[n] for i in range (3, n+1): g = fib_list[i - 1] + fib_list[i - 2] fib_list.append(g) return fib_list[n] def main(): f = int(...
false
b0972ddcba708ccaf388c5f53d596f2bccebfb99
NishantGhanate/PythonScripts
/Scripts/alien.py
927
4.21875
4
# -*- coding: utf-8 -*- """ Created on Fri Jan 11 13:39:32 2019 @author: Nishant Ghanate """ # your code goes here import pandas as pd #Take User input for alphabetical order and string #a= input('Enter the order of alphabet : \n') #b= input('Enter the string you want to sort according to the Alphabet provided : \n'...
true
d8de5b3a6c0ba9c21d6f8287fe338f588175efa5
NishantGhanate/PythonScripts
/ObjectOriented/Sorting/MergeSort.py
2,569
4.28125
4
class MergeSort: def __init__(self,array): self.merge_sort(array) def merge_sort(self,array): print("\nGiven List = {} ".format(array)) if len(array)>1: mid = len(array)//2 print("Mid index = {} ".format(mid)) # From 0 till mid index left...
false
bd446e6a1cd0e8bcb5fe6745d2ebe9b78c40639e
pavanpandya/Python
/Python Basic/27_Sets.py
589
4.5
4
# Set-Unordered Collection of unique objects my_set = {1, 2, 3, 4, 5, 6} print(my_set) # Now let say we have an another set name my_set2 my_set2 = {1, 2, 3, 4, 5, 5} print(my_set2) # Here this will only print the unique objects. my_set.add(100) my_set.add(2) # Here 2 is not added in the set because it is already pre...
true
0a64d5d93b55aca7e3b854c9cd246ba3269010f7
pavanpandya/Python
/OOP by Telusko/13_Operator_Overloading.py
2,145
4.15625
4
# eg: 5 + 6 # Here 5 and 6 are operands and + is operator. a = 5 b = 6 print(a+b) # When you say a + b behind the scene int.__add__(a, b) is called. print(int.__add__(a, b)) c = '5' d = '6' print(c+d) # When you say c + d behind the scene str.__add__(c, d) is called. print(str.__add__(c, d)) # The moment you say...
false
adff70a67790e99f15a4effcddf6d69269395bf9
pavanpandya/Python
/Python Basic/38_Range().py
965
4.46875
4
# Range - It returns an object that produces a sequence of integers from start(inclusive) to stop(exclusive) by step. # Syntax: # range(stop) # range(start, stop[, step]) print(range(100)) # will give output: # range(0, 100) print(range(0, 100)) # will give output: # range(0, 100) for number in range(0, 100): pr...
true
4bf1675599ba2c0097469ead8eccccc889334057
pavanpandya/Python
/Other Python Section/06_Error_Handling.py
718
4.21875
4
# Error Handling: while True: try: age = int(input('What is your age: ')) print(age) except: print('Please enter a number') # The above code means try the code and if there is any error run except. else: print('Thank You') break # If there is any error then inst...
true
59ca9c162a99aabaa5affebfe41f32241e655379
pavanpandya/Python
/Python Basic/11_Formatted_Strings.py
768
4.34375
4
# Formatted Strings name = 'Pavan' age = 19 # print('Hi' + name + '. You are ' + age + ' year old.') --> This will throw an error as age is int # and string Concatenation only works with strings print('Hi ' + name + '. You are ' + str(age) + ' year old.') # Better Way of doing This print(f'Hi {name}. You are {age} ye...
true
be072451108e2ad01b0c6f2638d13f3352104d16
pavanpandya/Python
/OOP by Telusko/10_Constructor_in_Inheritance.py
1,292
4.59375
5
# SUB CLASS CAN ACCESS ALL THE FEATURES OF SUPER CLASS # BUT # SUPER CLASS CANNOT ACCESS ANY FEATURES OF SUB CLASS ''' IMPORTANT RULE: When you create object of sub class it will call init of sub class first. If you have call super then it will first call init of super class and then call the init of sub class. '''...
true
266c658edeabb5217f3cd1b8cf61a2ad2de4fea2
pavanpandya/Python
/Python Basic/07_Augmented_Assignment_Operator.py
471
4.71875
5
# Augmented Assignment Operator Some_value = 5 # Some_value = Some_value + 5 # instead of doing this we will use Augmented Assignment Operator, Some_value += 5 # --> which is equal to Some_value = Some_value + 5 # NOTE : In order to work this "Some_value += 5", the variable "Some_value" should be defined before or ...
true
3f1dce9f42dbd335fa08610df5732a308fb7f744
pavanpandya/Python
/Python Basic/56_Exercise_Functions.py
332
4.125
4
def Highest_Even_Number(li): evens = [] for item in li: if(item % 2 == 0): evens.append(item) max = 0 for i in evens: if(i > max): max = i return max # By using Max Function. # return max(evens) my_List = [10, 2, 3, 4, 8, 11] print(Highest_Even_Numbe...
true
14039762193d12d2ab24057aa383a327bc254eb5
pavanpandya/Python
/Other Python Section/08_Exercise_error_handling.py
551
4.15625
4
while True: try: age = int(input('What is your age: ')) print(age) except ValueError: print('Please Enter a number') except ZeroDivisionError: print("You can't Enter Zero") else: print('Thank You') break finally: print("Okay, I'am Finally Done"...
true
61021fe5756f17e209dd666326304557af17b1d2
pavanpandya/Python
/Python Basic/33_Logical_Operators.py
470
4.1875
4
# Logical Operators: # >, <, >=, <=, ==, != # and, or, not print(4 > 5) print(4 >= 5) print(4 < 5) print(4 <= 5) print(4 == 5) print(4 != 5) print('a' > 'b') print('a' > 'A') print(1 < 2 < 3 < 4) print(not(True)) # Exercise is_magician = False is_expert = True if is_magician and is_expert: print("You are a m...
false
ff82750488e0dd6ee02cdda39ebad5fc36df5fe4
cameron-teed/ICS3U-5-04-PY
/cyliinder.py
922
4.3125
4
#!/usr/bin/env python3 # Created by: Cameron Teed # Created on: Nov 2019 # This program calculates volume of a cylinder import math def volume_calculator(radius, height): # calculates the volume # process volume = math.pi * radius * radius * height return round(volume, 2) def main(): # This i...
true
0fd7593dc7b0faafc04fa0664278eb7ed1859e80
Zgonz19/Towers-of-Hanoi
/TowersofHanoi.py
2,875
4.125
4
# COSC 3320, Towers of Hanoi, Assignment 1 # Gonzalo Zepeda, ID: 1561524 # when called, printMove function prints the current move as long as the parameters # entered correspond to the solution. # notable parameters: which disk is moving, disk location, disk destination, number of moves so far def printMove(disk, sour...
true
985035622d0ea945f08a311f4b075820771d1652
mswift42/project-euler
/euler38.py
954
4.28125
4
#!/usr/bin/env # -*- coding: utf-8 -*- """Pandigital mutiples Problem 38 28 February 2003 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 an...
true
951621c35b6c9109a5444a51e173d9d36a1a1920
jwong6100/CompSciHW
/HW3.py
2,641
4.125
4
#Author - Jonathan Wong, jfw5328@psu.edu #populating dictionaries and lists property_groups_size = {'purple':2, 'light blue':3, 'maroon':3, 'orange':3, 'red':3, 'yellow':3, 'green':3, 'dark blue':2} property_groups_size_words = {'purple':'two', 'light blue':'three', 'maroon':'three', 'orange':'...
false
72833495fc0d5ab5180bbbd3cc98462bbb005ee5
ysjin0715/python-practice
/chapter6/study.py
1,268
4.15625
4
#2. print('방문을 환영합니다!') print('방문을 환영합니다!') print('방문을 환영합니다!') print('방문을 환영합니다!') print('방문을 환영합니다!') # for i in range(1000): # print('방문을 환영합니다!') #4. for i in [1, 2, 3, 4, 5]: print('방문을 환영합니다') #5. for i in [1, 2, 3, 4, 5]: print("i=",i) for a in [1, 2, 3, 4, 5]: print("9*",a,"=",9*a) #6. for ...
false
46811fc30524954812699c4ecc59ea0ce77735fb
Igor-Zhelezniak-1/ICS3U-Unit4-02-Python-Math_Program
/math_program.py
766
4.21875
4
#!/usr/bin/env python3 # Created by: Igor # Created on: Sept 2021 # This is math_program def main(): loop_counter = 1 answer = 1 # input integer = input("Enter any positive number: ") print("") # process & output try: number = int(integer) if number < 0: prin...
true
aedda9665a6e79cc9c6fb033d1b04aa9c4ba3565
ecornelldev/ctech400s
/ctech402/module_6/M6_Codio_PROJECT/exercise_files/startercode3.py
498
4.34375
4
#### # Player and Computer each have 3 dice # They each roll all 3 dice until one player rolls 3 matching dice. ####### # import random package import random # player and computers total score player_score = 0 computer_score = 0 # define a function that is checks for three matching dice # function returns True or ...
true
c829c9dab8968ee28dbcf12c7ed8a6f03167a632
ecornelldev/ctech400s
/ctech402/module_2/M2_Codio_PROJECT-Remove-Append/exercise_files/SolutionCode.py
515
4.125
4
Part 1: integer_list = [10,2,5,7,4,3,6,9,8,1] list_even = [] list_odd = [] for i in integer_list: if i%2 == 0: list_even.append(i) else: list_odd.append(i) print("Even numbers: " + str(sorted(list_even))) print("Odd numbers: " + str(sorted(list_odd))) Part 2: integer_list = [10, 2, 5, 7, 4, 3, 6, 9, 8, 1] ...
false
688528928849a3a923618670d60ad349799e16a2
satvikag2001/codechef
/func_game_south.py
1,541
4.1875
4
from sys import exit import func_extra prompt = ">>>>" def south(): print("You have entered the castle of DOOM ,from its rear end") print("It is dark and faint sounds of screaming can be heard.") print("you are absoulutely defenceless so like every sane peron you walk down the dusty corridor taking in") pr...
true
943d825de16d00b7e445aaa34666b1cad7ec2844
ishantk/GW2021PY1
/Session18C.py
2,084
4.125
4
# Why Inheritance # Code Redundancy -> Development Time class FlightBooking: def __init__(self, from_location, to_location, departure_date, travellers, travel_class): self.from_location = from_location self.to_location = to_location self.departure_date = departure_date self.travell...
true
fcc1f874bfc96c7da415baabe2cd152a7e831e2f
georgemaia/Logica_com_Python
/mundo01/ex008.py
387
4.15625
4
metro = float(input('Uma distância em metros: ')) km = metro * .001 hm = metro * .01 dam = metro * .1 dm = metro * 10 cm = metro * 100 mm = metro * 1000 print('A medida de {}m corresponde a'.format(metro)) print('{}km'.format(km)) print('{}gm'.format(hm)) print('{:.1f}dam'.format(dam)) print('{:.0f}dm'.forma...
false
7ad70114f889d526874f3bda353179532676a51c
rantsandruse/pytorch_lstm_01intro
/main_example.py
2,312
4.25
4
''' This is the "quick example", based on: https://pytorch.org/tutorials/beginner/nlp/sequence_models_tutorial.html ''' import numpy as np import torch import torch.nn as nn # This is the beginning of the original tutorial torch.manual_seed(1) # The first implementation # Initialize inputs as a list of tensors # pass...
true
3c04e2019071ccdf771f3fd7c2bfb0189235ac59
hirenpatel1207/IPEM_Smart_Coffee
/WorkingDirectory/Raspberry_Pi_Code/calculateParticularFeature.py
1,037
4.15625
4
""" Brief: this file calculates particular features passed in the argument. Calculate various features to generate the feature vector which can be used for prediction """ import numpy as np # Note: pass the feature name correctly to avoid error def calculateParticularFeatureFunc(x, featureName): # calcu...
true
150583f46366913093372af43576e892f3d7b3e5
aysegulkrms/SummerPythonCourse
/Week3/10_Loops_4.py
345
4.1875
4
max_temp = 102.5 temperature = float(input("Enter the substance's temperature ")) while temperature > max_temp: print("Turn down the thermostat. Wait 5 minutes. Check the temperature again") temperature = float(input("Enter the new Celsius temperature ")) print("The temperature is acceptable") print("Check ...
true
5276c5526eb0c903de5a7849529da3df5d8ab49f
aysegulkrms/SummerPythonCourse
/Week2/04_Tuples_2.py
252
4.1875
4
# Accessing elements using indexing my_tuple = ('p', 'y', 't', 'h', 'o', 'n') print(my_tuple[0]) print(my_tuple[-1]) # print(my_tuple[6]) # Nested Tuple n_tuple = ("Lion", [8, 4, 6], (1, 2, 3)) # Nested Indexing # Access to n print(n_tuple[0][3])
false
2c72fae5d1d15217e09b590aafb02199897e1499
aysegulkrms/SummerPythonCourse
/Week3/01_ForLoops.py
669
4.1875
4
# Range in python list_1 = list(range(0, 11)) print(list_1) list_2 = list(range(0, 11, 2)) print(list_2) # print("Hello") # print("Hello") # print("Hello") # print("Hello") # print("Hello") for i in range(5): print("Hello {}".format(i)) for i in range(11): print(i, end=" ") print() # modulo print(17 % 5) ...
false
ee1cc4de9e1fefc268d34dfc27d1ef6cd73573ea
nbrahman/LeetCode
/ReverseInteger.py
929
4.15625
4
''' Reverse digits of an integer. Example1: x = 123, return 321 Example2: x = -123, return -321 click to show spoilers. Note: The input is assumed to be a 32-bit signed integer. Your function should return 0 when the reversed integer overflows. ''' class Solution(object): def reverse(self, x): """ ...
true
3c7f4279f3901b455a9a8320029206845a06afc4
atriekak/LeetCode
/solutions/341. Flatten Nested List Iterator.py
2,459
4.1875
4
# """ # This is the interface that allows for creating nested lists. # You should not implement it, or speculate about its implementation # """ #class NestedInteger: # def isInteger(self) -> bool: # """ # @return True if this NestedInteger holds a single integer, rather than a nested list. # """...
true
7aa209132bb45a48ca45b8ec96e41af449436123
carlosmachadojr/Curso-em-Video-Python-3
/exercicio-018.py
1,245
4.5625
5
##### SENO, COSSENO E TANGENTE ##### """ CURSO EM VÍDEO - EXERCÍCIO PYTHON 18: Faça um programa que leia um ângulo qualquer e mostre na tela o valor do seno, cosseno e tangente desse ângulo. Link: https://youtu.be/9GvsphwW26k """ #######################################################################...
false
42f67ba9544b87f14631c7abce4a173e04e93f3a
carlosmachadojr/Curso-em-Video-Python-3
/exercicio-019.py
1,316
4.1875
4
##### SORTEANDO UM ITEM DE UMA LISTA ##### """ CURSO EM VÍDEO - EXERCÍCIO PYTHON 19: Um professor quer sortear um dos seus quatro alunos para apagar o quadro. Faça um programa que ajude ele, lendo o nome dos alunos e escrevendo na tela o nome do escolhido. Link: https://youtu.be/_Nk02-mfB5I """ ###...
false
30772d9bd9eddf2849b3c32e91c4c72179ad9e26
carlosmachadojr/Curso-em-Video-Python-3
/exercicio-003.py
949
4.25
4
##### SOMA DE DOIS NÚMEROS ##### """ CURSO EM VÍDEO - EXERCÍCIO PYTHON 003: Crie um programa que leia dois números e mostre a soma entre eles. Link: https://youtu.be/PB254Cfjlyk """ ############################################################################### ### INÍCIO DO PROGRAMA ################...
false
19e689c348748bbd674f6e95857764d9b9791300
carlosmachadojr/Curso-em-Video-Python-3
/exercicio-015.py
1,418
4.125
4
##### ALUGUEL DE CARROS ##### """ CURSO EM VÍDEO - EXERCÍCIO PYTHON 15: Escreva um programa que pergunte a quantidade de km percorridos por um carro alugado e a quantidade de dias pelos quais ele foi alugado. Calcule o preço a pagar, sabendo que o carro custa R$60 por dia e R$0,15 por Km rodado. Link: ht...
false
6d8a378ed2c0b602736e903c28115b8eed176d1e
carlosmachadojr/Curso-em-Video-Python-3
/exercicio-036.py
1,488
4.46875
4
##### APROVANDO EMPRÉSTIMO ##### """ CURSO EM VÍDEO - EXERCÍCIO PYTHON 036: Escreva um programa para aprovar o empréstimo bancário para a compra de uma casa. Pergunte o valor da casa, o salário do comprador e em quantos anos ele vai pagar. A prestação mensal não pode exceder 30% do salário ou então o emprés...
false