Why is it giving me an error when i'm calling it from inside the 'student class?
*I have to Create a class called student
• In the student class creates 5 instance variables to store student details for example name, age, grade, average term score and has a disability or not.
• Create a method that is accessible from only inside the class that displays all of the instance variables values.
• Create a mutator method ‘set grade’ that will update the value of grade instance variable
• Create an accessor ‘get grade’ to return the value of the grade variable*
but I'm getting an error and I didn't know how to complete the code, but what I did is:
public class Student {
String name;
private int age;
private int grade;
private int average;
private String disability;
public void StuInfo(){
name = "John";
age = 15;
grade = 71;
average = 63;
disability = "No";
System.out.println("Name: "+name+",Age: "+age+",Grade: "+grade+",Average: "+average );
}
public static void main(String[] args){
StuInfo();
}
}
Please help.
2 answers
-
answered 2021-01-11 05:18
Satyendra Sharma
You are calling non static method from static method. Create object of StuInfo by -> new StuInfo();
-
answered 2021-01-11 05:38
Spyros K
In order to successfully compile your program you need to create first a new object of the class Student or make the stunInfo() method static. Also the java convention for method names is to start with a lowercase later, so StunInfo should better be named 'stunInfo'. A name like 'printStudentInfo()' can be considere, which would be even more readable and better shows what the method does. These notes can get your example working but it is not a complete solution to the homework posted. You need perhaps to change the access modifier of the stunInfo() method to be only accessible from within the class etc.
public class Student { String name; private int age; private int grade; private int average; private String disability; public void Student(){ name = "John"; age = 15; grade = 71; average = 63; disability = "No"; } // end constructor public void stunInfo(){ System.out.println("Name: "+name+",Age: "+age+",Grade: "+grade+",Average: "+average ); } //end stunInfo public static void main(String[] args){ //Create a new student Student student=new Student(); //Invoke stunInfo method student.stunInfo(); } //end main } //end class
See also questions close to this topic
-
What to test with JUnit
Premise I am about to try my hand for the first time in testing a university project in which I was thrown without the slightest experience, finding myself in front of a gigantic problem: How and what should I test
Mine is a simple app that communicates with a movie database and has an MVVM structure.
These are my packages: activities, adapters (for recycler views), fragments, models, repositories, request, response, utils, viewmodels
My question is should i test everything? For example do activities or fragments have to be tested with Espresso or also with JUnit?
-
How to make a regex for decimal that has a defined length (coma includes)
I am looking for a 15 characters length regex with a decimal. In the swift documentation, the regex would look like this : 3!a15d where 3!a means [a-zA-Z]{3} and 15d means a decimal of 15 characters length with a coma.
I tried the regex below :
([A-Z]{3}[0-9]{1,14}[,][0-9]{1})|([A-Z]{3}[0-9]{1,13}[,][0-9]{1,2})|([0-9]{1,12}[,][0-9]{1,3})|([0-9]{1,11}[,][0-9]{1,4})|([0-9]{1,10}[,][0-9]{1,5})|([0-9]{1,9}[,][0-9]{1,6})|([0-9]{1,8}[,][0-9]{1,7})|([0-9]{1,7}[,][0-9]{1,8})|([0-9]{1,6}[,][0-9]{1,9})|([0-9]{1,5}[,][0-9]{1,10})|([0-9]{1,4}[,][0-9]{1,11})|([0-9]{1,3}[,][0-9]{1,12})|([0-9]{1,2}[,][0-9]{1,13})|[0-9]{1}[,][0-9]{1,14}
But it didn't work. Do you have any tips to help me?
-
Server throwing broken pipe exception
Now I am working on client-server application, client side using exoplayer to request video file from server (struts based server), when the exoplayer first time requesting video source, struts throws IOException: Broken pipe, but it loads the video file successfully on the second try. On server side throws such exception every time the client restarts.
On the some posts, I saw some said that client closing connection, but here exoplayer requests the source and i don't know how to increase timeout for the its connection. Please help me to figure out the problem?
Error:
Jan 26, 2021 3:35:24 PM com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor error SEVERE: java.io.IOException: Broken pipe org.apache.catalina.connector.ClientAbortException: java.io.IOException: Broken pipe at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:351) at org.apache.catalina.connector.OutputBuffer.flushByteBuffer(OutputBuffer.java:776) at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:298) at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:251) at org.apache.catalina.connector.CoyoteOutputStream.close(CoyoteOutputStream.java:157) at org.apache.struts2.dispatcher.StreamResult.doExecute(StreamResult.java:305) at org.apache.struts2.dispatcher.StrutsResultSupport.execute(StrutsResultSupport.java:193) at com.opensymphony.xwork2.DefaultActionInvocation.executeResult(DefaultActionInvocation.java:372) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:276) at org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at org.apache.struts2.interceptor.debugging.DebuggingInterceptor.intercept(DebuggingInterceptor.java:256) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.DefaultWorkflowInterceptor.doIntercept(DefaultWorkflowInterceptor.java:168) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.validator.ValidationInterceptor.doIntercept(ValidationInterceptor.java:265) at org.apache.struts2.interceptor.validation.AnnotationValidationInterceptor.doIntercept(AnnotationValidationInterceptor.java:76) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:229) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.StaticParametersInterceptor.intercept(StaticParametersInterceptor.java:191) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at org.apache.struts2.interceptor.DateTextFieldInterceptor.intercept(DateTextFieldInterceptor.java:125) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at org.apache.struts2.interceptor.FileUploadInterceptor.intercept(FileUploadInterceptor.java:253) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor.intercept(ModelDrivenInterceptor.java:100) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.ScopedModelDrivenInterceptor.intercept(ScopedModelDrivenInterceptor.java:141) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.ChainingInterceptor.intercept(ChainingInterceptor.java:145) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171) at com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.I18nInterceptor.intercept(I18nInterceptor.java:140) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.AliasInterceptor.intercept(AliasInterceptor.java:193) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189) at com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:245) at org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54) at org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:575) at org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:81) at org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:193) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:166) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:202) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:96) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:526) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:139) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:92) at org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:678) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:74) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:343) at org.apache.coyote.http11.Http11Processor.service(Http11Processor.java:408) at org.apache.coyote.AbstractProcessorLight.process(AbstractProcessorLight.java:66) at org.apache.coyote.AbstractProtocol$ConnectionHandler.process(AbstractProtocol.java:860) at org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1587) at org.apache.tomcat.util.net.SocketProcessorBase.run(SocketProcessorBase.java:49) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:748) Caused by: java.io.IOException: Broken pipe at sun.nio.ch.FileDispatcherImpl.write0(Native Method) at sun.nio.ch.SocketDispatcher.write(SocketDispatcher.java:47) at sun.nio.ch.IOUtil.writeFromNativeBuffer(IOUtil.java:93) at sun.nio.ch.IOUtil.write(IOUtil.java:65) at sun.nio.ch.SocketChannelImpl.write(SocketChannelImpl.java:471) at org.apache.tomcat.util.net.NioChannel.write(NioChannel.java:140) at org.apache.tomcat.util.net.NioBlockingSelector.write(NioBlockingSelector.java:101) at org.apache.tomcat.util.net.NioSelectorPool.write(NioSelectorPool.java:152) at org.apache.tomcat.util.net.NioEndpoint$NioSocketWrapper.doWrite(NioEndpoint.java:1261) at org.apache.tomcat.util.net.SocketWrapperBase.doWrite(SocketWrapperBase.java:793) at org.apache.tomcat.util.net.SocketWrapperBase.writeBlocking(SocketWrapperBase.java:563) at org.apache.tomcat.util.net.SocketWrapperBase.write(SocketWrapperBase.java:501) at org.apache.coyote.http11.Http11OutputBuffer$SocketOutputBuffer.doWrite(Http11OutputBuffer.java:538) at org.apache.coyote.http11.filters.ChunkedOutputFilter.doWrite(ChunkedOutputFilter.java:112) at org.apache.coyote.http11.Http11OutputBuffer.doWrite(Http11OutputBuffer.java:190) at org.apache.coyote.Response.doWrite(Response.java:601) at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:339) ... 77 more
-
Apply tags to a text (angular)
I need to apply some tags (<b>, <i>,...) to some words in a string.
For now, I've done the following :
applyTaggings(text: string, posArray: any[], tag: any[]){ let first = ''; let sentence = ''; for(let i = 0; i < posArray.length; i++){ let beg = JSON.parse(posArray[i].tagging).begPos; let end = JSON.parse(posArray[i].tagging).endPos; if(i==0){ first = text.slice(0, beg) let next = tag[0] + text.slice(beg, end) + tag[1]; sentence = first.concat('', next) } else{ let lastEnd = JSON.parse(posArray[i - 1].tagging).endPos; let inBetween = text.slice(lastEnd, beg); sentence = sentence.concat('', inBetween); let next = tag[0] + text.slice(beg, end) + tag[1]; sentence = sentence.concat('', next); if(i == posArray.length - 1){ let last = text.slice(end); sentence = sentence.concat('', last); } } } return sentence; }
Where posArray parameter is an array like this one :
posArray= [{ "id": 2605, "tagging": "{\"id\":132,\"begPos\":4,\"endPos\":13}", "review_status": null }, { "id": 2606, "tagging": "{\"id\":135,\"begPos\":17,\"endPos\":22}", "review_status": null }, { "id": 2606, "tagging": "{\"id\":135,\"begPos\":60,\"endPos\":74}", "review_status": null } ]
And tag is just the specification of the tag, here bold :
tag = [`<b>`, `</b>`];
Then I call the function applyTaggings which matches to a variable and in the template I use [innerHTML]="variable" in the div I want the tagged text to appear.
It seems to work but I'm sure there are better and more efficient ways to do this.
How would you do it ? What are your thoughts on this ?
Thanks in advance!
-
Replace string prefix in list of strings based on unicode code (ascii value) from another list
I have two lists like:
a = ['119', '111', '111', '108', '105', '97', '111'] b = ['119esi', '111dl', '111lw', '108dvei', '105n', '97n', '111ka']
The
a
list is representation of letter in ascii format but string. How can I merge them in a way that I get "cohesive" sentence.In other words:
119
in ascii is a'w'
so merge them so that theb[0]
is"wesi"
now, instead of"119esi"
.My desired output list is:
['wesi', 'odl', 'olw', 'ldvei', 'in', 'an', 'oka']
-
R substract patterns in colnames
how can I generally substract shared pattern from a list of names,
Given:
a <- c('dogcathello', 'doghousehello', 'dogpen')
This would be the result
a <- c('cat', 'house', 'pen')
I believe I should use regex, but not sure how.
Any help?
-
How to debug protoc plugin using visual studio code
Does anyone know how to debug a customized protoc plugin(written in golang), for example protoc-gen-test?
Thanks.
-
MS Access 2010: Mouse movement restricted in debug mode
I'm facing a very frustrating issue: when the code is halted in debug mode and the source window pops up, the mouse cursor movement is restricted just to the client area of the main Access window (that is in background). I work with a large desktop, 2560x1440, so the Access window occupy just a partial area of it. When the VBA code come in foreground when a breakpoint is encountered, I can not move the mouse over it if it is not perfectly overlapped to the Access window in background!
This is really weird: does anyone had similar problem ? Any solution or workaround ?
Thanks Pietro
-
Debug dll and doesn't contain the architecture x86_64
I build a 64-bit dll in Clion. Tollchain Visual Studio
The project compiles successfully. For debugging I use Win64 host application compiled in Delphi. I added this application in the configuration editor and when I start debugging I get the message
'Project.exe' doesn't contain the architecture x86_64
Process finished with exit code 0The application itself without a debugger (or from under the Visual Studio debugger) starts and loads my dll.
Additional info
I have compiled an empty Delphi project
program Project1; {$APPTYPE CONSOLE} begin end.
When I run it from under the debugger as a host application, I get the same error.
When running an empty project built in Visual Studio as an host application
int main() { }
the debugger starts without errors
Platform: Win64
For comparison PE Headers Delphi and VC programs
Delphi
Visual Studio
-
How to add image quantity functions in printing in javascript?
This is an example of what I want to achieve first the user will select the image and then they will input number of image pieces they want to show on the print page, I already created the functions of adding the image and printing it but it is only one I want to create like this one that can print multiple images depends on what user input.
This is my code
var myApp = new function() { this.geltint = function() { var tab = document.getElementById('geltint'); var style = "<style>"; style = style + "table {width: 100%;font: 17px Calibri;}"; style = style + "table, th, td {border: solid 1px #DDD; border-collapse: collapse;"; style = style + "padding: 2px 3px;text-align: center;}"; style = style + "</style>"; var win = window.open('', '', 'height=700,width=700'); win.document.write(style); // add the style. win.document.write(tab.outerHTML); win.document.close(); win.print(); } } var myApp2 = new function() { this.powdery = function() { var tab = document.getElementById('powdery'); var style = "<style>"; style = style + "table {width: 100%;font: 17px Calibri;}"; style = style + "table, th, td {border: solid 1px #DDD; border-collapse: collapse;"; style = style + "padding: 2px 3px;text-align: center;}"; style = style + "</style>"; var win = window.open('', '', 'height=700,width=700'); win.document.write(style); // add the style. win.document.write(tab.outerHTML); win.document.close(); win.print(); } } var myApp3 = new function() { this.powdery5ml = function() { var tab = document.getElementById('powdery5ml'); var style = "<style>"; style = style + "table {width: 100%;font: 17px Calibri;}"; style = style + "table, th, td {border: solid 1px #DDD; border-collapse: collapse;"; style = style + "padding: 2px 3px;text-align: center;}"; style = style + "</style>"; var win = window.open('', '', 'height=700,width=700'); win.document.write(style); // add the style. win.document.write(tab.outerHTML); win.document.close(); win.print(); } } function readURL(input) { if (input.files && input.files[0]) { var reader = new FileReader(); reader.onload = function(e) { $('#geltint') .attr('src', e.target.result) .width(244.8) .height(187.2); }; reader.readAsDataURL(input.files[0]); } } function readURL2(input) { if (input.files && input.files[0]) { var reader2 = new FileReader(); reader2.onload = function(e) { $('#powdery') .attr('src', e.target.result) .width(172.8) .height(230.4); }; reader2.readAsDataURL(input.files[0]); } } function readURL3(input) { if (input.files && input.files[0]) { var reader2 = new FileReader(); reader2.onload = function(e) { $('#powdery5ml') .attr('src', e.target.result) .width(244.8) .height(105.6); }; reader2.readAsDataURL(input.files[0]); } }
<html> <head> <link class="jsbin" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1/themes/base/jquery-ui.css" rel="stylesheet" type="text/css" /> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script> <script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.0/jquery-ui.min.js"> </script> <meta charset=utf-8 /> <title>JS Bin</title> <!--[if IE]> <script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script> <![endif]--> <style> article, aside, figure, footer, header, group, menu, nav, section { display: block; } </style> </head> <body> <div id="1stimage"> <input type='file' onchange="readURL(this);" /> <img id="geltint" src="#" alt="your image" /> <p> <input type="button" value="Print Table" onclick="myApp.geltint()" /> </p> </div> <div id="2ndimage"> <input type='file' onchange="readURL2(this);" /> <img id="powdery" src="#" alt="your image" /> <p> <input type="button" value="Print Table" onclick="myApp2.powdery()" /> </p> </div> <div id="3rdimage"> <input type='file' onchange="readURL3(this);" /> <img id="powdery5ml" src="#" alt="your image" /> <p> <input type="button" value="Print Table" onclick="myApp3.powdery5ml()" /> </p> </div> </body> </html>
This is EXAMPLE what I want my output to look plain and simple any suggestions or ideas you can share with me guys thank you so much.
Users will choose an image and then input quantity on how many copies of an image they want then press print And It will show the print preview like this with total numbers of images what the user input.
-
How to make a printable file for a mobile application using python tkinter?
I am working on a personal project just to automate some manual work in the office.
Here I have to print a Receipt(Challan Form) with some data in it as an output. I am not sure which file format should I use to print the output. I am going to use this application on an android device so the choices seem very little. If I were using the desktop system then I had plenty of the choices like (.xlsx, .pdf, .docx) but I don't know how to accomplish this task for an android device.
Workflow:
- User will enter some data in the text boxes, e.g Fee, Date, Name.
- Then Press the Print Button and Output will be printed out with the text box data from the printer via Wi-fi connection.
My question is how to make this receipt/file in an android system using python(Tkinter). Please suggest some sort of article or link.
-
How to make footer div in tbody to be at the bottom of the last printed page?
I want to make the div with id "footer1" in tbody to be at the bottom of last printed page. I've referred to lot of posts but seems can't find the answer yet. Can help me how to make the "footer1" div to be at the bottom of last printed page? This is my sample code in jsfiddle.
[Sample code to print][1] https://jsfiddle.net/k9L48nsz/
-
How to convert object string to int?
i have a dataframe with object type on it, i need to make it type be an integer, so i can convert it to float. I already try to loop it and change with if else condition, but it makes another problem, what i must to do? thank's before.
for x in df_merge3["type"]: if x == 'course': df_merge3[["type"][x]] = 1 elif x == exercise: df_merge3[["type"][x]] = 2 elif x == challange: df_merge3[["type"][x]] = 3 elif x == achievement: df_merge3[["type"][x]] = 4 print(x)
-
Java: How to call an integer value from an external method
I just started learning java so I'm sure I'm just missing something basic. I have to create a dice object with 7 sides which generates a random number between 1 and 7:
import java.util.Random; public class Dice { Random rand = new Random(); int maxRoll = 7; public void roll(){ int dicVal = rand.nextInt(maxRoll)+1; } }
After that, I have to use another file to make 5 different dice from the original object, roll them, and detect weather or not they have rolled the same number.
public class DiceRollem { public static void main (String[] args) { int turn=0; while (turn < 10) { turn ++; Dice dice1; dice1 = new Dice(); dice1.roll(); Dice dice2; dice2 = new Dice(); dice2.roll(); Dice dice3; dice3 = new Dice(); dice3.roll(); Dice dice4; dice4 = new Dice(); dice4.roll(); Dice dice5; dice5 = new Dice(); dice5.roll(); } } }
I am unsure exactly how to call the dicVal value from each of the dice in order to compare them. I was able to code something in the original file that would return the value, but there isn't supposed to be a return in the original, instead it should all be in the second file. Again, I'm sure this is something easy but after looking I can't figure out how to do it.
-
Strange Python 3 mod behavior for longs
Consider this code snippet.
>>> n, m = 10011617, 100000000000006340 >>> s = lambda n: n * (n + 1) / 2 >>> s(n) 50116242483153.0 >>> s(n) == int(s(n)) True >>> m % s(n) 18096246116101.0 >>> m % int(s(n)) 18096246116105
As you can see,
s(n)
is an integer (mathematically), yetm % s(n) != m % int(s(n))
.Could this have to do with
s(n)
orm
being a long under the hood? Even if that's the case, why doess(n) == int(s(n))
yet when I take the modulus the results are not equal?P.S. I ran this in repl.it