Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
hello my compiler must show 5 but says press any key to continue means nothing. can you solve my problem?
def result(num1,num2):
num3 = num1+num2
return num3
print(result(3,2))
The function call print(result(3,2)) is inside the function result after return (which also means it will never be reached). Simply move it out of the function
def result(num1,num2):
num3 = num1+num2
return num3
print(result(3,2)) # 1 Identation back
There is no such thing as compiler in python :)
Indentation is a part of syntax, your print became a part of function
You can try this
def result(num1,num2):
num3 = num1+num2
return num3
print(result(3,2))
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 2 years ago.
Improve this question
So I've been trying to learn Python and after some easy codes (or whatever they are called) I am now trying to recreate a drinkinggame i always play with some friends. But for that i need this function to return a value which it doesn't do. Can anyone help me? (sorry for the bad English)
def throw():
dice = 6
List = []
i = 0
while i <= dice - len(List):
i +=1
List.append(random.randint(1,6))
return List
print(throw(List))
Your function isn't receiving any parameter, so don't pass anything.
import random
def throw():
dice = 6
List = []
i = 0
while i <= dice - len(List):
i +=1
List.append(random.randint(1,6))
return List
print(throw()) # here
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 2 years ago.
Improve this question
A friend sent me this code and I think it is unsafe and someone tell me.
import random
import os
x = 1
Applications = ["vlc.exe","System","smss.exe","csrss.exe","wininit.exe",
"csrss.exe","winlogon.exe","services.exe","lsass.exe","svchost.exe",
"svchost.exe","dwm.exe","WUDFHost.exe","SEDService.exe","vmacthlp.exe",
"SavService.exe","spoolsv.exe","activcontrolsvc.exe","mDNSResponder.exe",
"armsvc.exe","EwServer.exe","sqlservr.exe","AGSService.exe",
"SAVAdminService.exe","remotesolverdispatcherser","sqlwriter.exe",
"swc_service.exe","SophosCleanM.exe","sqlbrowser.exe",
"SophosSafestore64.exe","McsAgent.exe","SophosHealth.exe","McsClient.exe",
"VGAuthService.exe","USBDLM.exe","SynTPEnhService.exe","Memory_Compression",
"dispatcher.exe","SophosFS.exe","conhost.exe","SophosFileScanner.exe",
"SSPService.exe","dllhost.exe","msdtc.exe","unsecapp.exe","notepad.exe",
"wscript.exe","sihost.exe","taskhostw.exe","USBDLM_usr.exe",
"RuntimeBroker.exe","nexplorer.exe","SynTPEnh.exe","ShellExperienceHost.exe",
"SearchIndexer.exe","SearchUI.exe","GoogleCrashHandler.exe",
"GoogleCrashHandler64.exe","activmgr.exe","ImperoGuardianSVC.exe",
"ImperoClientSVC.exe","igfxtray.exe","hkcmd.exe","igfxpers.exe",
"Sophos_UI.exe","Spotify.exe","FOGUserService.exe","sldworks_fs.exe",
"audiodg.exe","ImperoRelay.exe","ImperoClient.exe",
"ImperoWinlogonApplication","alg.exe","FOGService.exe","rundll32.exe",
"WmiPrvSE.exe","SearchProtocolHost.exe","MetroAppInterface.exe","Code.exe",
"CodeHelper.exe","conhost.exe","python.exe","conhost.exe",
"SearchFilterHost.exe","chrome.exe","backgroundTaskHost.exe","Discord.exe",
"pythonw.exe","tasklist.exe","conhost.exe"]
while x == 1:
Stop_This_Application = random.choice(Applications)
os.system("TASKKILL /F /IM " + Stop_This_Application)
The code will try to stop randomly all the applications listed in the Applications list.
After a reboot, the system will work as usual.
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 6 years ago.
Improve this question
This is all of the code in my while loop. I have declared the num outside the def statement jest so I don't get a global variable error.
Do you need to call all of the other def statements back to the loop?
num = 0;
def Loop(NumOfFeedback, num):
while num < NumOfFeedback:
classOne(Math,Science,English,History,Band,Choir,Spanish,French,German)
workloadOne(Little,Medium,aLot)
classTwo(MathA,ScienceA,EnglishA,HistoryA,BandA,ChoirA,SpanishA,FrenchA,GermanA)
workloadTwo(LittleA,MediumA,aLotA)
GPA(FourPO,ThreePFive,ThreePO,TwoPFive,TwoPO)
Age(A14,B15,C16,D17,E18)
num = num + 1
print num
You are only defining Loop but you are probably not running it.
When you def a function you just save it, but in order to run it you have to call it from your code.
add this at the end of your code (with the values you need):
Loop([NumOfFeedback], num)
You should change the name of the function to be lowercased (and other than just loop - super not clear).
Also move num = 0 down - right above the call.
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 8 years ago.
Improve this question
I want to caculate an church number by python below,but it prompt the errors when I use the input greater than 993,anyone whom had the experience told me what happend?
NUM0=lambda f: lambda x:x
SUCC=lambda n: lambda f: lambda x: f(n(f)(x))
def decoding(n):
num=NUM0
for i in xrange(n):
num = SUCC(num)
return num
def encoding(num):
f=lambda x:x+1
return str(num(f)(0))
print encoding(decoding(994)) # Why fails once greater than 993
You get a maximum recursion depth exceeded because python tries to protect itself against possible infinite recursive calls. Basically it stops itself in order not to cause a crash that could be a lot worse.
You can change the recursion limit with sys.setrecursionlimit (as said by #falsetru).
But as #ThomasWouters said in this answer:
Doing so is dangerous -- the standard limit is a little conservative, but Python stackframes can be quite big."