blob_id
string
repo_name
string
path
string
length_bytes
int64
score
float64
int_score
int64
text
string
is_english
bool
a9cfa9463756a988acde76df57da14596c800169
DebbyMurphy/project2_python-exercises
/wk4-exercises_lists/python-lists_q3-append.py
487
4.5625
5
# Q3) Ask the user for three names, append them to a list, then print the list. # Input # Izzy # Archie # Boston # Output # ["Izzy", "archie", "Boston"] nameslist = [] firstname = input("Hi, what's your first name?! ") middlename = input(f"Cool, hey {firstname} what about your middle name? ") lastname = input(f"Th...
true
83e386a5c63cbd9696b0fa7ce04ca9ac248b6555
prabhakarchandra/python-samples
/Question4.py
694
4.28125
4
# -*- coding: utf-8 -*- """ Created on Mon Mar 25 11:08:55 2019 @author: v072306 """ # Write a program which accepts a sequence of comma-separated numbers from console and generate a list and a tuple which contains every number. # Suppose the following input is supplied to the program: # 34,67,55,33,12,98 #...
true
aadcbc2aca1d9f10503bcac93c3e4468b0f39d7c
Daletxt/xiaojiayu
/40classBIF.issubclass.isinstance.hasattr.setattr.getattr.delattr.property.py
2,804
4.3125
4
print('hello,world') #类和对象一些相关的BIF #issubclass(class,classinfo)检查class是否是classinfo的子类,非严格性, #1.一个类被认为是其自身的子类 #2.classinfo可以是类对象组成的元组,只要class是其中任何一个候选类的子类,则返回True class A: pass class B(A): pass print("B是A的子类吗",issubclass(B,A)) print("B是B的子类吗",issubclass(B,B)) print("A是B的子类吗",issubclass(A,B)) print("A是元组(A,B)的子类吗",is...
false
43ebbeacae18cb60f4de3c986033597e2d815dda
shiqing881215/Python
/object&database/inheritence.py
817
4.28125
4
class PartyAnimal : x = 0 name = "" # This is the constructor def __init__(self, name) : self.name = name print "I'm constructing", self.name # method, each python class at least has one variable called self def party(self): self.x = self.x+1 print self.name, " says ", self.x # This is the destructor ...
false
4fbb26d010002e088acd3a0297ac9b446961cb30
Manendar/branch-new-data
/trial.py
253
4.125
4
# this function counts vowels in a given string def vowels(s): count=0 vowel = "aeiouAEIOU" for i in s: if i in vowel: count +=1 return count if __name__ == '__main__': print(vowels("aeiou")) print(__name__)
false
1762ec6a2b9a905bd7569d47ef8ad75bfca0fce3
zhxiaozhi/untitled9
/day03/12-赋值运算符的特殊场景.py
700
4.1875
4
# 等号连接的变量可以传递赋值 a = b = c = d = 'hello' print(a, b, c, d) # x = 'yes' = y = z 错误,赋值运算时从右到左。y不能赋值‘yes’ m, n = 3, 5 # 拆包,(3,5)是一个元组 print(m, n) x = 'hello', 'good', 'yes' print(x) # ('hello', 'good', 'yes') # 拆包时,变量的个数和值的个数不一致,会报错 # y,z = 1, 2, 3, 4, 5 # print(y,z) # o, p, q = 4, 2 # print(o, p, q) # *表示可变长度...
false
f23e9b415175dffbbe1fb1cae40438cc6612d496
priyam009/Python-Codecademy
/Text Manipulation Examples/x_length_words.py
521
4.125
4
#Create a function called x_length_words that takes a string named sentence and an integer named x as parameters. This function should return True if every word in sentence has a length greater than or equal to x. def x_length_words(sentence, x): sentence = sentence.split() count = 0 for word in sentence: fo...
true
27b08fd75ad185244ddb9a44453d83326fe8d88a
priyam009/Python-Codecademy
/Loops Examples/exponents.py
347
4.375
4
#Create a function named exponents that takes two lists as parameters named bases and powers. Return a new list containing every number in bases raised to every number in powers. def exponents(base, powers): new_lst= [] for i in base: for j in powers: new_lst.append(i ** j) return new_lst print(expon...
true
9275738c76e060d910ef17a4644f8c21b89ce90f
priyam009/Python-Codecademy
/Loops Examples/max_num.py
276
4.1875
4
#Create a function named max_num that takes a list of numbers named nums as a parameter. The function should return the largest number in nums def max_num(nums): max = nums[0] for i in nums: if i >max: max = i return max print(max_num([50, -10, 0, 75, 20]))
true
81452be56123ee27e4fbd3a1aa371fe39652a9b4
Debashish-hub/Python
/MyCaptain1.py
561
4.40625
4
# Displaying fibonacci series upto n terms n = int(input("Enter the number of terms? ")) # Initialisation of 2 terms n1, n2 = 0, 1 count = 0 # Checking for validation and printing the fibonacci series if n <= 0: print("Please enter a positive integer!") elif n == 1: print("Fibonacci series upto ", ...
false
4f906ffbb833dbbfa4a806c8f458fde74e98e3f3
tyermercado/python-hacker-rank
/divisible_sum_pair.py
1,857
4.1875
4
#!/usr/bin/env python3 # -*- coding: utf-8 -*- """ Created on Thu Sep 12 22:32:30 2019 @author: bijayamanandhar """ #Github repo: #https://www.hackerrank.com/challenges/divisible-sum-pairs/problem?utm_campaign=challenge-recommendation&utm_medium=email&utm_source=24-hour-campaign """ You are given an array of integ...
true
a43edd3f97e3c2229fbf824591fc5a5e0a1894b8
KickItAndCode/Algorithms
/DynamicProgramming/UniquePaths.py
1,320
4.34375
4
# 62. Unique Paths # robot is located at the top-left corner of a m x n grid(marked 'Start' in the diagram below). # The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid(marked 'Finish' in the diagram below). # How many possible unique pat...
true
86fd55a2d7264324ad169204d4c28024698d59f8
KickItAndCode/Algorithms
/Graphs, BFS, DFS/2D Board BFS/SurroundedRegions.py
2,413
4.125
4
# 130. Surrounded Regions # Given a 2D board containing 'X' and 'O' (the letter O), capture all regions surrounded by 'X'. # A region is captured by flipping all 'O's into 'X's in that surrounded region. # Example: # X X X X # X O O X # X X O X # X O X X # After running your function, the board should be: # X X X X...
true
70ee7a473dfef293a283af568731e5f637a04d21
KickItAndCode/Algorithms
/Recursion/TowerOfHanoi.py
1,906
4.15625
4
# Program for Tower of Hanoi # Tower of Hanoi is a mathematical puzzle where we have three rods and n disks. The objective of the puzzle is to move the entire stack to another rod, obeying the following simple rules: # 1) Only one disk can be moved at a time. # 2) Each move consists of taking the upper disk from one of...
true
4233d6a91fe0b4d2a088cc13bf11a5cc1a0cccee
KickItAndCode/Algorithms
/ArraysListSets/GenerateParentheses.py
2,883
4.125
4
# 22. Generate Parentheses # Given n pairs of parentheses, write a function to generate all combinations of well-formed parentheses. # For example, given n = 3, a solution set is: # [ # "((()))", # "(()())", # "(())()", # "()(())", # "()()()" # ] # Approach 2 (Directed Backtracking) # The 3 Keys To Backt...
true
3b4f9ea9c6d1257928b6ee539904746f5e7fa6b5
marc-haddad/cs50-psets
/pset6/credit/credit.py
2,388
4.125
4
# Marc Omar Haddad # CS50 - pset6: 'Credit' # September 4, 2019 from cs50 import get_string # This program uses Luhn's algorithm to check the validity and type of credit cards def main(): num = get_string("Number: ") # Repeatedly prompts user for valid numeric input while (num.isdigit() != True): ...
true
eba970f91a25c886fa95fd5f25f7bc42f214e0a7
dconn20/Random
/Random.py
243
4.21875
4
# program that prints out a random number # between 1 and 10 import random x = int (input("Enter number here: ")) y = int (input("Enter number here: ")) number = random.randint (x,y) print ("Here is a random number {}" .format (number))
false
14f03f53b53fee9132afebbc12ed6b72d75315e6
aaronjrenfroe/Algorithms
/fibonacci_memoize.py
465
4.125
4
# Returns the nth number in the fibonacci sequence def fib_memo(n, memo): if n == 0: return 0 elif memo[n] != None: return memo[n] elif n == 1 or n == 2: memo[n] = 1 else: memo[n] = fib_memo(n-1, memo) + fib_memo(n-2, memo) return memo[n] # memo initialiseation cen be done differntly # but ...
true
c54d475ea800479f4cdf5b2a1f95e3e5efde9452
Frijke1978/LinuxAcademy
/Python 3 Scripting for System Administrators/The while Loop.py
2,207
4.6875
5
The while Loop The most basic type of loop that we have at our disposal is the while loop. This type of loop repeats itself based on a condition that we pass to it. Here’s the general structure of a while loop: while CONDITION: pass The CONDITION in this statement works the same way that it does for an if state...
true
fdd668609fcd5bf054e8888d5da465a1a971089a
Frijke1978/LinuxAcademy
/Python 3 Scripting for System Administrators/Working with Environment Variables.py
1,809
4.21875
4
Working with Environment Variables By importing the os package, we’re able to access a lot of miscellaneous operating system level attributes and functions, not the least of which is the environ object. This object behaves like a dictionary, so we can use the subscript operation to read from it. Let’s create a simple...
true
e7c1e57d0061f37a815fa05ea988deef32bf1bc0
jeen-jos/PythonPrograms
/Code/test.py
709
4.375
4
# Follwoing code shows how to print msg = "Hello world" print(msg) print(msg.capitalize()) print(msg.split()) # Taking inputs from user name = input("enter your name : ") print("Hello ",name) # eval() converts entered text into number to evaluate expressions num= eval(input("Enter the number : ")) print(" The value i...
true
a9c7bb5f18b5b109b924e0bd5eb0bc2386e6d0eb
rajiarazz/task-2
/day2/day2.py
343
4.3125
4
#1 ) Consider i = 2, Write a program to convert i to float. i=2 print(float(i)) #2 )Consider x="Hello" and y="World" , then write a program to concatinate the strings to a single string and print the result. x="Hello " y="World" print(x+y) #3 ) Consider pi = 3.14 . print the value of pie and its type. pi=3....
true
944469b3af2436ce62b11e22ee43f8bf2a6c0e87
akarnoski/data-structures
/python/data_structures/binheap.py
1,845
4.125
4
"""Build a binary min heap object.""" from math import floor class BinaryHeap(object): """Create a Binary Heap object as a Min Heap.""" def __init__(self): """Initialize the heap list to be used by Binary Heap.""" self._heap_list = [] def push(self, val): """Add new value to heap...
false
a32fc4f194acd34c21ef5a5bcfcb3bf9f5d34bc1
akarnoski/data-structures
/python/data_structures/trie_tree.py
2,265
4.1875
4
"""Create a trie tree.""" class Node(object): """Build a node object.""" def __init__(self, val=None): """Constructor for the Node object.""" self.val = val self.parent = None self.children = {} class TrieTree(object): """Create a trie tree object.""" def __init__(s...
true
0927de7b023d96a01db8047c1955aedfdcd2a9a1
hillarymonge/class-samples
/fancyremote.py
856
4.25
4
import turtle from Tkinter import * def circle(myTurtle): myTurtle.circle(50) # create the root Tkinter window and a Frame to go in it root = Tk() frame = Frame(root) # create our turtle shawn = turtle.Turtle() # make some simple but fwd = Button(frame, text='fwd', command=lambda: shawn.forward(50)) left = Button...
true
2868818bbaaef980a57267f34e8cec8bd6574018
ShresthaRujal/python_basics
/strings.py
340
4.28125
4
#name = "rujal shrestha"; #print(name); #print(name[0]); #indexing #print(name[3:]) # prints all string after 3rd character #print(name.upper()) #print(name.lower()) #print(name.split(s)) #default is white space #print formatting print("Hello {}, your balance is {}.".format("Adam", 230.2346)) x = "Item One : {}".for...
true
1f8975b5b315aa287404ef91c968a3039274215a
Denzaaaaal/python_crash_course
/Chapter_8/user_album.py
644
4.1875
4
def make_album(name, title, no_of_songs=None): if no_of_songs: album = { 'artist_name': name, 'album_title': title, 'number_of_songs': no_of_songs, } else: album = { 'artist_name': name, 'album_title': title, } retur...
true
bb1eef8f10a456d560abba511f81c169acacbd5f
Denzaaaaal/python_crash_course
/Chapter_6/cities.py
751
4.34375
4
cities = { 'london': { 'country': 'england', 'population': 8.98, 'fact': 'london is the smallest city in england' }, 'tokyo': { 'country': 'japan', 'population': 9.27, 'fact': 'tokyo for fromally known as "edo" in the 20th century', }, 'malmo': { ...
false
ccc9a226774cc6527f7ffd0212f06c066eda6949
anya92/learning-python
/1.Basics/numbers_and_operators.py
542
4.21875
4
# Numeric types in Python: # - int # - float # - complex 1 # int 3.2 # float print(type(-1)) # <class 'int'> print(type(0.5)) # <class 'float'> # operator | name | example # + | addition | 1 + 2 # 3 # - | subtraction | 15 - 4 # 11 # * | multiplication | 3 * 2 # 6 # ...
false
5523bdf0039a9d1b2c5a03e00aa8e3a48f6b73d3
udoyen/andela-homestead
/codecademy/advanced_topics/dictionary/sample.py
528
4.15625
4
movies = { "Monty Python and the Holy Grail": "Great", "Monty Python's Life of Brian": "Good", "Monty Python's Meaning of Life": "Okay" } for key in movies: print(key, movies[key]) print("===================================") for key, value in movies.items(): print([(key, value)], end=' ') # pri...
true
ecb27c7716d22c480ac6dc14aca69b6fd25c9d5a
Sombat/Python-Stack
/python_stack/python/OOP/users_with_bank_accounts.py
2,220
4.25
4
# Assignment: Users with Bank Accounts # Objectives: # Practice writing classes with associations class BankAccount: def __init__(self, int_rate=.01, balance=0): self.interest_rate = int_rate self.account_balance = balance def deposit(self, amount): self.account_balance += amount ...
false
0390536aadf4e563e3e8de60fc26b0ea5fec6cae
loumatheu/ExerciciosdePython
/Mundo 1/Exercicio27.py
758
4.1875
4
#Faça um programa que leia o nome completo de uma pessoa, mostrando em seguida o primeiro nome e o último nome separadamente. #ex: Ana Maria de Souza # primeiro = Ana # último = Souza cores = {'azul':'\033[1;34m','verde':'\033[1;32m','semestilo':'\033[m', 'vermelho':'\033[1;31m', 'lilas':'\033[1;35m', 'amarelo...
false
99edaf310f340ee8612570e49f4945e8c3092a80
loumatheu/ExerciciosdePython
/Mundo 1/Exercicio22.py
1,015
4.40625
4
#Challenge 22 - Crie um programa que leia o nome completo de uma pessoa e mostre: #•O nome com todas as letras maiúsculas; #•O nome com todas as letras minúsculas; #•Quantas letras ao todo (sem considerar espaços); #Quantas letras tem o primeiro nome; cores = {'azul':'\033[1;34m','verde':'\033[1;32m','semestilo':'\033[...
false
e7b028c64ca4fb48618d9a41eea2d80b30e62495
ThomasBriggs/python-examples
/Calculator/Calculator.py
287
4.28125
4
def calc(num, num2, operator): if operator == "+": print (num + num2) elif operator == "-": print (num - num2) elif operator == "*": print (num * num2) elif operator == "/": print (num / num2) else: print ("Invalid operator")
false
42db31f4a097ff0c8b38af894441bd4ffe75aa8f
jovyn/100-plus-Python-challenges
/100-exercises/ex16.py
442
4.25
4
''' Use a list comprehension to square each odd number in a list. The list is input by a sequence of comma-separated numbers. Suppose the following input is supplied to the program: 1,2,3,4,5,6,7,8,9 Then, the output should be: 1,9,25,49,81 ''' num_lst = input("Enter a sequence of nos. comma separated: ") num_lst = n...
true
52bdee1e48b1e04565e350c5227db664729b1cf7
prashantravishshahi/pdsnd_github
/User_Input.py
2,512
4.375
4
#definition of input month function. def get_month(): '''Asks the user for a month and returns the specified month. Args: none. Returns: (tuple) Lower limit, upper limit of month for the bikeshare data. ''' months=['january','february','march','april','may','june'] while True: ...
true
ce981daae2eeda0038941778658b09ced578538b
kelv-yap/sp_dsai_python
/ca3_prac1_tasks/section_2/sec2_task4_submission.py
780
4.3125
4
number_of_months = 6 title = "Calculate the average of your last " + str(number_of_months) + "-months electricity bill" print("*" * len(title)) print(title) print("*" * len(title)) print() bills = [] bill_number = 1 while bill_number <= number_of_months: try: input_bill = float(input("Enter Bill #{}: ".for...
true
e3ac44b37f2f78dac95229051386a20881b61009
Afraysse/practice_problems
/missing_num.py
1,173
4.125
4
""" SOLUTION 1: Simple Solution - O(N) keep track of what you've seen in a seperate list. """ def find_missing_num(nums, max_num): # find what number is missing from the list and return it # there's a way of solving in O(n), but can also solve in O(log N) # list may be in any order seen = [Fals...
true
355ee501441d3fea748bee9e288d2466fba17afb
alexweee/learn-homework-2_my
/my_date_and_time.py
1,490
4.15625
4
from datetime import datetime, date, timedelta import datedelta """ Домашнее задание №2 Дата и время * Напечатайте в консоль даты: вчера, сегодня, месяц назад * Превратите строку "01/01/17 12:10:03.234567" в объект datetime """ def split_myday(day): #day_split = str(day).split() #yesterday_final = day....
false
e1771a8446c03835dda14e0f77a779a5c8451ae2
LPisano721/color_picker
/colorpicker.py
1,767
4.21875
4
""" Program: colorpicker.py Author: Luigi Pisano 10/14/20 example from page 287-288 Simple python GUI based program that showcases the color chooser widget """ from breezypythongui import EasyFrame import tkinter.colorchooser class ColorPicker(EasyFrame): """Displays the result of picking a color.""" ...
true
2da51b497199b3dd5b65dcf8b63eb1443965f169
Harmonylm/Pandas-Challenge
/budget_v1.py
2,831
4.1875
4
# Budget: version 1 # Run with: python3 budget_v1.py import csv BUDGET_FILE="budget_data.csv" month_count = 0 # number of months read total_pl = 0 # total profit less all losses max_profit = 0 # largest profit increase seen max_profit_month = "" # month string with maximum profi...
true
57b57fc2c25a5fed061a5bbd7d046d234469e6c3
max-web-developer/python-homework-1
/home.py
1,411
4.125
4
# total = int(input("введите количество квартир!: ")) # floors = int(input("введите количество этажей: ")) # apartment = int(input("номер кв вашего друга? ")) # p = (total/floors) # if total % floors > 0 or apartment <= 0 or total < apartment: # print("кол-во квартир не делится на кол-во этажей!") # if total % flo...
false
b107cf5cf5f3ab6c4c18fc32fecdc83ab128d6e7
varshini-07/python
/series.py
820
4.1875
4
#sum of series def factorial(num): fact=1 for i in range(1,num+1): fact=fact*i return fact num=int(input("enter the number: ")) sum=0 for i in range(1,num+1): sum=sum+(i/factorial(i)) print("the sum of series: ",sum) #sum of odd n series def factorial(num): fact=1 for...
false
d137bb1a2509bd2ab60f39943673485b1e57489f
owili1/BOOTCAMP
/Hello world.py
210
4.125
4
print("Hello World\n"*10) #modifying hello world to prinT nmaes in reverse name1=(input("Enter name")) name2=(input("Enter name")) name3=(input("Enter name")) print("Hi "+name3+","+name2+","+name1+".")
false
db665202fccf5aef49ee276732e2050ffde1306f
thiamsantos/python-labs
/src/list_ends.py
416
4.1875
4
""" Write a program that takes a list of numbers (for example, a = [5, 10, 15, 20, 25]) and makes a new list of only the first and last elements of the given list. For practice, write this code inside a function. """ def get_list_start_end(initial_list): return [initial_list[0], initial_list[-1]] def main(): ...
true
9993766594dea8835043ca71a5e058d4dc8796bf
thiamsantos/python-labs
/src/odd_even.py
525
4.40625
4
"""Ask the user for a number. Depending on whether the number is even or odd, print out an appropriate message to the user. Hint: how does an even / odd number react differently when divided by 2? """ def is_odd(number): return number % 2 == 1 def main(): number = int(input("Type a number: ")) number_is_o...
true
521a0426f89e4f184ebd5d6800804c8636b46a5e
DSLYL/Python_One_Hundred
/python对象/study_2.py
801
4.21875
4
# 测试私有属性 # 在变量或方法前面加上__(俩个下划线)的时候,就成为私有方法或私有变量, # 要想在类外访问它们,必须使用对象名._类名__变量名或方法名 #访问私有类变量时,是 类名._类名__变量名 #私有的 在类内是可以随意调用的 class Student: __Teacher=1 #私有类变量 def __init__(self, name, age): self.name = name self.__age = age # 私有属性 def __work(self): print("加油!") print(self....
false
de4a0592197953efe82a51cbaac639f53a238525
ahbaid/kids-code-camp
/lesson-002/Answers/cel2far.py
203
4.25
4
print ("\nCelsius to Farenheit:") print ("========================") t = input("Enter temperature in degrees celsius: ") t = int(t) f = (t*9/5.0)+32 print ("Temperature in Farenheit is: ",f) print ()
false
4fe16b312f72b931743d74d10805aa3446951398
Accitri/PythonModule1
/(4) 06.12.2017/Class work/dataVisualisationWithTurtle.py
2,854
4.1875
4
import turtle myTurtle = turtle.Turtle #defining a function for the basic setup of the turtle def setupTurtle(): myTurtleInsideFunction = turtle.Turtle() myTurtleInsideFunction.penup() myTurtleInsideFunction.setpos(-300, 0) myTurtleInsideFunction.pendown() myTurtleInsideFunction.color('red') ...
true
a7e4955daf0d8d355bed55be5d43df8fffff872c
HarshaYadav1997/100daychallange
/day-5/matrixtranspose.py
481
4.1875
4
rows = int(input("Enter number of rows in the matrix: ")) columns = int(input("Enter number of columns in the matrix: ")) matrix = [] print("Enter the %s x %s matrix: "% (rows, columns)) for i in range(rows): matrix.append(list(map(int, input().rstrip().split()))) "tranpose of a matrix is" for i in matrix: ...
true
f3f5d8f50592f4d4cb642061f6e4bb57bbe74329
gbartomeo/mtec2002_assignments
/class11/labs/my_fractions.py
1,500
4.40625
4
""" fractions.py ===== Create a class called Fraction that represents a numerator and denominator. Implement the following methods: 1. __init__ with self, numerator and denominator as arguments that sets a numerator and denominator attribute 2. __str__ with self as the only argument... that prints out a fraction as nu...
true
5e4abdc4bb35aa3cad8a8b740f422f2e4f53b590
gbartomeo/mtec2002_assignments
/class5/greetings.py
580
4.40625
4
""" greetings.py ===== Write the following program: 1. Create a list of names and assign to a variable called names 2. Append another name to this list using append 3. Print out the length of this list 4. Loop through each item of this list and print out the name with a greeting, like "hello", appended before it For e...
true
2c6f5d75d5a749a332ffafb990764c00e7fd4cb2
wittywatz/Algorithms
/Algorithms Python/validMountain.py
597
4.375
4
def validMountainArray(arr): ''' Returns true if the array is a valid mountain ''' if (len(arr)<3): return False index = 0 arrlen = len(arr) while ((index+1)<=(arrlen-1) and arr[index]<arr[index+1]): index +=1 ...
true
5f6f2d8e3feb52ac48c05ad6b00d4fa52e035487
EmmanuelTovurawa/Python-Projects
/Class_Work/Chapter 4/chapter4_pg_116.py
1,033
4.46875
4
#4.10 pizzas = ['veggie', 'meat', 'cheese', 'BBQ', 'buffalo'] print(f"The first three items in the list are: ") for pizza in pizzas[:3]: print(pizza) print("") print("Three items from the middle of the list are") #get the middle position middle = int(len(pizzas)/2) for pizza in pizzas[middle-1:middle+2]: print(pizza)...
false
1ae005031a741bb896fdd8a9cf8aee17ed85ee91
EmmanuelTovurawa/Python-Projects
/Class_Work/Chapter 2/chapter2_pg_71.py
601
4.1875
4
# 2.3 name = "Emmanuel" print(f"Hello {name}, would you like to learn some Python today?") # 2.4 name_1 = "Emmanuel" print(name_1.lower()) print(name_1.upper()) print(name_1.title()) # 2.5 print('Dale Carnegie once said, "The successful man will profit from mistakes and try again in a different way"') # 2.6 famous_p...
false
018180c41b27bdd3582dedfa279c0e8f8532fa53
rbunch-dc/11-18immersivePython101
/python101.py
2,768
4.40625
4
# print "Hello, World"; # print("Hello, World"); # print """ # It was a dark and stormy night. # A murder happened. # """ # print 'Hello, World' # print 'Khanh "the man" Vu' print 'Binga O\'Neil\n' # # Variables # # - strings, letters, numbers, or any other stuff # # you can make with a keyboard # # a vari...
true
e50f64e8a117186ebf66b550df6e7a7802b7bdfd
rbunch-dc/11-18immersivePython101
/dictionaries.py
1,559
4.21875
4
# DICTIONARIES # Dictionaries are just like lists # Except... instead of numbered indicies, they # have English indicies greg = [ "Greg", "Male", "Tall", "Developer" ] # If I wanted to know Greg's job, I have to do greg[3] # No one is going to expect that # A dictionary is like a list of variables nam...
true
6f9d88d25edbbf0303d51140822f8f790e048c44
NaserWhite/STEP2017
/Review.py
504
4.15625
4
age = int(input("Enter your age => ")) # 30 < 3 = False if age < 3: print("Toddler") # 30 > 20 = True and 30 < 30 = False ----- True and False --- False elif age > 20 and age < 30: print("You're in your 20's") ...
false
c59556760fce2bdb2cc045b411aebf78e8214b3a
mesaye85/Calc-with-python-intro-
/calc.py
1,171
4.21875
4
def print_menu(): print("-"* 20) print(" python Calc") print("-"* 20) print("[1] add ") print("[2] subtract") print("[3] multiply") print('[4] Division') print("[5] My age") print('[x] Close') opc = '' while( opc!= 'x'): print_menu() opc = input('Please choose an option:'...
true
76191c55ec6b572b1c2cd21faf810b3f66052944
TamaraGBueno/Python-Exercise-TheHuxley
/Atividade Continua 2/Média.py
1,017
4.125
4
#descreva um programa que receba as notas e a presença de um aluno, calcule a média e imprima a situação final do aluno. #No semestre são feitas 3 provas, e faz-se a média ponderada com pesos 2, 2 e 3, respectivamente. #Os critérios para aprovação são: #1 - Frequência mínima de 75%. #2 - Média final mínina de 6.0 ...
false
b65280021b7397d9f85e81ea974600001c8908c1
posguy99/comp660-fall2020
/src/M4_future_value_calculator.py
1,229
4.34375
4
#!/usr/bin/env python3 def calculate_future_value(monthly_investment, yearly_interest_rate, years): monthly_interest_rate = yearly_interest_rate / 12 / 100 months = years * 12 future_value = 0 for i in range(0, months): future_value += monthly_investment monthly_interest_amount = futur...
true
1c8c6473e7fe467a4e21bb6707b54ea154764777
posguy99/comp660-fall2020
/src/Module 2 Assignment 3.py
672
4.34375
4
#!/usr/bin/env python3 kg_to_lb = 2.20462 earth_grav = 9.807 # m/s^2 moon_grav = 1.62 # m/s^2 mass = float(input("Please enter the mass in lb that you would like to convert to kg: ")) kg = mass / kg_to_lb print("The converted mass in kg is:", kg) print("Your weight on Earth is:", kg*earth_grav, "Newtons") print("...
true
190bbbc26dd2db956d03a7dbcf9b2edc27bd8599
posguy99/comp660-fall2020
/src/M6_Exercise.py
1,052
4.1875
4
# string traversal fruit = 'Apple' # print forwards index = 0 while index < len(fruit): letter = fruit[index] print(letter) index = index + 1 # exercise 1 - print in reverse index = len(fruit) while index: letter = fruit[index - 1] # because slice is zero-based print(letter) index = inde...
true
2d52aa2d9101714688f9bbd6498c17a10e7def6d
Pavan1511/python-program-files
/python programs/data wise notes/29 april/default dict ex3.py
797
4.1875
4
#Program: 3 returning a default value if key is not present in defaultdict # creating a defaultdict # control flow --> 1 from collections import defaultdict # control flow --> 5 def creating_defaultdict(): student = defaultdict(func) # ----> invoke func() ---> 8 print(type(student)) student['...
true
ab2d92b7e16305d3ce343c6926e3cce6508959e2
EricWWright/PythonClassStuff
/aThing.py
1,369
4.125
4
# print("this is a string") # name = "Eric" # print(type(name)) # fact = "my favorite game is GTA 5" # print("my name is " + name + " and I like " + fact) # # or # print("my name is ", name, " and i like ", fact) # # or # message = "my name is " + name + " and I like " + fact # print(message) # # vars # num = 8 # num2...
true
362394abdf87008e69007c7268050b4397e57a08
hkam0323/MIT-6.0001
/Problem set 4a - Permutations.py
1,980
4.5
4
def get_permutations(sequence): ''' Enumerate all permutations of a given string sequence (string): an arbitrary string to permute. Assume that it is a non-empty string. You MUST use recursion for this part. Non-recursive solutions will not be accepted. Returns: a list of all pe...
true
912b52732d9352aac2720272b97757106a549eff
Fongyitao/_001_python_base
/_008_字符串/_001_字符串常用方法.py
1,957
4.28125
4
name="abcdefg" print(name[0]) print(name[len(name) - 1]) print(name[-1]) str = "hello world itcast and itxxx" index = str.find("world") print(index) # 6 下标为6 index = str.find("dog") print(index) # -1 没有就返回 -1 index = str.rfind("itcast") print(index) # 12 index = str.index("w") print(index) # 6 count = str.co...
false
582e9d3021b08852ec9e56d72528155992ee6298
Fongyitao/_001_python_base
/_011_递归和匿名函数/_006_seek定位光标位置.py
542
4.34375
4
''' 定位到某个位置: 在读写文件的过程中,需要从另一个位置进行操作的话,可以使用seek() seek(offset,from)有两个参数 offset:偏移量 from:方向 0:表示文件开头 1:表示当前位置 2:表示文件末尾 ''' # demo:把位置设置为:从文件开头偏移5个字节 # 打开一个已经存在的文件 f=open("test.txt","r") str=f.read(10) print("读取的数据是:%s" %str) f.seek(1,0) # 查找当前位置 position=f.tell() print("当前的位置是:%s" %position) f.close()
false
4dd880f4f2423a147bbeb86ff4d7ad545d0b6513
baksoy/WebpageScraper
/WebpageScraper.py
1,155
4.15625
4
import urllib2 from bs4 import BeautifulSoup website = urllib2.urlopen('https://en.wikipedia.org/wiki/List_of_countries_by_population_(United_Nations)').read() # print website # html_doc = """ # <html><head><title>The Dormouse's story</title></head> # <body> # <p class="title"><b>The Dormouse's story</b></p> # # <p c...
true
3652fc5411c75588d37319f9776dbaee6e5044d4
Viktoriya-Pilipeyko/books
/dousonP2.py
1,504
4.3125
4
# Бесполезные факты # # Узнает у пользователя его / ее личные данные и выдает несколько фактов #о нем / ней. Эти факты истинны. но совершенно бесполезны. name = input( "Привет. Как тебя зовут? ") age = input("Сколько тебе лет? ") age = int(age) weight = int(input("Xopoшo. и последний вопрос. Сколько в тебе килограммов...
false
44ad837a03b617202d6417f71b911cd4ab5f9add
dpkenna/PracticePython
/Exercise 6.py
254
4.1875
4
# http://www.practicepython.org/exercise/2014/03/12/06-string-lists.html maypal = input('Enter a string: ') backwise = maypal[::-1] if maypal == backwise: print('{} is a palindrome'.format(maypal)) else: print('{} is not a palindrome'.format(maypal))
true
54cbd8559c9106cca85fe8b504e73b52700c9735
amisha-tamang/function
/factorial.py
254
4.1875
4
def factorial(inputValue): if inputValue==0: return inputValue elif inputValue==1: return inputValue else: return inputValue*factorial(inputValue-1) Number = 6 print("factorial of number") print(factorial(Number))
false
0c56bdd6fff73ded84befae2bf975f7910ce62dc
milton-dias/Fatec-Mecatronica-0791721011-Rogerio
/LTP2-2020-2/Pratica03/elife.py
320
4.125
4
numero_secreto = 32 numero_secreto2 = 42 numero_secreto3 = 23 palpite = int(input("Informe um Palpite: ")) if palpite == numero_secreto: print("Acertou") elif palpite > numero_secreto: print("Chute um numero menor") elif palpite < numero_secreto: print("Chute um numero maior") else: print("Caso padrão")
false
7147f9ddac28af4a1faeec6ff3eb5c01d8353e78
rmccorm4/BHSDemo.github.io
/rand.py
246
4.1875
4
#Game to guess a number between 1-10, or any range you choose import random number = str(random.randint(1, 10)) guess = input("Guess a number between 1 and 10: ") print(number) if guess == number: print("You won!") else: print("You lost!")
true
8ec77ebfb0083525c3ad4e39ffcc1430826d6d61
Jueee/PythonStandardLibrary
/lib03.02-threading.py
1,257
4.125
4
''' threading 模块 (可选) threading 模块为线程提供了一个高级接口 它源自 Java 的线程实现. 和低级的 thread 模块相同, 只有你在编译解释器时打开了线程支持才可以使用它. 你只需要继承 Thread 类, 定义好 run 方法, 就可以创建一个新的线程. 使用时首先创建该类的一个或多个实例, 然后调用 start 方法. 这样每个实例的 run 方法都会运行在它自己的线程里. ''' # 使用 threading 模块 import threading import time, random class Counter(object): """docstring for C...
false
d7f536b5654e29a431238f19f3b8efcc93c35440
AshaS1999/ASHA_S_rmca_s1_A
/ASHA_PYTHON/3-2-2021/q3sum of list.py
224
4.125
4
sum = 0 input_string = input("Enter a list element separated by space ") list = input_string.split() print("Calculating sum of element of input list") sum = 0 for num in list: sum += int (num) print("Sum = ",sum)
true
48dcf7ecbe7d8761756704c15b08f729520ffdb4
joshuastay/Basic-Login-Code
/login.py
2,942
4.3125
4
import re class LoginCredentials: """ Simple login authentication program includes a method to create a new user stores values in a dictionary """ def __init__(self): self.login_dict = dict() self.status = 1 # method to check if the password meets parameters...
true
122addb28d5f13854eca172d0be609d3369bea70
Combatd/Intro_to_Algorithms_CS215
/social_network_magic_trick/stepsfornaive.py
470
4.1875
4
# counting steps in naive as a function of a def naive(a, b): x = a y = b z = 0 while x > 0: z = z + y x = x - 1 return z ''' until x (based on value of a) gets to 0, it runs 2 things in loop. 2a we have to assign the values of 3 variables 3 ''' def time(a): # ...
true
b896a796ea172a50137208a7f0adefa10194bfd0
javierlopeza/IIC2233-2015-2
/Tareas/T02/clases/ListaLigada.py
2,804
4.15625
4
class ListaLigada: """ Clase que construye una estructura simulando una lista ligada. """ def __init__(self): """ Se inicializa sin elementos. """ self.e0 = None self.largo = 0 def append(self, valor): """ Agrega el valor en un nuevo atributo de la lista. ...
false
5c3ff785d5fe122e97fe146ba170d1021f8ddb4d
henriqueumeda/-Python-study
/Curso em Vídeo/Mundo 3 Estruturas Compostas/Desafios/desafio082.py
556
4.15625
4
number_list = [] even_list = [] odd_list = [] while True: number = int(input('Input a number: ')) number_list.append(number) if number % 2 == 0: even_list.append(number) else: odd_list.append(number) answer = '' while answer != 'Y' and answer != 'N': answer = input('Do yo...
false
4a38e180aabadcdb26f7ec2814ae2ae876f9e7a6
henriqueumeda/-Python-study
/MIT/600.1x - Introduction to Computer Science and Programming Using Python/Unit 3/Tuples and Lists/odd_tuples.py
319
4.21875
4
def oddTuples(aTup): ''' aTup: a tuple returns: tuple, every other element of aTup. ''' odd_tuple = () for number, element in enumerate(aTup): if number % 2 == 0: odd_tuple += (element, ) return odd_tuple aTup = ('I', 'am', 'a', 'test', 'tuple') print(oddTuples(aTup))
false
ce1a001e3dde4aa6bb413ad884cea077d526ecfc
StephTech1/Palindrome
/main.py
341
4.28125
4
#Add title to code print ("Is your word a Palindrome?") #Ask user for word input = str(input("What is your word?")) palin = input #create a function to check if a string is reversed #end to beginning counting down by 1 if palin == palin [::-1] : #print answers based on input print("Yes!") else: print("No!") print("...
true
ecacdeb6cd2c390e04e834191197100135c3d374
convex1/data-science-commons
/Python/filter_operations.py
2,074
4.1875
4
import pandas as pd import numpy as np """ create dummy dataframe about dragon ball z characters earth location and other information """ data = {"name": ["goku", "gohan"], "power": [200, 400], city": ["NY", "SEA"]} dragon_ball_on_earth = pd.DataFrame(data=data) """ ~~ABOUT~~ Use vectorization instead of using for ...
true
34f8bc7975b9905230efab2ff7f143d26fe0ecda
AlexandreInsua/ExerciciosPython
/exercicios_parte03/exercicio06.py
1,355
4.375
4
# 6) Utilizando la función range() y la conversión a listas genera las siguientes listas dinámicamente: # Todos los números del 0 al 10 [0, 1, 2, ..., 10] # Todos los números del -10 al 0 [-10, -9, -8, ..., 0] # Todos los números pares del 0 al 20 [0, 2, 4, ..., 20] # Todos los números impares entre -20 y 0 [-19, -17,...
false
aa5ae68154e8d3a480bf8aba0900c88f60ce0a01
AlexandreInsua/ExerciciosPython
/exercicios_repaso/exercicio29.py
2,248
4.1875
4
# Ejercicio 29 # Crea un programa en python que sirva para convertir monedas. # * Primero pedirá (mediante un menú) que se indique el tipo de divisa inicial que vas a usar (ej: dólar, euro, libra, …) # * Luego pedirá un valor numérico por pantalla (float), que será la cantidad de esa divisa. # * Por último se pedirá ...
false
3d292e18c4200a4f2809f1c9668da62a1c54f6c4
AlexandreInsua/ExerciciosPython
/exercicios_repaso/exercicio02.py
281
4.125
4
# Pide constantemente numeros ata que se introduce -1. Logo mostra a súa suma. print("Suma de números (-1 para finalizar)") num = 0 acumulator = 0 while num != -1: num = float(input("Introduza un número: ")) acumulator += num print("A suma dos número é: ", acumulator)
false
c892d4b1f235510f6695392342f8e6a8495fa1c5
AlexandreInsua/ExerciciosPython
/exercicios_parte01/exercicio05.py
856
4.28125
4
#5) La siguiente matriz (o lista con listas anidadas) debe cumplir una condición, # y es que en cada fila, el cuarto elemento siempre debe ser el resultado de sumar los tres primeros. # ¿Eres capaz de modificar las sumas incorrectas utilizando la técnica del slicing? #Ayuda: La función llamada sum(lista) devuelve una ...
false
92c9a9d6d247507651eb9be5d34d3508b6a144b5
AlexandreInsua/ExerciciosPython
/exercicios_repaso/exercicio23.py
262
4.375
4
# Realiza un programa en python que pida la anchura de un triángulo # y lo pinte en la pantalla (en modo consola) mediante asteriscos. anchura = int(input("inserte a anchura do lado: ")) aux = "*" for i in range(anchura): print(aux) aux = aux + "*"
false
d3c4297906e7eee347f7b49baa4274c37f6bba6f
AlexandreInsua/ExerciciosPython
/exercicios_repaso/exercicio30.py
1,367
4.34375
4
# Programa (en python) que calcule áreas de: cuadrados(en función de su lado), # rectángulos(en función de sus lados, circunferencias(en función de su radio) y triángulos # rectángulos(en función de su base y su altura). # Primero se pedirá el objeto que se va a calcular(cuadrado, rectángulo, circunferencia o triangul...
false
530de8ff2ed5d46e819d098591c2deb56e081623
Psuedomonas/Learn-Python-3
/Strings.py
508
4.15625
4
str1 = '''This is a multi-line string. This is the first line. This is the second line. "What's your name?," I asked. He said "Bond, James Bond." ''' str2 = 'What\'s your name?' str3 = "What's your name?" str4 = "This is the first sentence.\ This is the second sentence." str5 = '''Yubba dubba. \n The grass is greener ...
true
e8b37ca27deb3bc5997c06b9d840ddb5239edc63
reidpat/GeeringUp
/oop.py
809
4.125
4
# creates a class class Dog: # ALL dogs are good good = True # runs when each "Dog" (member of Class) is created def __init__ (self, name, age): self.name = name self.age = age self.fed = False # function exclusive to Dog def bark(self): print(self.name + " starts to bark!") # create a...
true
0b07faeed17c71745c16e7131ddcc19bca79dd7b
yeeshenhao/Web
/2011-T1 Python/yeesh_p02/yeesh_p02_q06.py
609
4.59375
5
## Filename: yeesh_p02_q06.py ## Name: Yee Shen Hao ## Description: Write a program that sorts three integers. The integers are entered from standard input and ##stored in variables num1, num2, and num3, respectively. The program sorts the numbers ##so that num1 > num2 > num3. The result is displayed as a sorted list i...
true
c3b4bb152fe1aac639fc8c0767a44fae9e119cb8
gusun0/data-structures
/dictionaries.py
352
4.1875
4
mydict = {"name": "max", "age": 28, "city": "New York"} print(mydict) for key, value in mydict.items(): print(key, value) ''' try: print(mydict["lname"]) except: print('error') ''' ''' mydict2 = dict(name="mary", age=27, city="boston") print(mydict2) value = mydict['name'] print(value) mydict["lastname...
false
a26f57626165a2dec8c1ab86e68d862d6e1639f3
UgeneGorelik/Python_Advanced
/ContexManagerStudy.py
1,623
4.40625
4
from sqlite3 import connect #with means in the below example: #open file and close file when done #means with keyword means start with something #and in the end end with something with open('tst.txt') as f: pass #we declare a class that will runn using context manager type implementation class temptable: ...
true
5e28de8f0613ba5ae0f50dc0c019c8716e6e4e09
mdimovich/PythonCode
/Old Tutorial Code/pythonTut27 (Recursion).py
602
4.1875
4
# Recursive Functions in Python # Recursive Factorial Function def factorial(num): if num <= 1: return 1 else: result = num * factorial(num-1) return result print(factorial(4)) # 1, 1, 2, 3, 5, 8, 13 # Fibonacci Sequence: Fn = Fn-1 + Fn-2 # Where F0 = 0 and F1 = 1 def fibonacci(num)...
true
e0a3095c64fd1e4fddb49f2dff25ef0b1b829e04
mdimovich/PythonCode
/Old Tutorial Code/pythonTut4.py
737
4.34375
4
#Enter Calculation: 5 * 6 # 5*6 = 30 #Store the user input of 2 numbers and the operator of choice num1, operator, num2 = input("Enter Calculation ").split() #Convert the strings into integers num1 = int(num1) num2 = int(num2) # if + then we need to provide output based on addition #Print result if operator == "+": ...
true
1730623fc10aa70a47b2e1cc3fe5aa42ac08ee59
mdimovich/PythonCode
/Old Tutorial Code/pythonTut3.py
328
4.25
4
#Problem: Receive Miles and Convert To Kilometers #km = miles * 1.60934 #Enter Miles, Output 5 Miles Equals 8.04 Kilometers miles = input ("Enter Miles: ") #Convert miles to integer miles = int(miles) #Kilometer Equation kilometers = miles * 1.60934 #Data Output print("{} Miles equals {} Kilometers".format(miles, kilo...
true
5956dee8f7bd60bfcddd0f74bd487ae132c70547
devSubho51347/Python-Ds-Algo-Problems
/Linked list/Segrate even and odd nodes in a linked list.py
1,884
4.125
4
## Creation of a node of linked list class Node: def __init__(self,data): self.data = data self.next = None # Method to create the linked list def create_linked_list(arr): head = None tail = None for ele in arr: newNode = Node(ele) if head is None: head =...
true
aeae7d9948ca357f80b8c955e078b3f8dd227677
devSubho51347/Python-Ds-Algo-Problems
/Linked list/AppendLastNToFirst.py
1,644
4.1875
4
# Description ''' You have been given a singly linked list of integer along with an integer 'N'. Write a function to append the last 'N' nodes towards the front of the singly linked list and returns the new head to the list. ''' # Solved question using two pointer approach def AppendLastToFirst(head,n): ptr1 = h...
true
c98a67c653cf3adfad0b2d1274a33f396fc6c8ac
mallikasinha/python-basic-programs
/stringFormatting.py
926
4.21875
4
age = 24 print("My age is" + str(age) + "years")#str convert integer to string print("My age is {0} year".format(age)) #replacement field print("there are {0} days in {1} ,{2} {3} {4}".format(31, "jan", "feb", "march", "may")) print("""Jan: {2} Feb: {0} March: {2} April: {1} June: {1} July: {2} August: {2...
false