All Activity

This stream auto-updates     

  1. Today
  2. Yesterday
  3. Last week
  4. I wanna start python without having any prior coding experience. Please advice me the best tutorial.

    Thanks in advance. 

  5. Earlier
  6. Can someone explain to me what validInput = False does? Not only that but also everything that is somehow linked to that. Furthermore, I really don't understand why you would define the runOperation function... Thanks in advance!
  7. Ii need help (calculator)

    Or use this: #include <iostream> #include <cstdlib> /* run this program using the console pauser or add your own getch, system("pause") or input loop */ using namespace std; float addition(float num1, float num2) { return num1 + num2; } float subtraction(float num1, float num2) { return num1 - num2; } float multiplication(float num1, float num2) { return num1 * num2; } float division(float num1, float num2) { return num1 / num2; } int main() { float num1; float num2; int choice; cout << "" << endl; cout << "What would you like to do? \n \n 1= Addition \n 2= Subtraction \n 3= Multiplication \n 4= Division \n" << endl; cout << "_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ \n" << endl; cout << "choice: "; cin >> choice; if(choice==1) { cout << "" << endl; //Addition cout << "ADDITION. \n \nEnter the numbers you would like to add. \n \n Number1: "; cin >> num1; cout << "\n"; cout << " Number2: "; cin >> num2; cout << "\n"; cout << " Answer = " << addition(num1, num2) << endl; } else if(choice==2) { cout << "" << endl; //Subtraction cout << "SUBTRACTION. \n \nEnter the numbers you would like to subtract. \n \n Number1: "; cin >> num1; cout << "\n"; cout << " Number2: "; cin >> num2; cout << "\n"; cout << " Answer = " << subtraction(num1, num2) << endl; } else { if(choice==3) { cout << "" << endl; //Multiplication cout << "MULTIPLICATION. \n \nEnter the numbers you would like to multiply. \n \n Number1: "; cin >> num1; cout << "\n"; cout << " Number2: "; cin >> num2; cout << "\n"; cout << " Answer = " << multiplication(num1, num2) << endl; } else { if(choice==4) { cout << "" << endl; //Divition cout << "DIVITION. \n \nEnter the numbers you would like to divide. \n \n Number1: "; cin >> num1; cout << "\n"; cout << " Number2: "; cin >> num2; cout << "\n"; cout << " Answer = " << division(num1, num2) << endl; } } } return 0; }
  8. def contryStartA(allA): a1 = "Afghanistan\n" a2 = "Albania\n" a3 = "Algeria\n" a4 = "Andorra\n" a5 = "Angola\n" a6 = "Antigua_Barbuda\n" a7 = "Argentina\n" a8 = "Armenia\n" a9 = "Australia\n" a10 = "Austria\n" a11="Azerbaijan\n" allA = a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 +a10 + a11 print(allA) def contryStartB(allB): b1 = "Belarus\n" b2 = "Belgium\n" b3 = "Belize\n" b4 = "Bolivia\n" b5 = "Brazil\n" b6 = "Bulgaria\n" allB = b1 + b2 + b3 + b4 + b5 + b6 print(allB) def contryStartC(allC): c1 = "Cambodia\n" c2 = "Cameroon\n" c3 = "Canada\n" c4 = "Central\n" c5 = "Chile\n" c6 = "China\n" c7 = "Colombia\n" c8 = "Comoros\n" c9 = "Costa\n " c10 = "Croatia\n" c11 = "Cuba\n" allC = c1 + c2 + c3 + c4 + c5 + c6 + c7 + c8 + c9 + c10 + c11 print(allC) def contryStartD(allD): d1 ='Denmark\n' d2 ='Dominica\n' d3 ='Dominican\n' allD = d1 + d2 + d3 print(allD) def contryStartE(allE): e1 = 'Ecuador\n' e2 = 'Egypt\n' e3 = 'El\n' e4 = 'Eritrea\n' e5 = 'Ethiopia\n' allE = e1 + e2 + e3 + e4 + e5 print(allE) def contryStartF(allF): f1 = 'Fiji\n' f2 = 'Finland\n' f3 = 'France\n' allF = f1 + f2 + f3 print(allF) def contryStartG(allG): g1 = 'Gabon\n' g2 = 'Gambia\n' g3 = 'Georgia\n' g4 = 'Germany\n' g5 = 'Ghana\n' g6 = 'Greece\n' g7 = 'Grenada\n' g8 = 'Guatemala\n' g9 = 'Guinea\n' g10 = 'Guinea - Bissau\n' g11 = 'Guyana\n' allG = g1 + g2 + g3 + g4 + g5 + g6 + g7 + g8 + g9 + g10 + g11 print(allG) def contryStartH(allH): h1 = 'Haiti\n' h2 = 'Honduras\n' h3 = 'Hungary\n' allH = h1 + h2 + h3 print(allH) def contryStartI(allI): i1 = 'Iceland' i2 = 'India\n' i3 = 'Indonesia\n' i4 = 'Iran\n' i5 = 'Iraq\n' i6 = 'Ireland\n' i7 = 'Israel\n' i8 = 'Italy\n' allI = i1 + i2 + i3 + i4 + i5 + i6 + i7 + i8 print(allI) def contryStartj(allJ): j1 = 'Jamaica' j2 = 'Japan\n' j3 = 'Jordan\n' allJ = j1+j2+j3 print(allJ) def contryStartK(allK): k1 = 'Kazakhstan' k2 = 'Kenya\n' k3 = 'Kiribati\n' k4 = 'Kosovo\n' k5 = 'Kuwait\n' k6 = 'Kyrgyzstan\n' allK = k1 + k2 + k3 + k4 + k5 + k6 print(allK) def contryStartl(allL): l1 = 'Laos' l2 = 'Latvia\n ' l3 = 'Lebanon\n' l4 = 'Lesotho\n' l5 = 'Liberia\n' l6 = 'Libya\n' l7 = 'Liechtenstein\n' l8 = 'Lithuania\n' l9 = 'Luxembourg\n' allL = l1+l2+l3+l4+l5+l6+l7+l8+l9 print(allL) def contryStartM(allM): m1 = 'Macedonia' m2 = '\nMadagascar' m3 = '\nMalawi' m4 = '\nMalaysia' m5 = '\nMaldives' m6 = '\nMali' m7 = '\nMalta' m8 = '\nMarshall' m9 = '\nIslands' m10 = '\nMauritania' m11 = '\nMauritius' m12 = '\nMexico' m13 = '\nMicronesia' m14 = '\nMoldova' m15 = '\nMonaco' m16 = '\nMongolia' m17 = '\nMontenegro' m18 = '\nMorocco' m19 = '\nMozambique' allM = m1+m2+m3+m4+m5+m6+m7+m8+m9+m10+m11+m12+m13+m14+m15+m16+m17+m18+m19 print(allM) def contryStartN(allN): n1 = 'Namibia' n2 = 'Nauru\n' n3 = 'Nepal\n' n4 = 'Netherlands\n' n5 = 'New\n' n6 = 'Zealand\n' n7 = 'Nicaragua\n' n8 = 'Niger\n' n9 = 'Nigeria\n' n10 = 'North\n' n11 = 'Korea\n' n12 = 'Norway\n' allN = n1+n2+n3+n4+n5+n6+n7+n8+n9+n10+n11+n12 print(allN) def contryStartO(allO): p1 = "Oman" allO = p1 print(allO) def contryStartP(allP): p1 = 'Pakistan' p2 = 'Palau\n' p3 = 'Palestine\n' p4 = 'Panama\n' p5 = 'Papua\n' p6 = 'New\n' p7 = 'Guinea\n' p8 = 'Paraguay\n' p9 = 'Peru\n' p10 = 'Philippines\n' p11 = 'Poland\n' p12 = 'Portugal\n' allP = p1+p2+p3+p4+p5+p6+p7+p8+p9+p10+p11+p12 print(allP) def contryStartQ(allQ): q1 = 'Qatar' allQ = q1 print(allQ) def contryStartR(allR): r1 = 'Romania' r2 = 'Russia\n' r3 = 'Rwanda\n' allR = r1 + r2 + r3 print(allR) def contryStartS(allS): s1 ="San" s2 = "Marino\n" s3 = "Sao\n" s4 = "Tome'and'Principe\n" s5 = "Saudi\n" s6 = "Arabia\n" s7 = "Senegal\n" s8 = "Serbia\n" s9 = "Seychelles\n" s10 = "Sierra\n" s11 = "Leone\n" s12 = "Singapore\n" s13 = 'Slovakia\n' s14 = 'Slovenia\n' s15 = 'Solomon\n' s16 = 'Islands\n' s17 = 'Somalia\n' s18 = 'SouthAfrica\n' s19 = 'South Korea\n' s20 = 'South Sudan\n' s21 = 'Spain\n' s22 = 'Sri\n' s23 = 'Lanka\n' s24 = 'Sudan\n' s25 = 'Suriname\n' s26 = 'Swaziland\n' s27 = 'Sweden\n' s28 = 'Switzerland\n' s29 = 'Syria\n' allS = s1+s2+s3+s4+s5+s6+s7+s8+s9+s10+s11+s12+s13+s14+s15+s16+s17+s18+s19+s20+s21+s22+s23+s24+s25+s26+s27+s28+s29 print(allS) def contryStartT(allT): t1 = 'Taiwan' t2 = 'Tajikistan\n' t3 = 'Tanzania\n' t4 = 'Thailand\n' t5 = 'Timor - Leste\n' t6 = 'Togo\n' t7 = 'Tonga\n' t8 = "Trinidad'and'Tobago\n" t9 = 'Tunisia\n' t10 = 'Turkey\n' t11 = 'Turkmenistan\n' t12 = 'Tuvalu\n' allT = t1 + t2 + t3 + t4 + t5 + t6 + t7 + t8 + t9 + t10 + t11 + t12 print(allT) def contryStartU(allU): u1 = 'Uganda' u2 = 'Ukraine' u3 = 'United' u4 = 'Arab Emirates\n' u5 = 'UnitedKingdom(UK)\n' u6 = 'United States of America(USA)\n' u7 = 'Uruguay\n' u8 = 'Uzbekistan\n' allU = u1+u2+u3+u4+u5+u6+u7+u8 print(allU) def contryStartV(allV): v1 = 'Vanuatu' v2 = '\nVatican City Holy See' v3 = '\nVenezuela' v4 = '\nVietnam' allV = v1 + v2 + v3 + v4 print(allV) def contryStartY(allY): y1 = 'Yemen' allY = y1 print(allY) def contryStartZ(allZ): z1 = 'Zambia' z2 = '\nZimbabwe\n' allZ = z1+z2 print(allZ) def main1(): contrYa = input(" press the namber 1 if your contry start with a(a1.,b2.,c3.,d4.,e5.,f6.,g7.,h8.,i9.,j10.,k11.,l12.," "m13.,n14.,o15.,p16.,q17.,r18.,s19.,t20.,u21.,v22.,y23.,z24.,") if (contrYa == '1'): print(contryStartA(allA=str)) elif(contrYa == '2'): print(contryStartB(allB=str)) elif (contrYa == '3'): print(contryStartC(allC=str)) elif (contrYa == '4'): print(contryStartD(allD=str)) elif(contrYa == '5'): print(contryStartE(allE=str)) elif(contrYa == '6'): print(contryStartF(allF=str)) elif (contrYa == '7'): print(contryStartG(allG=str)) elif (contrYa == '8'): print(contryStartH(allH=str)) elif (contrYa == '9'): print(contryStartI(allI=str)) elif (contrYa == '10'): print(contryStartj(allJ=str)) elif (contrYa == '11'): print(contryStartK(allK=str)) elif (contrYa == '12'): print(contryStartl(allL=str)) elif (contrYa == '13'): print(contryStartM(allM=str)) elif (contrYa == '14'): print(contryStartN(allN=str)) elif (contrYa == '15'): print(contryStartO(allO=str)) elif (contrYa == '16'): print(contryStartP(allP=str)) elif (contrYa == '17'): print(contryStartQ(allQ=str)) elif (contrYa == '18'): print(contryStartR(allR=str)) elif (contrYa == '19'): print(contryStartS(allS=str)) elif (contrYa == '20'): print(contryStartT(allT=str)) elif (contrYa == '21'): print(contryStartU(allU=str)) elif (contrYa == '22'): print(contryStartV(allV=str)) elif (contrYa == '23'): print(contryStartY(allY=str)) elif (contrYa == '24'): print(contryStartZ(allZ=str)) main1()
  9. Tuturial 5

    Hello, I am new to python and having trouble running the program in Tutorial 5. Here is the code I was using. The error code I am receiving is: NameError: Name Operation is not defined. Any help would be appreciated. Thanks, George helloworld5.py
  10. Not compiled code doesn't run

    So, I am just beginning to learn Python, and tried this, but this code didn't compile, can someone suggest or inform me, what's the problem! Please
  11. I'm already waiting for the next lesson good job dude :)
  12. def PrintInput(): # here i make the func name name = input("your name", ) # here i make ver i call it name afte it i make input func and with for the user print("שלום לך ידידי במחשבון שלי יש לי 4 אופציות כפל חילוק חיבור חיסור") # here i wont to print the input the user enter print("hello", name, "My calculator has only 4 options)(for now)") pass def add(num1, num2): return num1 + num2 def חיבור(מספר1, מספר2): return num1 + num2 def sub(num1,num2): return num1 - num2 def חיסור(מספר1,מספר2): return מספר1 - מספר2 def mul(num1, num2): return num1 * num2 def כפל(מספר1, מספר2): return מספר1 * מספר2 def div(num1, num2): return num1 / num2 def חילוק(מספר1, מספר2): return מספר1 / מספר2 def main2(): פעולה = input("מה אתה רוצה לעשות?(חיבור,חיסור,כפל,חילוק") מספר1 = int(input("מספר1")) מספר2 = int(input("מספר2")) if (פעולה == 'חיבור'): print(חיבור(מספר1, מספר2)) elif (פעולה == 'חיסור'): print(חיסור(מספר1, מספר2)) elif (פעולה == 'כפל'): print(כפל(מספר1, מספר2)) elif (פעולה == 'חילוק'): print(חילוק(מספר1, מספר2)) else: print("משהו לא עובד") def main(): operation = input("what you wont to do?(add,subtract,multiply, and dvide,") num1 = int(input("מספר1:")) num2 = int(input("מספר2:")) if (operation == 'add'): print(add(num1,num2)) elif (operation == 'subtract'): print(sub(num1,num2)) elif (operation == 'multiply'): print(mul(num1,num2)) elif (operation == 'dvide'): print(div(num1,num2)) else: print("somting rong") PrintInput() main() main2()
  13. Rock Paper Scissors Beginners practice

    This is what I came up with... It's a little dirty still, and I seem to have taken a slightly different approach than some others, but it seems to be working: #Import Time and Random import time import random print("Let's play 'Rock! Paper! Scissor!'") print("") def main(): PlayAgain = True while PlayAgain: # Declare variable for computers choice opponent = random.choice(['Rock', 'Paper', 'Scissor']) #Player chooses rock, paper, or scissors to compete against computer #Get user input validInput = False while not validInput: try: Player = int(input("Press 1 for 'Rock', 2 for 'Paper', or 3 for 'Scissor': ")) validInput = True except: print("Invalid input. Try Again") #Determine outcome of game if(Player == 1 and opponent == 'Rock'): print("You chose: Rock") print("Your opponent chose: " + opponent) print("You and your opponent both chose rock. Tie!") elif(Player == 1 and opponent == 'Paper'): print("You chose: Rock") print("Your opponent chose: " + opponent) print("Paper covers rock! You lose!") elif(Player == 1 and opponent == 'Scissor'): print("You chose: Rock") print("Your opponent chose: " + opponent) print("Rock breaks scissor! You win!") elif(Player == 2 and opponent == 'Rock'): print("You chose: Paper") print("Your opponent chose: " + opponent) print("Paper covers rock! You win!") elif(Player == 2 and opponent == 'Paper'): print("You chose: Paper") print("Your opponent chose: " + opponent) print("You and your opponent both chose paper. Tie!") elif(Player == 2 and opponent == 'Scissor'): print("You chose: Paper") print("Your opponent chose: " + opponent) print("Scissor cuts paper! You lose!") elif(Player == 3 and opponent == 'Rock'): print("You chose: Scissor") print("Your opponent chose: " + opponent) print("Rock breaks scissor! You lose!") elif(Player == 3 and opponent == 'Paper'): print("You chose: Scissor") print("Your opponent chose: " + opponent) print("Scissor cuts paper! You win!") elif(Player == 3 and opponent == 'Scissor'): print("You chose: Scissor") print("Your opponent chose: " + opponent) print("You and your opponent both chose scissor. Tie!") else: print("Invalid entry, please try again") #Play again Y/N again = input("Would you like to play again (Y/N): ") print("") if(again != 'Y' and again != 'y'): PlayAgain = True break else: continue print("Thanks for playing 'Rock, Paper, Scissor!'") main()
  14. class Input_PrintFUNC():#i make class pass def PrintInput():#here i make the func name name = input("your name",)#here i make ver i call it name afte it i make input func and with for the user #print(name)#here i wont to print the input the user enter print("hello",name,"wallcome","heve good day") #print("wallcome") # print("heve good day") PrintInput()#here i call the func from the class def add(num1,num2): num1 = input("num1",) num2 = input("num2",) return num2+num1 def main(): myresolt = add(1, 1) print(myresolt) main() def PrintInput():#here i make the func name name = input ("your name",)#here i make ver i call it name afte it i make input func and with for the user #print(name)#here i wont to print the input the user enter print("hello",name,"Welcome Have a great day") #print("wallcome") # print("heve good day") PrintInput()#here i call the func def minos(num1,num2): return num1 - num2 def hilok(num1,num2): return num1/num2 def plus(num1,num2): return num1 + num2 def kafel(num1,num2): return num1 * num2 def dubkafel(num1,num2): return num1 ** num2 def ExeFunc(): print(plus(4,2)) print(minos(4,2)) print(dev(4,2)) print(kafel(4,2)) print(dubkafel(4,2)) ExeFunc()
  15. How old

    How old were you when you started, and what was your background?
  16. How old were you when you started, and what was your background?
  17. How old were you when you started, and what was your background?
  18. How old were you when you started, and what was your background?
  19. Rock Paper Scissors Beginners practice

    vary cool :)
  20. Rock Paper Scissors Beginners practice

    Hi guys here's my version of the code it was a really fun challenge if anyone has some tips or improvements id really appreciate any advice. import random import time cpu = (random.randint(0, 2)) def computer(): # determine computer's move if (cpu == 0): print('Computer picked rock') elif (cpu == 1): print('Computer picked Paper') else: print('Computer picked scissors') def rps(): # print rock, paper, scissors print('rock') time.sleep(1) print('paper') time.sleep(1) print('scissors') time.sleep(1) def wl(human): # determine a win, loss or tie if (human == 'rock' and cpu == 0) or (human == 'paper' and cpu == 1) or (human == 'scissors' and cpu == 2): print('You tie.') elif (human == 'rock' and cpu == 1) or (human == 'paper' and cpu == 2) or (human == 'scissors' and cpu == 0): print('You lose.') elif (human == 'rock' and cpu == 2) or (human == 'paper' and cpu == 0) or (human == 'scissors' and cpu == 1): print('You Win.') else: print('INVALID input, try again') def game(): # run the game print('rock, paper, scissors.') human = input('Make your selection: ') time.sleep(1) print('You picked: ' + human) time.sleep(1) rps() time.sleep(0.5) computer() wl(human) def main(): # main program loop with exit cont = False while not cont: game() playAgain = input('Play again(y/n)? ') if (playAgain != 'y'): cont = True break else: continue main()
  21. If I'm running Linux (Kubuntu 18.04), are there alternatives to the above windows downloads? Nevermind :) I figured it out.
  22. Inhering classes

    .
  23. Rock Paper Scissors Game Problem

    There seem to be a problem, which i can't find... I have a problem, where program won;t tell corectly if i won/lost/ tied.. please help, because it's eating my mind haha
  24. The only thing I can see wrong with it is this line operation = raw_input('What do you want to do (+,-,*,/): ') which should be operation = input('What do you want to do (+,-,*,/): ') assuming all the other functions are present.
  25. Simple calculator

    The print statement on line 27 is missing a final closing bracket print(divide(var1,var2))
  26. Calculator

    if (operation == "+"): print(add(var1,var2)) elif(operation == '-'): print(sub(var1,var2)) elif (operation == "*"): print(mult(var1,var2)) elif (operation == "/"): print(div(var1 / var2)) I corrected 2 things you can see them here
  27. I added some small things in the end would like to have your opinnions import.py
  28. Calculator

    this is a simple calculator program but it is giving a syntax error at line 24 i am not able to figure it out what is the problem anybody can help me with this calculator.py
  29. Making dice game alpha

    Few programs start with all of their features, so the first version will only implement the basics. First a couple of definitions: A variable is a value that is subject to change, and they are used a lot in Python. Whenever you need your program to "remember" something, you use a variable. In fact, almost all the information that code works with is stored in variables. For example, in the math equation x + 5 = 20, the variable is x, because the letter x is a placeholder for a value. An integer is a number; it can be positive or negative. For example, 1 and -1 are both integers. So are 14, 21, and even 10,947. Variables in Python are easy to create and easy to work with. This initial version of the dice game uses two variables: player and ai. Type the following code into a new text file called dice_alpha.py: import random player = random.randint(1,6) ai = random.randint(1,6) if player > ai : print("You win") # notice indentation else: print("You lose") Launch your game to make sure it works. This basic version of your dice game works pretty well. It accomplishes the basic goals of the game, but it doesn't feel much like a game. The player never knows what they rolled or what the computer rolled, and the game ends even if the player would like to play again. This is common in the first version of software (called an alpha version). Now that you are confident that you can accomplish the main part (rolling a die), it's time to add to the program.
  1. Load more activity