blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
4744ad31ee30f7428017da886d2f8c1b3271f3e6
wgh19950620/python_test
/venv/com.src.wgh/variable/tuple_variable.py
1,533
4.84375
5
""" 元组(tuple)与列表类似,不同之处在于元组的元素不能修改。元组写在小括号 () 里,元素之间用逗号隔开。 元组中的元素类型也可以不相同 元组与字符串类似,可以被索引且下标索引从0开始,-1 为从末尾开始的位置。也可以进行截取 元组元素不可被修改 虽然tuple的元素不可改变,但其可以包含可变对象,如list列表 """ tuple_test = ('hello', 786, 2.23, 'python', 70.2) tiny_tuple = (123, 'python') print("tuple_test: ") print(tuple_test) # 输出完整元组 print(tuple_test[0]) ...
false
3eff129c86eaa9651a8f97a2c2c85928988cf340
abderrahmanesaad/python-climb-learning-tutorial
/python-tips-and-tricks/enumeration/main.py
267
4.125
4
mynames = ['john', 'mike', 'anna', 'bob', 'sara'] counter = 0 for name in mynames: print(f'{counter}: {name}') counter += 1 for index, name in enumerate(mynames): print(f'{index}: {name}') print(list(enumerate(mynames))) print(dict(enumerate(mynames)))
false
fc416eac9e468b582974225de2c8d4fe1f43470b
arpitgupta275/MyCaptain-Python
/task1.py
401
4.46875
4
import math # accepts radius of circle and computes area radius = float(input('Input the radius of the circle : ')) area = math.pi * radius * radius print(f'The radius of the circle with radius {radius} is: {area}') # accepts a filename and prints its extension filename = input('Input the Filename: ') f_extns = f...
true
0cd177b0f508ba272e1cca5ec047800dc4753cba
AaronDonaldson74/code-challenges
/python/biggest_smallest.py
591
4.15625
4
### biggest / smallest function def biggest_smallest(selection, list_of_numbers): # list_of_numbers = [43, 53, 27, 40, 100, 201] list_of_numbers.sort() smallest_num = (list_of_numbers[0]) biggest_num = (list_of_numbers[-1]) # selection = ("small") if selection == ("small"): print("sm...
true
092c64fb38b2fa9190c62f47d53bfa2f1cb693f3
AaronDonaldson74/code-challenges
/python/birthday.py
508
4.78125
5
# Create a variable called name and assign it a string with your name. Create a variable called current_year and assign it an int. Create a variable called birth_year and assign it an int. Using the following variables print the following result. Please print it using the f"" way. # Example result: "Hello, my name is D...
true
c2fbd24d7c4efc16cb8b2ce178482511234394ab
rdvnkdyf/codewars-writing
/python/sum-of-odd-numbers.py
569
4.21875
4
""" Given the triangle of consecutive odd numbers: 1 3 5 7 9 11 13 15 17 19 21 23 25 27 29 Calculate the row sums of this triangle from the row index (starting at index 1) e.g.: row_sum_odd_numbers(1); # 1 row_sum_odd_numbers(2); # 3 + 5 = 8 """ import ...
true
0bed93426d83ed50a1dfb8df94b2fee2e6dd1963
Nusrat-H/python-for-everybody
/MyownfunctionD.py
793
4.40625
4
""" Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the f...
true
f6a555bb8191ed9f969793247810259c6e809d41
aycelacap/py_playground
/Fundamentals/Basics i/041_list_slicing.py
394
4.375
4
string = "hello" string[0:2:1] # string[start:stop:step] # we can apply the concept of string slicing to lists # lists are mutable # with list slicing, we create a new copy listlists are mutable amazon_cart = new_cart # these two variable would point on the same place in memory # if instead we want to copy a li...
true
6cf892b2d5ca9fe205c819ba3487f60a30c400b1
aycelacap/py_playground
/Fundamentals/Basics i/053_dictionary_methods_ii.py
1,076
4.5
4
# how else can we look for items in a dictionary? user = { 'basket': [1, 2, 3] 'greet': 'hello' } print('basket' in user) #True print('hello' in user.keys()) #False print('greet' in user.keys()) #True # how can we grab items print(user.items()) #this prints out a list of the key/value pairs, in tuple form prin...
true
a29f118e72afd2fea0af99e51e1133487de93a94
aycelacap/py_playground
/Fundamentals/Basics i/037_type_conversion.py
608
4.25
4
name = "Ayce" age = 100 relationship_status = "complicated" relationship_status = "single" # create a program that can guess your age birth_year = input("What year were you born?") guess = 2020 - int(birth_year) print("your age is: {guess}") # string interpolation and input from user as seen in video # if confuse...
true
3ec531367f1e906f1ac3954e860e0d9ba558c41e
campbellmarianna/Code-Challenges
/python/spd_2_4/binary_search_tree.py
2,701
4.1875
4
# Binary Search Tree in Python Credits: Joe James https://youtu.be/YlgPi75hIBc class Node: def __init__(self, val): self.value = val self.leftChild = None self.rightChild = None def insert(self, data): if self.value == data: return False elif self.value > d...
false
65f91220ffcbf25c289a329c0bd3ecc189bfc014
AxelSeg/course-material
/exercices/203/solution.py
214
4.15625
4
# -*- coding: utf-8 -*- """ Created on Mon Sep 22 22:37:07 2014 @author: Axel """ def is_multiple(value1, value2): if value2 % value1 == 0: print(True) else: print(False) is_multiple(2, 6)
false
3f7dd2e108ad2bd674d6f8483e30e6e70750f0c0
pawlodkowski/advent_of_code_2020
/day_12/part1.py
2,139
4.28125
4
""" Part 1 of https://adventofcode.com/2020/day/12 """ # TO-DO: Is it possible to contain the navigation information in a single data structure? CARDINALS = {"E": (1, 0), "S": (0, -1), "W": (-1, 0), "N": (0, 1)} BEARINGS = [(1, 0), (0, -1), (-1, 0), (0, 1)] # maps to current bearing def read_data(filename: str) ->...
true
bb46a7fd5c5b409a8f000ad3bd5cd91f8998a120
fengeric/LearnPythonProject
/hello.py
1,199
4.28125
4
print("hahaha") # 被双引 号包括的字符串 和被单引 号括起的字符串 其工作机制完全相同 # 你可以通过使用 三个引 号—— """ 或 ' ' ' 来指定多 行字符串 。 你可以在三引 号之间 自 由 地使用 单引 号与 双引 号。 # -------------------------------------------- # format的用法,Python 中 format 方法所做的事情便是将每个参数值替换至格式所在的位置 name = "feng" age = 20 print("1{0} was {1} years old when he wrote this book".format(name, ag...
false
867c58f1bef940d3ea93f06e7ce3b793e18dbc03
yuntianming0613/learnpython
/条件判断.py
1,147
4.25
4
# -*- coding: utf-8 -*- age = 20 if age >= 18: print('your age is ', age) print('adult') age = 3 if age >= 18: print('your age is ', age) print('adult') else: print('your age is ', age) print('teenager') age = 4 if age >=18: print('your age is', age) print('adult') elif age >= 6: ...
false
02301984b7cf81be680136da913bf3696c16cab6
Farah-H/python_classes
/class_task.py
1,808
4.34375
4
# Task # create a Cat class class Cat: # Create 2 class level variables coward = False cute = True fluffy = True # one function which returns 'MEOWWWWWWW', added some details :) def purr(self,cute,coward,fluffy): if cute and fluffy: print('You approach this adorable cat..') ...
true
3fbba0b056c2aa515949f6be884331401a6d71ad
G8A4W0416/Module6
/more_functions/validate_input_in_functions.py
921
4.34375
4
def score_input(test_name, test_score=0, invalid_message='Invalid test score, try again!'): """ This takes in a test name, test score, and invalid message. The user is prompted for a valid test score until it is in the range of 0-100, then prints out the valid input as 'Test name: ##'. :param test_name: Str...
true
6832afafc0f5c16e3222c3ce6051b5585bd7710d
General-Gouda/PythonTraining
/Training/Lists.py
713
4.25
4
student_names = [] # Empty List variable student_names = ["Mark","Katarina","Jessica"] # List variable with 3 entries print(student_names) student_names.append("Homer") # Adds Homer into the List print(student_names) if "Mark" in student_names: # Checks to see if the string "Mark" is in the List student_names ...
true
ac743ad6bd03bedb544e59d2d1797fc3ff2b7a9e
General-Gouda/PythonTraining
/Training/ForLoops.py
975
4.4375
4
student_names = ["Mark", "Katarina", "Jessica"] for name in student_names: print("Student name is {0}".format(name)) # Interates through each element in the List. There is no ForEach in Python. For does it automatically. x = 0 for index in range(10): # Range(10) if it were printed would look like [0,1,2,3,4,5...
true
df05bbb841a4142ff87889cce1e1f014de49987c
ad-egg/holbertonschool-higher_level_programming
/0x0A-python-inheritance/100-my_int.py
583
4.1875
4
#!/usr/bin/python3 """ this module contains a class MyInt which inherits from int """ class MyInt(int): """ this class MyInt inherits from int but has == and != operators inverted """ def __init__(self, value=0): """ instantiates an instance of MyInt with value """ self...
true
b7849c1c75bd8ae24fbe9c4d8b136b4b1c5bcd19
ad-egg/holbertonschool-higher_level_programming
/0x08-python-more_classes/4-rectangle.py
2,717
4.59375
5
#!/usr/bin/python3 """ This module contains an empty class that defines a rectangle. """ class Rectangle: """an empty class Rectangle that defines a rectangle a rectangle is a parallelogram with four right angles """ def __init__(self, width=0, height=0): """ instantiates a rectangle w...
true
fe509c567d5b9ab36da3f50ee7f17ae92f0f0b0d
SmiteLi/python-note
/base/7-filter-sorted.py
1,431
4.125
4
# filter()也接收一个函数和一个序列。和map()不同的是,filter()把传入 # 的函数依次作用于每个元素,然后根据返回值是True还是False决定保留还是丢弃该元素。 # filter()函数返回的是一个Iterator,也就是一个惰性序列,所以要强迫filter()完成计算结果, # 需要用list()函数获得所有结果并返回list。 def is_odd(n): return n % 2 == 1 list(filter(is_odd, [1, 2, 4, 5, 6, 9, 10, 15])) def not_empty(s): return s and s.strip(...
false
030d32c1d9e1f809046976a7e1bb2aea87736aed
NixonRosario/crytography-using-Fernet
/main.py
2,419
4.21875
4
# This is a sample Python script. # Press Shift+F10 to execute it or replace it with your code. # Press Double Shift to search everywhere for classes, files, tool windows, actions, and settings. from cryptography.fernet import Fernet # install cryptography and import Fernet key = Fernet.generate_key() # gen...
true
ec823e35ba2387cca400cea55d8916034f0123d1
RayWLMo/Eng_89_Python_Collections
/dict_sets.py
2,064
4.8125
5
# Dictionaries and Sets are both data collections in Python # Dictionaries # Dict are another way to manage data but can be a little more Dynamic\ # Dict work as a KEY AND VALUE # KEY = THE REFERENCE OF THE OBJECT # VALUE + WHAT THE DATA STORAGE MECHANISM YOU WISH TO USE # Dynamic as it we have Lists, and anot...
true
374a8d5bbe59f30f7d8b1a6b9f02c9be92120e91
group1BSE1/BSE-2021
/src/chapter5/exercise2.py
292
4.15625
4
largest = None smallest = None while True: num = input('Enter a number: ') if num =='done': break elif largest is None or num > largest: largest = num elif smallest is None or num < num: smallest = num print('maximum',largest) print('minimum',smallest)
true
d974e78ca248bb2322da4ca150b523610bdb67df
AranzaCarolina/Primerrepo
/evidenciaWhile.py
763
4.125
4
#Menu Ciclico while True: print("operaciones: [1]suma, [2]resta, [3]multitplicacion, [4]division, [5]salir") eleccion = input("Selecciona una de las opciones anteriores: ") if eleccion == "1" or eleccion == "2" or eleccion == "3" or eleccion == "4": n1 = int(input("introduce el primer numero: ")) ...
false
9250e0bab7e1c634b3aa416c66bce8cddd5ec048
timurkurbanov/firstPythonCode
/firstEx.py
463
4.46875
4
# Remember, we get a string from raw_input, but we need an int to compare it weather = int(25); # if the weather is greater than or equal to 25 degrees if weather >= 25: print("Go to the beach!") # the weather is less than 25 degrees AND greater than 15 degrees elif weather < 25 and weather > 15: print("Go ho...
true
7bc262beb842765e249819a987fd68c68f3bd0b1
MTaylorfullStack/flex_lesson_transition
/jan_python/week_one/playground.py
1,191
4.15625
4
print("Hello World") ## Data Types ## String collection_of_characters="hrwajfaiugh5uq34ht834tgu89398ht4gh0q4tn" collection_of_characters+="!!!!!!!!!!!!!" name="Adam" stack="Python" # print(f"The student {name} is in the {stack} stack") ## Numbers ## Operators: +, -, /, *, % ten=10 one_hundred=100 # print(one_hu...
true
2f288985a6f9a652688bf2112a8fb5599a60080d
tiandrioni/python
/lesson4/lesson4-5.py
728
4.3125
4
""" Реализовать формирование списка, используя функцию range() и возможности генератора. В список должны войти четные числа от 100 до 1000 (включая границы). Необходимо получить результат вычисления произведения всех элементов списка. Подсказка: использовать функцию reduce(). """ from functools import reduce def mu...
false
6a0b6f550fbd00cf80b035789b7364626d2b55d1
wesleyhooker/assign1
/ccpin.py
1,355
4.40625
4
#!/usr/bin/env python3 """ Validates that the user enteres the correct PIN number """ def valid_input(input): """ Checks for valid PIN Number Argument: input = the users inputted PIN Returns: Any Errors with the input TRUE if it passes, False if it doenst """ if(len(inp...
true
384cb75137c4702da88da4a227e2af8c72f3a0a8
jeffvswanson/DataStructuresAndAlgorithms
/Stanford/10_BinarySearchTrees/red_black_node.py
2,069
4.25
4
# red_black_node.py class Node: """ A class used to represent a Node in a red-black search tree. Attributes: key: The key is the value the node shall be sorted on. The key can be an integer, float, string, anything capable of being sorted. instances (int): The number o...
true
5fd2e1ce1bb2dd34be5958f80787f04a4b0dcacf
icicchen/PythonGameProgramming
/Power of Thor - episode 1.py
2,073
4.46875
4
# Power of Thor - easy '''This program allows Thor to reach the light of power by giving it directions''' import sys import math # light_x: the X position of the light of power # light_y: the Y position of the light of power # initial_tx: Thor's starting X position # initial_ty: Thor's starting Y position light_x, l...
false
2c6883f73522c971670cae797200f454968a635f
Neeragrover/HW04
/HW04_ex00.py
1,265
4.21875
4
#!/usr/bin/env python # HW04_ex00 # Create a program that does the following: # - creates a random integer from 1 - 25 # - asks the user to guess what the number is # - validates input is a number # - tells the user if they guess correctly # - if not: tells them too high/low # - only lets t...
true
3ec08d9e5985e5ab19eae234835ae990bd31d8ac
lamngockhuong/python-guides
/basic/dictionaries/dictionaries-1.py
1,106
4.46875
4
# https://www.w3schools.com/python/python_dictionaries.asp thisdict = { "brand": "Ford", "model": "Mustang", "year": 1964 } print(thisdict) x = thisdict["model"] print(x) y = thisdict.get("model") print(y) # Change values thisdict["year"] = 2019 print(thisdict) # Return values of a dictionary for x in ...
true
524b7612faa6b189b228d9f8e6aca0f69fbf6364
lamngockhuong/python-guides
/basic/strings/strings-2.py
497
4.375
4
# https://www.w3schools.com/python/python_strings.asp x = "Hello, world!" print(x[2:5]) y = " Hello world " print(y.strip()) # remove any whitespace from the beginning or the end print(len(y)) # return the length of a string print(y.lower()) # return the string in lower case print(y.upper()) # return the strun...
true
de9b2cef5eea479083e2932d8291e8ba6a4188bf
kisa411/CSE20211
/isPalindrom.py
476
4.15625
4
word = raw_input("Enter a word:") list = [] start = 0 end = len(word) - 1 def isPalindrome(word): global start global end for letter in word: list.append(letter) while (start < end): if list[start] != list[end]: return False else: return True s...
true
b0f26fc98716307747c63e4bbc3921dd660ac6b1
waddahAldrobi/RatebTut-
/Python Algs copy/print bst by level.py
504
4.125
4
def print_bst(tree): current_level = [tree.root] while current_level: next_level = [] for node in current_level: print(node.value,end='') # Logic to start building the next level ##Added if node.left: next_level.append(node.left) ...
true
8fc3791795ba4f7be4da91cf325c64d2a3810572
alexnicolescu/Python-Practice
/lambda/ex1.py
289
4.1875
4
# Write a Python program to create a lambda function that adds 15 to a given number passed in as an argument, also create a lambda function that multiplies argument x with argument y and print the result. def l1(x): return x + 15 def l2(x, y): return print(x*y) print(l1(15)) l2(12, 10)
true
a6099bc9283e52aacf41fb0d83a1b357adb9b67d
ValDagon/different
/Quadratic Equations/Quadratic Equations.py
1,584
4.1875
4
# Valentin 1 September 2017 # Решение квадратных уравнений import math while True: a = float(input('Введите a: ')) b = float(input('Введите b: ')) c = float(input('Введите c: ')) #total = str(a) + "x^2" + str(b) + "x" + str(c) #print("Итоговый вид уравнения: ", total) d = b ** 2...
false
c82870abca988247ab2a07c841550bf1e57d36b8
Adamrathjen/MOD1
/Module1.py
1,073
4.125
4
import os print("Character Creator!") selected = 1 while "4" != selected: print("Make new Character: 1") print("Delete character: 2") print("See current characters: 3") print("Quit: 4") selected = input("Make your selection: ") if selected == "1": print("you selected 1") char...
true
7b67bdcd6f6dfef936e27507d5b5390562475359
sohinipattanayak/Fundamentals_Of_Python
/p2_palindrome_num.py
638
4.21875
4
#Check if num is plaindrome num=int(input("Enter the number: ")) num_str=str(num) #Type-casting the number to String flag=0 #No need to iterate throught the whole of string #Just iterate till the half of the string #If the last two match it is automatically a reverse for i in range(len(num_str)//2): #halfing the list...
true
a94426f5e57d3027080f43255a23b785fc829bae
alaamarashdeh92/CA06---More-about-Functions-Scope
/P3.py
2,132
4.375
4
# Shopping List # Your shopping list should keep asking for new items until nothing is entered (no input followed by enter/return key). # The program should then print a menu for the user to choose one of the following options: # (A)dd - To add a new item to the list. # (F)ind - To search for an item in the list....
true
d6482340a7a0125c28ac00e22c30974bb3edf79d
riteshsharma29/Python_data_extraction
/ex_2.py
501
4.28125
4
#!/usr/bin/python # coding: utf-8 -*- #This example shows reading a dataset using csv reader import csv #creating an empty list MonthlySales = [] with open('data/MonthlySales.csv', 'r') as f: reader = csv.DictReader(f) for row in reader: MonthlySales.append(row) for a in MonthlySales: print a ...
true
406002913411dfd9538c285b1969ddcee05bf9f9
yusufemrebudak/Python-Studies
/loop_operations.py
1,956
4.5625
5
# range method for item in range(2,10): # 2 den 10 a kadar olan sayıları yazdır print(item) print(list(range(5,100,20))) # [5, 25, 45, 65, 85] basar #################### enumarete #################### greeting = 'hello' for index,letter in enumerate(greeting): print(f'index: {index} , letter: {letter}') fo...
false
6a296745a5d413d0f2c23635425fba1e751d1af1
DanielOjo/Iteration
/Classroom exercises/Development/Iteration Class Exercise (Development Part 2).py
347
4.21875
4
#DanielOgunlana #31-10-2014 #Iteration Class Exercise (Development Part 2) number_stars = int(input("How many stars do you want on each row:")) number_display = int(input("How many times would you like this to display?:")) stars_printed = "*" for stars in range(1,number_display+1): print(stars_printed*n...
true
d223031deac627cd02f4c4cb223534b185b07579
asterane/python-exercises
/other/friend/Multiplication Tables.py
204
4.21875
4
print("What multiplication table would you like? ") i = input() print("Here's your table: ") for j in range(11): print(i, " x ", j, "=", i * j) # The code above creates the table... I hope. #
true
0cd5b92fbce3315dca5f35c815a7b6d73f91bbef
teresahu/digitalcrafts
/python-exercises-2/caesar_cipher.py
726
4.15625
4
caesar = { 'a' : 'n', 'b' : 'o', 'c' : 'p', 'd' : 'q', 'e' : 'r', 'f' : 's', 'g' : 't', 'h' : 'u', 'i' : 'v', 'j' : 'w', 'k' : 'x', 'l' : 'y', 'm' : 'z', 'n' : 'a', 'o' : 'b', 'p' : 'c', 'q' : 'd', 'r' : 'e', 's' : 'f', 't' : 'g', 'u' :...
false
a0208582f00a6f392e80905246e296dd45e843ca
b-ark/lesson_4
/Task3.py
820
4.375
4
# Create a program that reads an input string and then creates and prints 5 random strings # from characters of the input string. # For example, the program obtained the word ‘hello’, so it should print 5 random strings(words) # that combine characters ‘h’, ‘e’, ‘l’, ‘l’, ‘o’ -> ‘hlelo’, ‘olelh’, ‘loleh’ … # Tips: Use ...
true
14a4b02855d5b08a9a4c3b2eb8ee8e69474fed12
Atularyan/Letsupgrade-Assignment
/Day_3_Assignment/Day_3(Question2).py
338
4.25
4
""" Question 2 Define a function swap that should swap two values and print the swapped variables outside the swap function. """ def swap(n): rev=0 while(n>0): rem=n%10 rev=(rev*10)+rem n=n//10 return (rev+n) n=int(input("Enter the number = ")) res=swap(n) print("swap...
true
e47a5b27a63194e1a59814f5ce3d9d5fe1f0c5cc
vijay-Jonathan/Python_Training
/bin/44_classes_static_methods.py
2,156
4.15625
4
""" Client Requiremnt is :for 43rd example, add method to compute percentage, if student pass marks, method should return percentage. Now, for this compute_percentage method, not required to pass instance object OR class object, only passing 2 marks is enough method will return perecnetage. Other methods inside the ...
true
f14ac23d41d53f6cb09d94da5facd833aa3bb7f6
vijay-Jonathan/Python_Training
/bin/2_core_datatypes.py
1,842
4.25
4
""" CORE DATA TYPES : Similar to other languages, in python also we ALREADY have SOME options to store SOME kind of data. In that, 1. int,float,hex,bin classes : ALREADY have option to store numbers like int, float, hex, bin, oct etc 2. str class : ALREADY have option to store Strings like "My Name", "My Addess" etc 3...
true
c065a41651f03ca8f13fa7ae3f1102006e602962
N1ck079/lessons
/hw06_easy.py
2,972
4.28125
4
# Задача-1: # Следующая программа написана верно, однако содержит места потенциальных ошибок. # используя конструкцию try добавьте в код обработку соответствующих исключений. # Пример. # Исходная программа: def avg(a, b): """Вернуть среднее геометрическое чисел 'a' и 'b'. Параметры: - a, b (int или fl...
false
ba07cec6d0f3f8f0131b8ac1680314dedb04dd89
dmonzonis/advent-of-code-2019
/day3/day3.py
2,192
4.28125
4
def compute_path(path): """Return a set with all the visited positions in (x, y) form""" current = [0, 0] visited = {} total_steps = 0 for move in path: if move[0] == 'U': pos = 1 multiplier = 1 elif move[0] == 'D': pos = 1 m...
true
17baad513d548bf71b1ec6eea648fa0ca2917d7d
Ads99/python_learning
/python_crash_course/names.py
924
4.15625
4
name = "ada lovelace" print(name.title()) print(name.upper()) print(name.lower()) first_name = "ada" last_name = "lovelace" full_name = first_name + " " + last_name print(full_name) message = "Hello, " + full_name.title() + "!" print(message) # whitespace demo print("\tPython") print("Languages:\nPython\nC\nJavaScri...
true
1eb80efb19d1ef10b0b5ef2cfe6db47a3d3dc2ff
Ads99/python_learning
/python_crash_course/_11_3_example_employee_class.py
1,023
4.46875
4
# Example 11.3 - Employee # Write a class called Employee. The __init__() method should take in a first # name, last name and an annual salary and store each of these as attributes. # Write a method called give_raise() that adds $5000 to the annual salary by # default but also accepts a different raise amount class Em...
true
8b918360be7f45468c503e81f9c32b52e174ca17
AdarshSubhash/C-97-
/hwpro.py
351
4.15625
4
number=6 guess=int(input("Guess a number between 1 to 10")) if(guess==number): print("You Guessed The Right Number") elif(guess>number): print("Try a bit lower number") guess=int(input("Guess a number between 1 to 10")) else : print("Try a bit higher number") guess=int(input("Guess a number...
true
46a80d2f2be7f50395d1d80fda9d5b56375abb9a
StYaphet/learn_python
/exception.py
1,723
4.15625
4
# print(5 / 0) # ZeroDivisionError是一个异常对象。当python无法按照你的要求做的时候,就会创建这样的对象 # 在这种情况下,python将会停止运行程序,并指出发生了哪些异常,饿哦们就可以根据这些信息对程序进行修改 # 当认为可能发生了错误时,可编写一个try-except代码块来处理可能引发的异常。 try: print(5 / 0) except ZeroDivisionError: print("You can't divide by zero!") # 如果try-except 代码块后面还有其他代码,程序将接着运行,因为已经告诉了Python如何处理这种错误 #...
false
4d5aea2f9d176c16b665064761a8053cef554793
StYaphet/learn_python
/store_data.py
980
4.28125
4
# 模块json 让你能够将简单的Python数据结构转储到文件中,并在程序再次运行时加载该文件中的数据。 # 你还可以使用json 在Python程序之间分享数据。 # 更重要的是,JSON数据格式并非Python专用的,这让你能够将以JSON格式存储的数据与使用其他编程语言的人分享。 # 这是一种轻便格式,很有用,也易于学习。 # 首先导入模块json,在创建一个数字列表。 import json numbers = [2, 3, 5, 7, 11, 13] # 指定了要将该数字存储到其中的文件的名称,通常使用文件扩展.json来指出文件存储的数据为JSON格式。 filename = "numbers.json" # 接下...
false
a299d477015b60d595abc9e01fb9869d5e74bdbc
natkhosh/Algorithms__Data_structures
/Tasks/c1_fact.py
637
4.375
4
def factorial_recursive(n: int) -> int: """ Calculate factorial of number n (> 0) in recursive way :param n: int > 0 :return: factorial of n """ if n < 0: raise ValueError elif n == 0: return 1 else: p = 1 for i in range(1, n+1): p *= i return factorial_recursive(n-1) * n def factorial_iterativ...
false
889f3f7964600018ae0d002057c3903fe09e1932
lesshuman/misc_tasks
/yandex/2A.py
650
4.1875
4
''' Дан список. Определите, является ли он монотонно возрастающим(то есть верно ли, что каждый элемент этого списка больше предыдущего). Выведите YES, если массив монотонно возрастает и NO в противном случае. Test cases: [in]: 1 7 9 [out]: YES [in]: 1 9 7 [out]: NO [in]: 2 2 2 [out]: NO ''' def is_increasing(s): i...
false
bb9d7c309c187c7106e758685a02ffb1a9279c24
sourav9064/coding-practice
/coding_10.py
746
4.1875
4
##Write a code to check whether no is prime or not. ##Condition use function check() to find whether entered no is ##positive or negative ,if negative then enter the no, ##And if yes pas no as a parameter to prime() ##and check whether no is prime or not? num = int(input()) def check(n): if n >= 0: ...
true
9be112de553bec1a1af362c51ecd2877e622c214
sourav9064/coding-practice
/coding_22.py
1,385
4.21875
4
##A doctor has a clinic where he serves his patients. The doctor’s consultation fees are different for different groups of patients depending on their age. If the patient’s age is below 17, fees is 200 INR. If the patient’s age is between 17 and 40, fees is 400 INR. If patient’s age is above 40, fees is 300 INR. Write ...
true
f2e698e05e449961409b844e9bc4b667a2042cab
sourav9064/coding-practice
/coding_8.py
1,058
4.15625
4
##The program will recieve 3 English words inputs from STDIN ## ##These three words will be read one at a time, in three separate line ##The first word should be changed like all vowels should be replaced by * ##The second word should be changed like all consonants should be replaced by @ ##The third word should b...
true
b3c6b4f25e2fe162308638e5fbfb628779658a5a
bitwoman/python-basico-avancado-geek-university
/Estruturas Lógicas e Condicionais/#02.py
415
4.1875
4
#2. Leia um número fornecido pelo usuário. Se esse número for positivo, calcule a raiz quadrada do número. #Se o número for negativo, mostre uma mensagem dizendo que o número é inválido. from math import sqrt numero = int(input('Digite um número inteiro qualquer: ')) if numero > 0: sqrt = sqrt(numero) print...
false
f39aa64260dbce9cbe7d34c12129b2427f91a2f8
Krista-Pipho/BCH-571
/Lab_5/Lab_5.2.py
811
4.4375
4
# Declares an initial list with 5 values List1 = [1,2,3,4,5] # Unpacks this list into 5 separate variables a,b,c,d,e = List1 # Prints both the list and one of the unpacking variables print(List1) print(a) # Changes the value of a to 6 a = 6 # Prints both the list and a, and we can see that changing a d...
true
d9fbf08a599b0a04491081eece5292114ba12039
hamburgcodingschool/L2CX-November
/lesson 6/dashes.py
413
4.21875
4
# ask the user for a word # seperate the letters with dashes: # ex: banana becomes b-a-n-a-n-a def dashifyWord(word): dashedWord = "" firstTime = True for letter in word: if firstTime: firstTime = False else: dashedWord += "-" dashedWord += letter retur...
true
6a79b8a8424d83855aa72aefdf873be19b1a9ecd
manishg2015/python_workpsace
/python-postrgress/main.py
1,625
4.25
4
from sqlitedatabase import add_entry,get_entries,create_connection,create_table menu = """ Welcome to the programming diary! Please select one of the following options: 1) Add new entry for today. 2) View entries. 3) Exit. Your selection: """ welcome = "**Welcome to the programing diary!**" # entries = [ # {"c...
true
66703e13e0e831b7472ac1d5bb3df64e0af61a59
RobRoseKnows/umbc-cs-projects
/umbc/CMSC/2XX/201/Homeworks/hw8/hw8_part1.py
685
4.4375
4
# File: hw8_part1.py # Author: Robert Rose # Date: 11/24/15 # Section: 11 # E-mail: robrose2@umbc.edu # Description: # This program takes a list from user input and outputs it in reverse using # recursion. def main(): integers = [] number = int(input("Enter a number to append to the list, or -1 to st...
true
e97487959ffb477fed5bb5dde9019144a7f6536b
RobRoseKnows/umbc-cs-projects
/umbc/CMSC/2XX/201/Homeworks/hw2/hw2.py
2,425
4.34375
4
# File: hw2.py # Author: Robert Rose # Date: 9/12/15 # Section: 11 # Email: robrose2@umbc.edu # Description: # This file contains mathmatical expressions as # part of Homework 1. print("Robert Rose") print("Various math problem solutions as part of Homework 1.") # Question 1: # Expected output: 24 num1 = (7 ...
true
120b363afdecbbc5f67640a53cad242b5c97ad01
huangdaweiUCHICAGO/CAAP-CS
/Assignment 1/cash.py
890
4.1875
4
# Dawei Huang # 07/17/2018 # CAAP Computer Science Assignment 1 # Programs for Part 1 of the assignment is contained in the file hello.py # Programs for Part 2 of the assignment is contained in the file cash.py # Part 2 print("Part 2: Change Program\n") print("This program will prompt user for the amount of change an...
true
daabf510c6a6fd05ec5338da302af3c071c34015
bogdanlungu/learning-python
/rename_files.py
727
4.21875
4
""" Renames all the files from a given directory by removing the numbers from their names - example boston221.jpg will become boston.jpg """ import os from string import digits # define the function def rename_files(): # get the file names from a folder file_list = os.listdir(r"C:\Python\tmp\prank") ...
true
1e38094a5fa47b540c7a5350010c74bc389ab13c
bogdanlungu/learning-python
/combinations.py
752
4.46875
4
"""This programs computes how many combinations are possible to be made from a collection of 'n' unique integers grouped under 'g' elements. You need to specify the length of the collection and how many elements at a time you want to group from the collection. The number of possible combinations will be printed.""" # p...
true
f59a50d4c5a1d9fdf489097819905c086ee06df5
CoranC/Algorithms-Data-Structures
/Cracking The Coding Interview/Chapter Nine - Recursion and Dynamic Programming/9_2__xy_grid.py
734
4.25
4
""" Imagine a robot sitting on the upper left corner of an X by Y grid. The robot can only move in two directions: right and down. How many possible paths are there for the robot to go from (0,0) to (X,Y)? """ #Workings """ Grid [ [0, 0, 0], [0, 0, 0], [0, 0, 0] ] Answer [ [6, 3, 1], [3, 2, 1], [1, 1, 0]...
true
4ef0fe0dfebb3c739f8d52ea017b78b75a4076a0
shadman19922/Algorithm_Practice
/H_Index/h_index_sorted_array.py
783
4.21875
4
def compute_h_index(Input): #Input.sort() left = 0 right = len(Input) - 1 h_idx = -2 while left < right: middle = (int)(left + (right - left)/2) middle_element = Input[middle] remaining_elements = right - middle + 1 if middle_element <= remaining_elements: ...
true
ca66f03d8a33f2f47a3f21d1ca44aa4c410ac644
ebagos/python
/p023/main.py
1,699
4.125
4
""" 完全数とは, その数の真の約数の和がそれ自身と一致する数のことである. たとえば, 28の真の約数の和は, 1 + 2 + 4 + 7 + 14 = 28 であるので, 28は完全数である. 真の約数の和がその数よりも少ないものを不足数といい, 真の約数の和がその数よりも大きいものを過剰数と呼ぶ. 12は, 1 + 2 + 3 + 4 + 6 = 16 となるので, 最小の過剰数である. よって2つの過剰数の和で書ける最少の数は24である. 数学的な解析により, 28123より大きい任意の整数は2つの過剰数の和で書けることが知られている. 2つの過剰数の和で表せない最大の数がこの上限よりも小さいことは分かっているのだが,...
false
9ec4277cb9d0f88290a5f1c7abd4815d12677a90
mdisieno/Learning
/Python/FCC_PythonBeginner/14_ifStatements.py
278
4.15625
4
isMale = True isTall = False if isMale and isTall: #checks if either true print("You are a tall male") elif isMale and not(isTall): print("You are a male") elif not(isMale) and isTall: print(("You are not a male, but are tall")) else: print("You are a female")
true
62e29f3ea68b3f4e39bf6bb4194f07092c01978e
fabianocardosodev/exercicios-Python-cursoIntens
/removelista.py
203
4.125
4
#remove as instancias de valor especifico de uma lista #funçao "remove" pets = ['dog','cat','dog','goldfish','cat','rabbit','cat'] print(pets) while 'cat' in pets: pets.remove('cat') print(pets)
false
d8caba87defcaedadccb189e7a345ef3308b54b6
SaiSree-0517/19A91A0517_SAISREE_CSEA_PYTHON_LAB_EXPERIMENTS
/2.1experiment.py
476
4.25
4
""" 2.1Implement a python script to compute distance between two points taking inp from the user (Pythagorean Theorem) """ x1=int(input("enter x1 : ")) x2=int(input("enter x2 : ")) y1=int(input("enter y1 : ")) y2=int(input("enter y2 : ")) result= ((((x2 - x1 )**2) + ((y2-y1)**2) )**0.5) print("distance between",(x...
false
916e34cc0cce126412c21d0c4cb71fc640f2e73d
SaM-0777/OOP
/Strings.py
462
4.3125
4
##Strings in Python str1 = "Python is Easy" print(str1[:]) print(str1[::]) print(str1[:3]) ##Print first 3 characters print(str1[-2:3]) ##Slicing of String in Python s = "Computer Science" slice_1 = slice(-1, -6, -1) slice_2 = slice(1, 6, -1) slice_3 = slice(0, 5, 2) print(s[slice_1]) print(s[slice_2]) print(s[sli...
true
2624adf68591e885926d1a3fea74a5c4183b126d
SaM-0777/OOP
/Dictionary.py
1,781
4.59375
5
##Dict is an unordered set or collection of items or objects where unique keys are mapped yhe values ##These keys are used to access the corresponding paired value. While the keys are unique, values can be common and repeated ##The data type of a value is also mutable and can change whereas, the data type of keys mus...
true
f0d0f136058ba7b063ff00fe6e4e9165f106d0c2
Sjaiswal1911/PS1
/python/Lists/methods_1.py
1,030
4.25
4
# LIST METHODS # Append # list.append(obj) # Appends object obj to list list1 = ['C++', 'Java', 'Python'] print("List before appending is..", list1) list1.append('Swift') print ("updated list : ", list1) del list1 # Count # list.count(obj) # Returns count of how many times obj occurs in list aList = [123, 'xyz', 'za...
true
15449e1043649cf221e878405e1db4437bb74bfb
manish711/ml-python
/regression/multiple_linear_regression/multiple_linear_regression.py
1,688
4.125
4
# -*- coding: utf-8 -*- """ @author: manishnarang Multiple Linear Regression """ #Importing Libraries import numpy as np #contains mathematical tools. import matplotlib.pyplot as plt #to help plot nice charts. import pandas as pd #to import data sets and manage data sets. #Importing Data Set - difference bet...
true
7312689061a008c1b4c8dbc6a73b2849a4754776
YanisKachinskis/python_basic_200120
/lesson5/hw3.py
1,073
4.3125
4
# homework lesson: 5, task 3 """ Создать текстовый файл (не программно), построчно записать фамилии сотрудников и величину их окладов (не менее 10 строк). Определить, кто из сотрудников имеет оклад менее 20 тыс., вывести фамилии этих сотрудников. Выполнить подсчет средней величины дохода сотрудников. Пример файла: Иван...
false
cda4893eaa642ff053f86194f8494525bf7bc112
YanisKachinskis/python_basic_200120
/lesson4/hw2.py
624
4.15625
4
# homework lesson: 4, task 2 """ Представлен список чисел. Необходимо вывести элементы исходного списка, значения которых больше предыдущего элемента. Подсказка: элементы, удовлетворяющие условию, оформить в виде списка. Для формирования списка использовать генератор. """ my_list = [1, 7, 6, 13, 34, 23, 9, 11] new_my_...
false
9aae48aeae5c81ef96ed1e28e6764e67a89fc4fa
FordMcLeod/witAdmin
/python/rockpaperscissors.py
2,234
4.53125
5
# Rock Paper scissors demo for python introduction. SciCamps 2017 # Extentions: Add options for lives, an option to ask the player to play again. # 2 player mode. Add another option besides rock/paper/scissors. etc. import random import time computer = random.randint(0,2) # Le...
true
d81c8918a31ad2299039cdcc2517d1eeacb72599
RyuAsuka/python-utils
/color-code-change.py
2,192
4.125
4
import sys usage = """ Usage: python color-code-change.py <rgb|hex> <number> Arguments: rgb: Convert RGB color to hex number style. hex: Convert hex number color code to RGB color number. Examples: python color-code-change.py rgb 100 90 213 -> #645AD5 python color-code-change.py hex...
true
6fb000907798ff6426fd8fc933ecf2cc5656ab40
ravularajesh21/Python-Tasks
/Count number of alphabets,digits and special characters in STRING.py
532
4.28125
4
# Count number of alphabets,digits and special characters string=input('enter string:') alphabetcount=0 digitcount=0 specialcharactercount = 0 for x in string: if x>='A' and x<='Z' or x>='a' and x<='z': alphabetcount = alphabetcount + 1 elif x>='0' and x<='9': digitcount=digitcou...
true
c7cf39004c6961400afcb2983112060aba156f44
ravularajesh21/Python-Tasks
/Palindrome 1.py
553
4.5
4
# Approach 1 date = input('enter the date in dd/mm/yyyy format:') given_date = date.replace('/', '') reversed_date = given_date[::-1] if given_date == reversed_date: print(date,'is palindrome') else: print('It is not palindrome') # Approach 2 day = input('enter day:') month = input('e...
true
85e1e5c1adbc4daf79aaebaa31a2514e523dcef9
KotaCanchela/PythonCrashCourse
/6 Dictionaries/pizza.py
774
4.34375
4
# Store information about a pizza being ordered. pizza = { 'crust': 'thick', 'toppings': ['mushrooms', 'extra cheese'] } # Summarise the order print(f"You ordered a {pizza['crust']}-crust pizza with the following toppings: ") for topping in pizza['toppings']: print("\t" + topping) # favourite languages...
true
b3f906c56f714ca8d5e724b607dbe2e8d071b662
KotaCanchela/PythonCrashCourse
/6 Dictionaries/favourite_languages.py
1,860
4.5
4
# Break a large dictionary into several lines for readability # Add a comma after last key-value pair to be ready to add any future pairs favourite_languages = { 'jen': 'python', 'sarah': 'c', 'edward': 'ruby', 'phil': 'python', } sarah_language = favourite_languages['sarah'].title() print(f"Sarah's f...
true
9656f8e78d643569f078cf363ca57b4af32cb8ad
KotaCanchela/PythonCrashCourse
/9 Classes/9-8_Privileges.py
1,844
4.28125
4
# Write a separate Privileges class. The class should have one attribute, privileges, # that stores a list of strings as described in Exercise 9-7. Move the show_privileges() # method to this class. Make a Privileges instance as an attribute in the Admin class. # Create a new instance of Admin and use your method to ...
true
4d440d271bd189b22db644b888408fd001330c81
KotaCanchela/PythonCrashCourse
/4 working with lists/4-6 Odd Numbers.py
932
4.78125
5
# “4-6. Odd Numbers: Use the third argument of the range() function # to make a list of the odd numbers from 1 to 20. # Use a for loop to print each number. odd_number = [value for value in range(1, 21, 2)] print(odd_number) # 4-7. Threes: Make a list of the multiples of 3 from 3 to 30. # Use a for loop to print the n...
true
4262c4943e75c83ce8b337b8ec7a7802400760e5
KotaCanchela/PythonCrashCourse
/10 Files and Exceptions/favourite_number.py
784
4.46875
4
# Write a program that prompts for the user’s favorite number. Use json.dump() # to store this number in a file. Write a separate program that reads in this # value and prints the message, “I know your favorite number! It’s _____.” import json def ask_number(): """Asks the user for their favourite number and store...
true
332454e2039df29fa6c379252da70dcbd5c8a532
KotaCanchela/PythonCrashCourse
/7 User input and While statements/Counting.py
609
4.375
4
# Using continue in a loop # continue allows the user to return to the beginning of the loop rather than breaking out entirely # The continue statement tells Python to ignore the rest of the loop # Therefore, when current_number is divisible by 2 it loops back # otherwise when it is odd it goes to the next line (print...
true
cefb4142ffda596bf0e822678abdabac4209538b
OldLace/Python_the_Hard_Way
/may_19.py
1,844
4.1875
4
#May 19 - Paul Gelot #Python the Hard Way - Exercise 12 num1 = int(input("Please enter a number: ")) num2 = int(input("Please enter another number: ")) total_sum = num1 + num2 subtract = num1 - num2 product = num1 * num2 division1 = num1 / num2 print("The sum of the two numbers is:", total_sum) print("The difference...
true
180c892336d6a048da555972c923c8968874cafc
OldLace/Python_the_Hard_Way
/hw4.py
1,723
4.4375
4
# 1. Write a Python program to iterate over dictionaries using for loops character = {"name": "Walter", "surname": "White", "nickname": "Isenberg", "height": "6 foot 7", "hobby": "trafficking"} for i in character: print(i,":", character[i]) # 2. Write a function that takes a string as a parameter and returns a ...
true
51f72b65f476209ce78a087d0c401548be8dbb34
nivedipagar12/PracticePython
/E7_ListComprehensions.py
882
4.28125
4
''' ************* DISCLAIMER: THESE TASKS WERE POSTED ON https://www.practicepython.org *********************************** ************************* I AM ONLY PROVIDING SOLUTIONS *************************************************************** Project/Exercise 7 : List Comprehensions (https://www.practicepython....
true
76100afdfbeaabc631e5375da7ce9d06553957d3
nivedipagar12/PracticePython
/E24_DrawAGameBoard.py
2,666
4.4375
4
''' ************* DISCLAIMER: THESE TASKS WERE POSTED ON https://www.practicepython.org *********************************** ************************* I AM ONLY PROVIDING SOLUTIONS *************************************************************** Project/Exercise 24 : Draw a Game Board (https://www.practicepython.o...
true
17e09b72eba9b69ffed63b90d1ab3ceaec8b225a
nivedipagar12/PracticePython
/E1_CharacterInput.py
1,894
4.28125
4
''' ************* DISCLAIMER: THESE TASKS WERE POSTED ON https://www.practicepython.org************************************ ************************* I AM ONLY PROVIDING SOLUTIONS *************************************************************** Project/Exercise 1 : Character Input (https://www.practicepython.org/...
true
a81f36182dee04cd838b6ce101acd217d309ab66
poojajunnarkar11/CTCI
/CallBoxDevTest-3.py
567
4.53125
5
def is_power_two (my_num): if my_num == 0: return False while (my_num != 1): if my_num%2 != 0: return False my_num = my_num/2 return True print is_power_two(18) # Why this will work for any integer input it receives? # -Because the while loop works until the number is...
true