blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
1571c5675a0e614056cfcee317d8addcfb5c474d
Anjali-225/PythonCrashCourse
/Chapter_4/Pg_122_Try_It_Yourself_4-15.py
1,018
4.15625
4
#4-14 Read through it all ################################ #4-15 players = ['charles', 'martina', 'michael', 'florence', 'eli'] print(f"The first three items in the list are: {players[0:3]}") print("") print(f"Three items from the middle of the list are: {players[1:4]}") print("") print(f"The last th...
false
07af6c34d8365158a21250d6dc858399169fb80c
bharathkumarreddy19/python_loops_and_conditions
/odd_even.py
232
4.21875
4
# -*- coding: utf-8 -*- """ Created on Sat Apr 25 19:00:17 2020 @author: bhara_5sejtsc """ num = int(input("Enter a number: ")) if num%2 == 0: print("The given number is even") else: print("The given number is odd")
false
f8087e5bf4e1234b7dddf18f6cd7f3612b4563c4
ElminaIusifova/week1-ElminaIusifova
/04-Swap-Variables**/04.py
371
4.15625
4
# # Write a Python program to swap two variables. # # Python: swapping two variables # # Swapping two variables refers to mutually exchanging the values of the variables. Generally, this is done with the data in memory. # # # ### Sample Output: # ``` # Before swap a = 30 and b = 20 # After swaping a = 20 and b = 30 # `...
true
da4cf09617b4a09e36a1afa5ebcb28ae049331fe
ElminaIusifova/week1-ElminaIusifova
/01-QA-Automation-Testing-Program/01.py
968
4.28125
4
## Create a program that asks the user to test the pages and automatically tests the pages. # 1. Ask the user to enter the domain of the site. for example `example.com` # 2. After entering the domain, ask the user to enter a link to the 5 pages to be tested. # 3. Then display "5 pages tested on example.com". # 4. Add e...
true
563c9c6658a045bee7b35b510f706a1ae17039b8
Dilan/projecteuler-net
/problem-057.py
1,482
4.15625
4
#!/usr/bin/env python # -*- coding: utf-8 -*- # It is possible to show that the square root of two can be expressed as an infinite continued fraction. # √ 2 = 1 + 1/(2 + 1/(2 + 1/(2 + ... ))) = 1.414213... # By expanding this for the first four iterations, we get: # 1 + 1/2 = 3/2 = 1.5 # 1 + 1/(2 + 1/2) = 7/5 = 1.4...
true
3c8802f63b9ff336168a750a2d82e7e42c6ee7ec
Chou-Qingyun/Python006-006
/week06/p5_1classmethod.py
2,320
4.25
4
# 让实例的方法成为类的方法 class Kls1(object): bar = 1 def foo(self): print('in foo') # 使用类属性、方法 @classmethod def class_foo(cls): print(cls.bar) print(cls.__name__) cls().foo() # Kls1.class_foo() ######## class Story(object): snake = 'python' # 初始化函数,并非构造函数。构造函数: __n...
false
3f2e1e7f00004e07ed45b0499bfcacb873d6ef92
CodedQuen/python_begin1
/simple_database.py
809
4.34375
4
# A simple database people = { 'Alice': { 'phone': '2341', 'addr': 'Foo drive 23' }, 'Beth': { 'phone': '9102', 'addr': 'Bar street 42' }, 'Cecil': { 'phone': '3158', 'addr': 'Baz avenue 90' } } # Descriptive lables for the phone...
true
92ab0a09b8eab1d3a27beab9c4093d3acd30991b
JunaidRana/MLStuff
/Advanced Python/Virtual Functions/File.py
364
4.125
4
# -*- coding: utf-8 -*- """ Created on Tue Sep 25 19:51:27 2018 @author: Junaid.raza """ class Dog: def say(self): print ("hau") class Cat: def say(self): print ("meow") pet = Dog() pet.say() # prints "hau" another_pet = Cat() another_pet.say() # prints "meow" my_pets = [pet, anothe...
false
e84ea0ce2afb28b4bb2c13a0f8b44fbbb08788bc
aayanqazi/python-preparation
/A List in a Dictionary.py
633
4.25
4
from collections import OrderedDict #List Of Dictionary pizza = { 'crust':'thick', 'toppings': ['mashrooms', 'extra cheese'] } print("You ordered a " + pizza['crust'] + "-crust pizza " + "with the following toppings:") for toppings in pizza['toppings']: print ("\t"+toppings) #Examples 2 favourite...
true
05a1e4c378524ef50215bd2bd4065b9ab696b80d
Glitchier/Python-Programs-Beginner
/Day 2/tip_cal.py
397
4.15625
4
print("Welcome to tip calculator!") total=float(input("Enter the total bill amount : $")) per=int(input("How much percentage of bill you want to give ? (5%, 10%, 12%, 15%) : ")) people=int(input("How many people to split the bill : ")) bill_tip=total*(per/100) split_amount=float((bill_tip+total)/people) final...
true
14a7f65f931c18bf4e7fa39e421d1a688e47356c
rg3915/Python-Learning
/your_age2.py
757
4.3125
4
from datetime import datetime def age(birthday): ''' Retorna a idade em anos ''' today = datetime.today() if not birthday: return None age = today.year - birthday.year # Valida a data de nascimento if birthday.year > today.year: print('Data inválida!') return...
false
507fdcb28060f2b139b07853c170974939267b63
Abhinav-Rajput/CodeWars__KataSolutions
/Python Solutions/Write_ Number_in_Expanded_Form.py
611
4.34375
4
# Write Number in Expanded Form # You will be given a number and you will need to return it as a string in Expanded Form. For example: # expanded_form(12) # Should return '10 + 2' # expanded_form(42) # Should return '40 + 2' # expanded_form(70304) # Should return '70000 + 300 + 4' def expanded_form(num): strNum...
true
b8ca7993c15513e13817fa65f892ebd014ca5743
Satona75/Python_Exercises
/Guessing_Game.py
816
4.40625
4
# Computer generates a random number and the user has to guess it. # With each wrong guess the computer lets the user know if they are too low or too high # Once the user guesses the number they win and they have the opportunity to play again # Random Number generation from random import randint carry_on = "y" while...
true
c069374b1d2c822c9a71b4c7c95ac5e7e3ca945f
Satona75/Python_Exercises
/RPS-AI.py
1,177
4.3125
4
#This game plays Rock, Paper, Scissors against the computer. print("Rock...") print("Paper...") print("Scissors...\n") #Player is invited to choose first player=input("Make your move: ").lower() #Number is randomly generated between 0 and 2 import random comp_int=random.randint(0, 2) if comp_int == 0: computer...
true
474ae873c18391c8b7872994da02592b59be369c
Satona75/Python_Exercises
/RPS-AI-refined.py
1,977
4.5
4
#This game plays Rock, Paper, Scissors against the computer computer_score = 0 player_score = 0 win_score = 2 print("Rock...") print("Paper...") print("Scissors...\n") while computer_score < win_score and player_score < win_score: print(f"Computer Score: {computer_score}, Your Score: {player_score}") #P...
true
19dbab140d55e0b7f892d66f08b9dc26ba5f4095
timurridjanovic/javascript_interpreter
/udacity_problems/8.subsets.py
937
4.125
4
# Bonus Practice: Subsets # This assignment is not graded and we encourage you to experiment. Learning is # fun! # Write a procedure that accepts a list as an argument. The procedure should # print out all of the subsets of that list. #iterative solution def listSubsets(list, subsets=[[]]): if len(list) == 0...
true
c593ca80cbc671e86d12f8d2ffaf0829fdb024ea
jacobfdunlop/TUDublin-Masters-Qualifier
/10.py
470
4.1875
4
usernum1 = int(input("Please enter a number: ")) usernum2 = int(input("Please enter another number: ")) usernum3 = int(input("Please enter another number: ")) if usernum1 > usernum2 and usernum1 > usernum3: print(usernum1, " is the largest number") elif usernum2 > usernum1 and usernum2 > usernum3: pri...
true
267335a2b28e9bc77b99f0b288f5bbb6f5b4d763
KelseySlavin/CIS104
/Assignments/Lab1/H1P1.py
524
4.15625
4
first_name = input("What is your first name?: ") last_name = input("What is your last name?: ") age = int(input("What is your age?: ")) confidence=int(input("How confident are you in programming between 1-100%? ")) dog_age= age * 7 print("hello, " + first_name+ " " + last_name + " , nice to meet you! You might be " + s...
true
87e0c4f5b7335390da9274aedad193cbdb99d5ce
Ghelpagunsan/classes
/lists.py
2,473
4.15625
4
class manipulate: def __init__(self, cars): self.cars = cars def add(self): self.cars.append("Ford") self.cars.sort() return self.cars def remove(self): print("Before removing" + str(self.cars)) self.cars.remove("Honda") return str("After removing" + str(self.cars)) def update(self, car): car.u...
true
265049dd5c7273612076608f805ee6f00e3f2430
DangerousCode/DAM-2-Definitivo
/Python/Funciones de Alto orden/Ejemplo4.py
1,256
4.3125
4
__author__ = 'AlumnoT' '''Funcion dada una lista de numeros y un numero cota superior, queremos devolver aquellos elementos menores a dicha cota''' lista=list(range(-5,5)) '''1)Modificar la sintaxis anterior para que solo nos muestre los numeros negativos''' print filter(lambda x:x<0,lista) '''2)Crear funcion a la que ...
false
3cac0579ed84aaeeb6cd68e8dba63fbfa5caefee
brentirwin/automate-the-boring-stuff
/ch7/regexStrip.py
1,091
4.6875
5
#! python3 # regexStrip.py ''' Write a function that takes a string and does the same thing as the strip() string method. If no other arguments are passed other than the string to strip, then whitespace characters will be removed from the beginning and end of the string. Otherwise, the characters specified in the seco...
true
c86a09cf6d893b85a67cf094b8fcf3e1b1e22e9b
realdavidalad/python_algorithm_test_cases
/longest_word.py
325
4.375
4
# this code returns longest word in a phrase or sentence def get_longest_word(sentence): longest_word="" for word in str(sentence).split(" "): longest_word=word if len(word) > len(longest_word) else longest_word return longest_word print get_longest_word("This is the begenning of algorithm") ...
true
fa0c8bc224b3c091276166cd426bd5153edb0b73
Lynkdev/Python-Projects
/shippingcharges.py
508
4.34375
4
#Jeff Masterson #Chapter 3 #13 shipweight = int(input('Enter the weight of the product ')) if shipweight <= 2: print('Your product is 2 pounds or less. Your cost is $1.50') elif shipweight >= 2.1 and shipweight <= 6: print('Your product is between 2 and 6 pounds. Your cost is $3.00') elif shipweig...
true
3647c4684453494b07d2000b1f7d2a9cfd7eaef0
ching-yi-hsu/practice_python
/6_String_Lists/string_lists.py
206
4.3125
4
str_word = str(input("enter a string : ")) str_word_rev = str_word[::-1] if str_word == str_word_rev : print(str_word , " is a palindrome word") else : print(str_word, " isn't a palindrome word")
false
bf07fa0385b64213f01583fe22a86deb00ea65d2
mandarwarghade/Python3_Practice
/ThinkPython_Ex3.py
1,035
4.1875
4
#Exercise 3 #Note: This exercise should be done using only the statements and other features we have learned so far. #Write a function that draws a grid like the following: #+ - - - - + - - - - + #| | | #| | | #| | | #| | | #+ - - - - + - - - - + #| ...
false
bec5623135d5387e7bb16e3f63d93522a2a6f69a
sbuffkin/python-toys
/stretched_search.py
1,172
4.15625
4
import sys import re #[^b]*[b][^o]*[o][^a]*[a][^t]*[t](.?) #([^char]*[char])*(.?) <- general regex #structure of regex, each character is [^(char)]*[(char)] #this captures everything that isn't the character until you hit the character then moves to the next state #you can create a "string" of these in regex to see i...
true
91a5122f9957141be0966121bf67ac11ae2a2f22
Pranitha-J-20/Fibonacci
/Fibonacci series.py
306
4.21875
4
num=int(input("enter the number of terms: ")) n1=0 n2=1 count=0 if num<=0: print("enter a positive integer") elif num==1: print('fibonacci seies: ',n1) else: print("fibonacci series: ") while count<num: print(n1) nth=n1+n2 n1=n2 n2=nth count=count+1
false
b4c8c18405a914afecee69a0d7f55f57bca6aed5
helen5haha/pylee
/game/CountandSay.py
1,012
4.15625
4
''' The count-and-say sequence is the sequence of integers beginning as follows: 1, 11, 21, 1211, 111221, ... 1 is read off as "one 1" or 11. 11 is read off as "two 1s" or 21. 21 is read off as "one 2, then one 1" or 1211. Given an integer n, generate the nth sequence. Note: The sequence of integers will be represented...
true
84806db8304b6bb9b25f9aced5bcb078492bae2a
helen5haha/pylee
/matrix/SpiralMatrix.py
827
4.21875
4
''' Given a matrix of m x n elements (m rows, n columns), return all elements of the matrix in spiral order. For example, Given the following matrix: [ [ 1, 2, 3 ], [ 4, 5, 6 ], [ 7, 8, 9 ] ] You should return [1,2,3,6,9,8,7,4,5]. ''' def spiralOrder(matrix): m = len(matrix) if 0 == m: return [] ...
false
5cffad649c630930892fb1bbe38c7c8b6c177b60
Keerthanavikraman/Luminarpythonworks
/oop/polymorphism/demo.py
1,028
4.28125
4
### polymorphism ...many forms ##method overloading...same method name and different number of arguments ##method overriding...same method name and same number of arguments ###method overloading example # class Operators: # def num(self,n1,n2): # self.n1=n1 # self.n2=n2 # print(self.n1+se...
true
820abce4f9d2ca4f8435512d9ad69873abb106b3
Vani-start/python-learning
/while.py
553
4.28125
4
#while executes until condition becomes true x=1 while x <= 10 : print(x) x=x+1 else: print("when condition failes") #While true: # do something #else: # Condifion failed #While / While Else loops - a while loop executes as long as an user-specified condition is evaluated as True; the "else" clause is opti...
true
495429537628e1b51b144775abb34d060034ac20
Vani-start/python-learning
/convertdatatype.py
980
4.125
4
#Convet one datatype into otehr int1=5 float1=5.5 int2=str(int1) print(type(int1)) print(type(int2)) str1="78" str2=int(str1) print(type(str1)) print(type(str2)) str3=float(str1) print(type(str3)) ###Covert tuple to list tup1=(1,2,3) list1=list(tup1) print(list1) print(tup1) set1=set(list1) print(set1) #...
true
876792dac3431422495d8b71eb97b5faf662f201
risabhmishra/parking_management_system
/Models/Vehicle.py
931
4.34375
4
class Vehicle: """ Vehicle Class acts as a parent base class for all types of vehicles, for instance in our case it is Car Class. It contains a constructor method to set the registration number of the vehicle to registration_number attribute of the class and a get method to return the value stored in re...
true
27e8ec33ff0f380bf54428032445ab8905d3164f
detjensrobert/cs325-group-projects
/ga1/assignment1.py
2,273
4.40625
4
""" This file contains the template for Assignment1. You should fill the function <majority_party_size>. The function, recieves two inputs: (1) n: the number of delegates in the room, and (2) same_party(int, int): a function that can be used to check if two members are in the same party. ...
true
58e59338d5d1fc79374d0ce438582c4d73185949
Neethu-Mohan/python-project
/projects/create_dictionary.py
1,091
4.15625
4
""" This program receives two lists of different lengths. The first contains keys, and the second contains values. And the program creates a dictionary from these keys and values. If the key did not have enough values, the dictionary will have the value None. If Values that did not have enough keys will be ignored. ...
true
a99612c8ed99a9d0596c7a9f342e8831c21d0b63
SayedBhuyan/learning-python
/if else.py
781
4.1875
4
#mark = int(input("Enter Mark: ")) # if else mark = 85 if mark >= 80: print("A+") elif mark >= 70: print("A") elif mark >= 60: print("A-") elif mark >= 50: print("B+") elif mark >= 40: print("B") elif mark >= 33: print("B-") else: print("Fail") ''' if (mark % 2) == 0: print("Even") el...
false
488675687a2660c01e9fd7d707bdf212f94abb62
NM20XX/Python-Data-Visualization
/Simple_line_graph_squares.py
576
4.34375
4
#Plotting a simple line graph #Python 3.7.0 #matplotlib is a tool, mathematical plotting library #pyplot is a module #pip install matplotlib import matplotlib.pyplot as plt input_values = [1,2,3,4,5] squares = [1,4,9,16,25] plt.plot(input_values, squares, linewidth = 5) #linewidth controls the thickness of the lin...
true
9ed2d0f9f15fde3e123ea8f30c2ffa714db1460a
tristaaa/learnpy
/getRemainingBalance.py
819
4.125
4
#! /usr/bin/env python3 # -*- coding:utf-8 -*- balance = 42 annualInterestRate = 0.2 monthlyPaymentRate = 0.04 def getMonthlyBalance(balance, annualInterestRate, monthlyPaymentRate): ''' return: the remaining balance at the end of the month ''' minimalPayment = balance * monthlyPaymentRate monthl...
true
6df041ded350202d4e74f98a104fd3470e21683d
tristaaa/learnpy
/bisectionSearch_3.py
910
4.46875
4
#! /usr/bin/env python3 # -*- coding:utf-8 -*- # use bisection search to guess the secret number # the user thinks of an integer [0,100). # The computer makes guesses, and you give it input # - is its guess too high or too low? # Using bisection search, the computer will guess the user's secret number low = 0 high ...
true
0dc00b065c4e8460cb7e85db60d3bfea2189803a
AnnapurnaThakur/python_code
/anubreak19.py
600
4.3125
4
# for x in range (1,5): # for i in range(1,5): # if i==3: # print("Sorry") # print("loop2") # break # print("loop1") # print("end") ####2nd example: for x in range (1,5): for i in range(1,5): if i==3: print("Sorry") break print("loop2...
false
537ddca25824fd995727cbb026fecefa5bdcaf8b
wkomari/Lab_Python_04
/data_structures.py
1,383
4.40625
4
#lab 04 # example 1a groceries = ['bananas','strawberries','apples','bread'] groceries.append('champagne') print groceries # example1b groceries = ['bananas','strawberries','apples','bread'] groceries.append('champagne') # add champagne to the list of groceries groceries.remove('bread') # remove bread from the lis...
true
5f168aeaf97ebb2100fafcbaef59928522f86d70
sha-naya/Programming_exercises
/reverse_string_or_sentence.py
484
4.15625
4
test_string_sentence = 'how the **** do you reverse a string, innit?' def string_reverser(string): reversed_string = string[::-1] return reversed_string def sentence_reverser(sentence): words_list = sentence.split() reversed_list = words_list[::-1] reversed_sentence = " ".join(reversed_list) ...
true
18fae6895c6be30f0a3a87531a2fafe965a3c89f
pkdoshinji/miscellaneous-algorithms
/baser.py
1,873
4.15625
4
#!/usr/bin/env python3 ''' A module for converting a (positive) decimal number to its (base N) equivalent, where extensions to bases eleven and greater are represented with the capital letters of the Roman alphabet in the obvious way, i.e., A=10, B=11, C=12, etc. (Compare the usual notation for the hexadecimal numbers....
true
fe03952ad6982e0e51a9218b01dc9231df641b41
cbrandao18/python-practice
/celsius-to-f.py
226
4.1875
4
def celsiusToFahrenheit(degree): fahrenheit = degree*1.8 + 32 print fahrenheit celsiusToFahrenheit(0) celsiusToFahrenheit(25) n = input("Enter Celsius you would like converted to Fahrenheit: ") celsiusToFahrenheit(n)
false
2cee626ca8bbdd1c78751e9df019279d323d1e06
Philngtn/pythonDataStructureAlgorithms
/Arrays/ArrayClass.py
1,291
4.15625
4
# # # # # # # # # # # # # # # # # # # # # # # # # Python 3 data structure practice # Chap 1: Implementing Class # Author : Phuc Nguyen (Philngtn) # # # # # # # # # # # # # # # # # # # # # # # # class MyArray: def __init__(self): self.length = 0 # Declare as dictionary self.data = {}...
false
358c68067412029677c59023d1f4b35af58c54ff
yuniktmr/String-Manipulation-Basic
/stringOperations_ytamraka.py
1,473
4.34375
4
#CSCI 450 Section 1 #Student Name: Yunik Tamrakar #Student ID: 10602304 #Homework #7 #Program that uses oython function to perform word count, frequency and string replacement operation #In keeping with the Honor Code of UM, I have neither given nor received assistance #from anyone other than the instructor. #--...
true
5649dabbf39457cb906368ebc3591f964108713c
ijoshi90/Python
/Python/hacker_rank_staricase.py
460
4.3125
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 30-Oct-19 at 08:06 """ # Complete the staircase function below. """def staircase(n): for stairs in range(1, n + 1): print(('#' * stairs).rjust(n)) """ def staircase(n): for i in range(n-1,-1,-1): for j in range(i): ...
false
75aabcea6f84ac4f13a725080c9858954074472c
ijoshi90/Python
/Python/maps_example.py
1,385
4.15625
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 19-12-2019 at 11:07 """ def to_upper_case(s): return str(s).upper() def print_iterator(it): for x in it: print(x, end=' ') print('') # for new line #print(to_upper_case("akshay")) #print_iterator("joshi") # map() with st...
false
bbcdeafd4fdc92f756f93a1a4f990418d295c643
ijoshi90/Python
/Python/variables_examples.py
602
4.375
4
""" Author : Akshay Joshi GitHub : https://github.com/ijoshi90 Created on 26-Sep-19 at 19:24 """ class Car: # Class variable wheels = 2 def __init__(self): # Instance Variable self.mileage = 20 self.company = "BMW" car1 = Car() car2 = Car() print ("Wheels : {}".format(Car.wheels)...
true
e41d966e65b740a9e95368d7e5b9286fe587f2cb
donwb/whirlwind-python
/Generators.py
537
4.28125
4
print("List") # List - collection of values L = [n ** 2 for n in range(12)] for val in L: print(val, end=' ') print("\n") print("Generator...") # Generator - recipie for creating a list of values G = (n ** 2 for n in range(12)) #generator created here, not up there... for val in G: print(val, end=' ') # Genera...
true
d3dd23e8f5e164ca4378e7817f983fca0bf89e1b
DylanGuidry/PythonFunctions
/dictionaries.py
1,098
4.375
4
#Dictionaries are defined with {} friend = { #They have keys/ values pairs "name": "Alan Turing", "Cell": "1234567", "birthday": "Sep. 5th" } #Empty dictionary nothing = {} #Values can be anything suoerhero = { "name": "Tony Stark", "Number": 40, "Avenger": True, "Gear": [ "f...
true
109aebf88bfac4cd1e7e097b085d3a3f909923fa
helinamesfin/guessing-game
/random game.py
454
4.15625
4
import random number = random.randrange(1,11) str_guess= input("What number do you think it is?") guess= int(str_guess) while guess != number: if guess > number: print("Not quite. Guess lower.") elif guess < number: print("Not quite. Guess higher.") str_guess= input("W...
true
11c57367b1f26d98d8ccab7ab1fc44fedfe7ca42
IceMints/Python
/blackrock_ctf_07/Fishing.py
1,503
4.25
4
# Python3 Program to find # best buying and selling days # This function finds the buy sell # schedule for maximum profit def max_profit(price, fee): profit = 0 n = len(price) # Prices must be given for at least two days if (n == 1): return # Traverse through given price array ...
true
a1514c507909bd3d00953f7a8c7dd09223779ead
VEGANATO/Organizing-Sales-Data-Code-Academy
/script.py
651
4.53125
5
# Len's Slice: I work at Len’s Slice, a new pizza joint in the neighborhood. I am going to use my knowledge of Python lists to organize some of the sales data. print("Sales Data") # To keep track of the kinds of pizzas sold, a list is created called toppings that holds different toppings. toppings = ["pepperoni", "pine...
true
4c4dcc03d10adde7510c0f9e1c252050b23cad92
brennomaia/CursoEmVideoPython
/ex039.py
724
4.15625
4
from datetime import date aNasc = int(input('Digite o ano de nascimento: ')) aAtual = date.today().year idade = aAtual - aNasc # Menores de idade if idade < 18: calc = 18-idade print('Quem nasceu em {} tem {} anos em {}.\nAinda faltam {} anos para o alistamento militar!\nO alistamento será em {}.'.format(aNas...
false
7df64998ce5965ba3fabcbd54cedc6751ca413c8
gustavovalverde/intro-programming-nano
/Python/Work Session 5/Loop 4.py
2,343
4.46875
4
# We now would like to summarize this data and make it more visually # appealing. # We want to go through count_list and print a table that shows # the number and its corresponding count. # The output should look like this neatly formatted table: """ number | occurrence 0 | 1 1 | 2 2 | 3 3 | 2 ...
true
a9bed93ff1f778a466167b06cbc8afa902dabf9e
gustavovalverde/intro-programming-nano
/Python/Problem Solving/Calc_age_on_date.py
2,173
4.21875
4
# Given your birthday and the current date, calculate your age # in days. Compensate for leap days. Assume that the birthday # and current date are correct dates (and no time travel). # Simply put, if you were born 1 Jan 2012 and todays date is # 2 Jan 2012 you are 1 day old. daysOfMonths = [31, 28, 31, 30, 31, 30, 31...
true
1018f2da0c71c59aa9491bf5ab74ab734accb09d
adirickyk/course-python
/try_catch.py
302
4.3125
4
#create new exception try: Value = int(input("Type a number between 1 and 10 : ")) except ValueError: print("You must type a number between 1 and 10") else: if(Value > 0) and (Value <= 10): print("You typed value : ", Value) else: print("The value type is incorrect !")
true
17b0b49f8b26d7ddf8f5e7543df2b457494e985e
younga7/leap_year
/alex_young_hw2.py
550
4.1875
4
# CS362 HW2 # Alex Young # 1/26/2021 # Run this file using python3 alex_young_hw2.py # This program checks if a year is a leap year with error handling c = 0 while c == 0: try: n = int (input('Enter year: ')) c = 1 except: print ('Error, input is not valid, try again!') if n % 4 == 0: ...
false
e8368e5d17e8682b1f8d59ab9466995584747627
castacu0/codewars_db
/15_7kyu_Jaden Casing Strings.py
1,069
4.21875
4
from string import capwords """ Jaden Smith, the son of Will Smith, is the star of films such as The Karate Kid (2010) and After Earth (2013). Jaden is also known for some of his philosophy that he delivers via Twitter. When writing on Twitter, he is known for almost always capitalizing every word. For simplicity, you...
true
9940f02410122ddc6d0a9394479576fa0fb1a4fb
marizmelo/udacity
/CS262/lesson3/mapdef.py
267
4.125
4
def mysquare(x): return x * x print map( mysquare, [1, 2, 3, 4, 5]) print map( lambda(x): x * x, [1, 2, 3, 4, 5]) # this use of lambda is sometimes called anonymous function print [len(x) for x in ["hello", "my", "friends"]] print [x * x for x in [1, 2, 3, 4, 5]]
true
1451fa9c04e5ce8636d023001c663fb6a988b0bf
wajishagul/wajiba
/Task4.py
884
4.375
4
print("*****Task 4- Variables and Datatype*****") print("Excercise") print("1. Create three variables (a,b,c) to same value of any integer & do the following") a=b=c=100 print("i.Divide a by 10") print(a,"/",10,"=",a/10) print("ii.Multiply b by 50") print(b,"*",50,"=",b*50) print("iii.Add c by 60") print(c,"+",50,"=",b...
true
e4849cacfa472b48f1fdb666339c05655b491ffa
vspatil/Python3-HandsOn
/Chapter_6_UserInputs_whileLoops/Exercise_7.5.py
1,580
4.15625
4
"""prompt = "Enter a series of toppings : " message = "" while message != 'quit': message = input(prompt) if message == 'quit': break else: print("We will add " + message + " to the pizza!")""" """ age='' while age != 'quit': age = input("Enter your age : ") if age == 'quit': ...
false
fc70c57920b9e56aae696754aa6ff347e7971aba
Jackroll/aprendendopython
/exercicios_udemy/desafio_contadores_41.py
375
4.3125
4
"""fazer uma iteração para gerar a seguinte saída: 0 10 1 9 2 8 3 7 4 6 5 5 6 4 7 3 8 2 """ # método 01 - usando while i = 0 j = 10 while i <= 8: print(i, j) i = i+1 j = j-1 print('------------------') # método 02 - usando for com enumerate e range for r, i in enumerate(range(10,1, -1)): #enumerate cont...
false
972a883e10eda7523b400da701755868927938e8
Jackroll/aprendendopython
/agregacao/classes.py
982
4.3125
4
""" Agregação é quando uma classe pode existir sozinha, no entanto ela depende de outra classe para funcionar corretamente por exemplo: A Classe 'Carrinho de compras' pode existir sózinha, mas depende da classe 'Produtos' para pode funcionar corretamente pois seus métodos dependem da classe produto. E classe Produtos p...
false
0c1622a3e7497ab2ef4a8274bf3cae27492824df
Jackroll/aprendendopython
/exercicios/PythonBrasilWiki/exe003_decisao.py
490
4.1875
4
#Faça um Programa que verifique se uma letra digitada é "F" ou "M". Conforme a letra escrever: F - Feminino, M - Masculino, Sexo Inválido. letra = str(input('Digite F ou M :')) letra_upper = letra.upper() #transforma a string para Uppercase para não haver erro em caso de digitação da letra em minusculo if l...
false
55dace0617bee83c0abef6e191326eb87f464c6a
Jackroll/aprendendopython
/exercicios_udemy/Programacao_Procedural/arquivos/arquivo_aula_83.py
1,867
4.125
4
file = open('abc.txt', 'w+') #cria o arquivo 'abc.txt' em modo de escrita w+ apaga tudo que ta no arquivo antes de iniciar a escrita file.write('linha 1\n') #escreve varias linhas no arquivo file.write('linha 2\n') file.write('linha 3\n') file.write('linha 4\n') print('-=' * 50) ...
false
2f18dce6db44f8cbde41683bccd3f16611aace20
Jackroll/aprendendopython
/exercicios_udemy/Modulos_uteis/Json/json_main.py
978
4.34375
4
""" trabalhando com json Documentação : https://docs.python.org/3/library/json.html json -> python = loads / load python -> json = dumps / dump """ from aprendendopython.exercicios_udemy.Modulos_uteis.Json.dados import * import json # convertendo dicionário para json dados_json = json.dumps(clientes_dicionario, inden...
false
1b139816100f6157c1492c44eb552c096fb8b32f
verma-rahul/CodingPractice
/Medium/InOrderTraversalWithoutRecursion.py
2,064
4.25
4
# Q : Given a Tree, print it in order without Traversal # Example: 1 # / \ # 2 3 => 4 2 5 1 3 # / \ # 4 5 import sys import random # To set static Seed random.seed(1) class Node(): """ Node Struct """ def __init__(self,val=None): self.val=val ...
true
81eba7d41e0f8962458519751b02c21dc52c88a5
Sreenidhi220/IOT_Class
/CE8OOPndPOP.py
1,466
4.46875
4
#Aum Amriteshwaryai Namah #Class Exercise no. 8: OOP and POP illustration # Suppose we want to model a bank account with support for 'deposit' and 'withdraw' operations. # One way to do that is by Procedural Programming # balance = 0 # def deposit(amount): # global balance # balance += amount # ...
true
c79f3df4eb01631e73363cd6e5e6546e15380b30
edran/ProjectsForTeaching
/Classic Algorithms/sorting.py
2,073
4.28125
4
""" Implement two types of sorting algorithms: Merge sort and bubble sort. """ def mergeMS(left, right): """ Merge two sorted lists in a sorted list """ llen = len(left) rlen = len(right) sumlist = [] while left != [] and right != []: lstack = left[0] while right...
true
4b41489f518c4cbca1923440c3416cdfef345f88
edran/ProjectsForTeaching
/Numbers/factprime.py
657
4.28125
4
""" Have the user enter a number and find all Prime Factors (if there are any) and display them. """ import math import sys def isPrime(n): for i in range(2,int(math.sqrt(n)) + 1): # premature optimization? AH! if n % i == 0: return False return True def primeFacts(n): l = [] fo...
true
1ab87bc5c2863c90dea96185241b0869f2259f30
sonusbeat/intro_algorithms
/Recursion/group_exercise2.py
489
4.375
4
""" Group Exercise Triple steps """ def triple_steps(n): """ A child is running up a staircase with n steps and can hop either 1 step, 2 steps, or 3 steps at a time. Count how many possible ways the child can run up the stairs. :param n: the number of stairs :return: The number of possible way...
true
916e2aa4bc23a717c6ba3d196b26cb44a02e6c78
sonusbeat/intro_algorithms
/7.Loops/01.exercise.py
469
4.21875
4
# Exercises # 1. Write a loop to print all even numbers from 0 to 100 # for num in range(101): # if num % 2 == 0: # print(num) # list comprehension # [print(i) for i in range(101) if i % 2 == 0] # 2. Write a loop to print all even numbers from 0 to 100 # for i in range(0, 101): # if i % 2 == 1: # ...
false
ec45e6109ddd2f2f3b9984404f015b828f0ca4f1
sonusbeat/intro_algorithms
/SearchingAlgorithms/2.binary_search.py
1,037
4.28125
4
""" Binary Search - how you look up a word in a dictionary or a contact in phone book. * Items have to be sorted! """ alist = [ "Australia", "Brazil", "Canada", "Denmark", "Ecuador", "France", "Germany", "Honduras", "Iran", "Japan", "Korea", "Latvia", "Mexico", "Netherlands", "Oman", "Philippines", ...
true
4bb0736d12da8757a76839f242d902fb08afc461
vamsikrishna6668/python
/class2.py
559
4.3125
4
# w.a.p on class example by static method and static variables and take a local variable also print without a reference variable? class student: std_idno=101 std_name="ismail" @staticmethod def assign(b,c): a=1000 print("The Local variable value:",a) print("The static ...
true
3a5908b10e1eb651085ac4dee75e344b8bb9cc83
singzinc/PythonTut
/basic/tut2_string.py
785
4.3125
4
# ====================== concat example 1 =================== firstname = 'sing' lastname = 'zinc ' print(firstname + ' ' + lastname) print(firstname * 3) print('sing' in firstname) # ====================== concat example 2 =================== foo = "seven" print("She lives with " + foo + " small men") # ======...
true
590b4ee6898e35551b8059ef9256d307a8bcce59
markvakarchuk/ISAT-252
/Python/Rock, Paper, Scissors - Linear.py
1,891
4.1875
4
import time import random # defining all global variables win_streak = 0 # counts how many times the user won play_again = True # flag for if another round should be played game_states = ["rock", "paper", "scissors"] #printing the welcome message print("Welcome to Rock, Paper, Scissors, lets play!") time.slee...
true
c3f3e836042df5e06d1f19b26fda1197726d2030
mikofski/poly2D
/polyDer2D.py
2,204
4.25
4
import numpy as np def polyDer2D(p, x, y, n, m): """ polyDer2D(p, x, y, n, m) Evaluate derivatives of a 2-D polynomial using Horner's method. Evaluates the derivatives of 2-D polynomial `p` at the points specified by `x` and `y`, which must be the same dimensions. The outputs `(fx, fy)` will ...
true
4f6c341cb5903f526d9780af9d1aa2f8b2b87e35
JakeBednard/CodeInterviewPractice
/6-1B_ManualIntToString.py
444
4.125
4
def int_to_string(value): """ Manually Convert String to Int Assume only numeric chars in string """ is_negative = False if value < 0: is_negative = True value *= -1 output = [] while value: value, i = divmod(value, 10) output.append((chr(i + ord('0'))))...
true
5573f3eeb4a16263a4204b4ef1058858646b9873
sptechguru/Python-Core-Basics-Programs
/oops/multipleinhertance.py
1,101
4.1875
4
import time class phone: def __init__(self,brand,model_name,price): self.brand = brand self.model_name = model_name self.price = price def full_name(self): return f"{self.brand}{self.model_name} {self.price}" # multiple inheritance in class phone is Dervive Class & Main Cl...
false
7d26e6913a4b0024fa1082e5f3ea7c9ff0cbc50b
Azab007/Data-Structures-and-Algorithms-Specialization
/algorithms on strings/week2/suffix_array/suffix_array.py
572
4.21875
4
# python3 import sys from collections import defaultdict def build_suffix_array(text): """ Build suffix array of the string text and return a list result of the same length as the text such that the value result[i] is the index (0-based) in text where the i-th lexicographically smallest suffix of text sta...
true
eba2ffaeaf9b38da5f9ae60b785f406070267873
nuggy875/tensorflow-of-all
/7. gradient descent algorithm.py
1,147
4.125
4
# 7. gradient descent algorithm # 경사 하강법 이해를 목적으로 한다. import tensorflow as tf # 그래프 빌드 # # 데이터 x_data = [1, 2, 3] y_data = [1, 2, 3] # 변하는 값 W = tf.Variable(tf.random_normal([1]), name='weight') # 데이터를 담는 값 'feed_dict' X = tf.placeholder(tf.float32) Y = tf.placeholder(tf.float32) # Our hypothesis for linear model X * ...
false
01aaf5aec0ca74fdfec8f95d7137979737c313a4
JMH201810/Labs
/Python/p01320g.py
1,342
4.5
4
# g. Album: # Write a function called make_album() that builds a dictionary describing # a music album. The function should take in an artist name and an album # title, and it should return a dictionary containing these two pieces of # information. Use the function to make three dictionaries representing # differe...
true
64a30bf626d62b29ae78c9ac9435dc1ca5c929f3
JMH201810/Labs
/Python/p01320L.py
568
4.15625
4
# l. Sandwiches: # Write a function that accepts a list of items a person wants on a sandwich. # The function should have one parameter that collects as many items as the # function call provides, and it should print a summary of the sandwich that # is being ordered. # Call the function three times, using a di...
true
ae64e924773c4243da27404de13e74ce2e973b56
JMH201810/Labs
/Python/p01310j.py
631
4.59375
5
# Favorite Places: # Make a dictionary called favorite_places. # Think of three names to use as keys in the dictionary, and store one to # three favorite places for each person. # Loop through the dictionary, and print each person's name and their # favorite places. favorite_places = {'Alice':['Benton Harbor'...
true
d6c1fa3d43547d59fa10a9e6d1e51e169dac8a18
JMH201810/Labs
/Python/p01210i.py
924
4.875
5
# Pizzas: Think of at least three kinds of your favorite pizza. Store these pizza # names in a list, and then use a for loop to print the name of each pizza. pizzaTypes = ['Round', 'Edible', 'Vegetarian'] print("Pizza types:") for type in pizzaTypes: print(type) # i. Modify your for loop to print a senten...
true
e86600435612f88fbf67e3e805f0e21e6f0f51f8
23-Dharshini/priyadharshini
/count words.py
253
4.3125
4
string = input("enter the string:") count = 0 words = 1 for i in string: count = count+1 if (i==" "): words = words+1 print("Number of character in the string:",count) print("Number of words in the string:",words)
true
1622d36817330cc707a1a4e4c4e52810065aa222
Whatsupyuan/python_ws
/4.第四章-列表操作/iterator_044_test.py
1,306
4.15625
4
# 4-10 players = ['charles', 'martina', 'michael', 'florence', 'eli'] print("The first three items in the list are" ) print(players[:3]) print() # python3 四舍五入 问题 # 官方文档写了,round(number[, ndigits]) values are rounded to the closest multiple of 10 to the power minus ndigits; # if two multiples are equally close, round...
true
134d4811b1e629067e1f711f145fff9b889617aa
Whatsupyuan/python_ws
/6.第六章-字典(Dictionary)/06_dic_0603_iteratorDictionary.py
734
4.28125
4
favorite_num_dic = {"Kobe": 24, "Jame": 23, "Irving": 11} # 自创方法,类似于Map遍历的方法 for num in favorite_num_dic: print(num + " " + str(favorite_num_dic[num])) print() # 高级遍历方法 items() 方法 print(favorite_num_dic.items()) for name,number in favorite_num_dic.items(): print(name + " " + str(number)) print() # key获取 字典 中的...
false
3d999ca8f12348a3cb229be5af0f9cdba4ccc0b2
ArvindAROO/algorithms
/sleepsort.py
1,052
4.125
4
""" Sleepsort is probably the wierdest of all sorting functions with time-complexity of O(max(input)+n) which is quite different from almost all other sorting techniques. If the number of inputs is small then the complexity can be approximated to be O(max(input)) which is a constant If the number of inputs is l...
true
77d4482ba88837a3bca6280a08320a2b0eb70aac
KD4N13-L/Data-Structures-Algorithms
/Sorts/merge_sort.py
1,591
4.21875
4
def mergesort(array): if len(array) == 1: return array else: if len(array) % 2 == 0: array1 = [] half = (int(len(array) / 2)) for index in range(0, half): array1.append(array[index]) array2 = [] for index in range(half, ...
false
911d4753a01ab601346e3bc2f3b483a61d21c7ae
bspindler/python_sandbox
/classes.py
1,180
4.3125
4
# A class is like a blueprint for creating objects. An object has properties and methods (functions) # associated with it. Almost everything in Python is an object # Create Class class User: # constructor def __init__(self, name, email, age): self.name = name self.email = email self...
true
c246c6a153b6bc176ed0e279a60d32f1b2100711
ntkawasaki/complete-python-masterclass
/7: Lists, Ranges, and Tuples/tuples.py
1,799
4.5625
5
# tuples are immutable, can't be altered or appended to # parenthesis are not necessary, only to resolve ambiguity # returned in brackets # t = "a", "b", "c" # x = ("a", "b", "c") # using brackets is best practice # print(t) # print(x) # # print("a", "b", "c") # print(("a", "b", "c")) # to print a tuple explicitly i...
true
acf3384d648aa16c781ac82c61b8e3c275538bae
ntkawasaki/complete-python-masterclass
/10: Input and Output/shelve_example.py
1,638
4.25
4
# like a dictionary stored in a file, uses keys and values # persistent dictionary # values pickled when saved, don't use untrusted sources import shelve # open a shelf like its a file # with shelve.open("shelf_test") as fruit: # makes a shelf_test.db file # fruit["orange"] = "a sweet, orange fruit" # fruit[...
true
fcd60015393e712316586a32f75462eff2f4543f
ntkawasaki/complete-python-masterclass
/11: Modules and Functions/Functions/more_functions.py
2,460
4.125
4
# more functions! # function can use variables from main program # main program cannot use local variables in a function import math try: import tkinter except ImportError: # python 2 import Tkinter as tkinter def parabola(page, size): """ Returns parabola or y = x^2 from param x. :param page: ...
true
4ccdd7851dc2177d6a35e72cb57069685d75f72c
echo001/Python
/python_for_everybody/exer9.1.py
706
4.21875
4
#Exercise 1 Write a program that reads the words in words.txt and stores them as # keys in a dictionary. It doesn’t matter what the values are. Then you # can use the in operator as a fast way to check whether a string is # in the dictionary. fname = input('Enter a file na...
true
19e74e3bc318021556ceec645597199996cfba98
echo001/Python
/python_for_everybody/exer10.11.3.py
1,251
4.40625
4
#Exercise 3 Write a program that reads a file and prints the letters in # decreasing order of frequency. Your program should convert all the # input to lower case and only count the letters a-z. Your program # should not count spaces, digits, punctuation, or anything other ...
true
3168d9379b4ff8064b60ed5e6db65d504c91f5a0
marcluettecke/programming_challenges
/python_scripts/rot13_translation.py
482
4.125
4
""" Function to shift every letter by 13 positions in the alphabet. Clever use of maketrans and translate. """ trans = str.maketrans('ABCDEFGHIJKLMabcdefghijklmNOPQRSTUVWXYZnopqrstuvwxyz', 'NOPQRSTUVWXYZnopqrstuvwxyzABCDEFGHIJKLMabcdefghijklm') def rot13(message): """ Translation by rot...
true
ae038beb027640e3af191d24c6c3abbb172e398e
mihaidobri/DataCamp
/SupervisedLearningWithScikitLearn/Classification/02_TrainTestSplit_FitPredictAccuracy.py
777
4.125
4
''' After creating arrays for the features and target variable, you will split them into training and test sets, fit a k-NN classifier to the training data, and then compute its accuracy using the .score() method. ''' # Import necessary modules from sklearn.neighbors import KNeighborsClassifier from sklearn.model_sele...
true