BLOG-2-Question sets 4, 5, 6 and midterm exam summary blog

BLOG-2-Question Set 4, 5, 6 and Midterm Exam Summary Blog (1)Foreword: InptaNo.4.5.6The knowledge points included in the second major assignment and midterm exam mainly include: understanding the concept of classes, creating classes and instantiating objects. Define the method, parameter passing and return value of the method. Use conditional statements (if-else), loop statements (for, while), etc. to control menu storage and user input. An array or array-like array used to store menu options and handle the user’s selections. The difficulty of the questions varies depending on the question. The fourth menu question only requires basic menu display and user input processing. The subsequent 5.6Two questions require consideration of abnormal input processing and the use of more complex data structures to implement menu functions. The amount of questions is relatively moderate, No. 4TaoptaThe questions may be relatively simple. The two big questions are mainly about the design and method implementation of classes, and the other two questions are about traversal sorting. Comparing with dates examines some basic knowledge and library function knowledge. 5.6The complexity of the question has been greatly increased and the number of questions has been reduced. Its programming design There are more design and implementation details to consider. (2)…

hot3.png

Django’s first app, 5

2019 Unicorn Enterprises Recruit Python Engineer Standards with Large Money>>> 1, Automated testing polls/tests.py import datetimefrom django.utils import timezonefrom django.test import TestCasefrom .models import Questionclass QuestionModelTests(TestCase):def test_was_published_recently_with_future_question(self):”””was_published_recently() returns False for questions whose pub_dateis in the future.”””time = timezone.now() + datetime.timedelta(days&# 61;30)future_question = Question(pub_date=time)self.assertIs(future_question.was_published_recently(), False) In the terminal, we can run our test: $ python manage.py test polls Test views polls/tests.py from django.urls import reverse def create_question(question_text, days):”””Create a question with the given `question_text` and published thegiven number of `days& #96; offset to now (negative for questions published in the past, positive for questions that have yet to be published).”””time = timezone.now() + datetime.timedelta(days= days)return Question.objects.create(question_text=question_text, pub_date=time)class QuestionIndexViewTests(TestCase):def test_no_questions(self):”””If no questions exist, an appropriate message is displayed.””” response = self.client.get(reverse('polls:index'))self.assertEqual(response.status_code, 200)self.assertContains(response, “No polls are available.”)self .assertQuerysetEqual(response.context['latest_question_list'], [])def test_past_question(self):”””Questions with a pub_date in the past are displayed on the index page.”””create_question(question_text&#61 ;”Past question.”, days=-30)response = self.client.get(reverse('polls:index'))self.assertQuerysetEqual(response.context[&#39 ;latest_question_list'],['']) def test_future_question(self):”””Questions with a pub_date in the future aren’t displayed on the index page .”””create_question(question_text=”Future question.”, days=30)response = self.client.get(reverse('polls:index'))self.assertContains (response, “No polls are available.”)self.assertQuerysetEqual(response.context['latest_question_list'], [])def test_future_question_and_past_question(self):”””Even if both past and future questions exist, only past questions are displayed.”””create_question(question_text=”Past question.”, days=-30)create_question(question_text=”Future question.”, days=30)response = self.client.get(reverse('polls:index'))self.assertQuerysetEqual(response.context['latest_question_list'],[' '])def test_two_past_questions(self):”””The questions index page may display multiple questions.”””create_question(question_text=”Past question 1.”,…

Insert picture description here

Use Java simulation to implement disk array raid levels 0, 1, 3, 5, 6, 01, 10

Table of contents 1. Instructions for use 2. Overall design 3. Operation screenshots 4. Detailed design 4.1raid0 4.2raid1 4.3raid3 4.4raid5 4.5raid6 4.6raid01 4.7raid10 5. Source code 1. Instructions for use The development environment of this program is the Windows operating system Eclipse software – developed using Java language. When using, open the project file and run Main.java under the raidMain package. According to the prompts, enter the file to be written “full path of the file” and the file to be read. The entered file path indicates file reading. The saved path “contains the file name to be read” and the file can be restored. The disk “folder” used by each disk array level data is different. For example, the main disk path of raid0 is disk/raid0 and raid6 is disk/raid6. The other disk/read and disk/read are used to demonstrate the file path for writing and reading. Of course, you can also choose other files for operation. Data when the disk is damaged when raid3, 5, and 6 are not completed. Restoration: After writing, I still found that there were still big problems with the program structure. However, the changes took a lot of time and I just let it…

java11235_Use java to calculate the sum of the 120th digit of 1,1,2,3,5,8…

Use java to calculate the sum of the numbers 1, 1, 2, 3, 5, 8… 1-20th digits Attention: 254 Answer: 4 mip version Solution time 2021-01-27 00:01 The questioner is sorry and sorry 2021-01-26 16:29 Use java to calculate 1,1,2,3,5 ,8…The sum of the 1-20th digits Best answer Second-level knowledge expert Takaki Nono 2021-01-26 16:54 public class Test1 { public static void main(String args[]) { int a[] = new int[20]; a[0] = a[1] = 1; int sum = a[0] + a[1]; for (int i = 2; i <20; i++) { a[i] = a[i – 2] + a[i – 1]; sum += a[i]; } System.out.println(” The sum of the first 20 digits is :” + sum); } } The result is :17710 Answer all 1F Liuli Zhishi 2021-01-26 19:27 If you observe the rules of numbers, you will know that except for the first number And the second number is unexpected, the other numbers are equal to the first 2 numbers, and I wrote a function to see if you want to see it, but I didn’t pay much attention to the function name (I am a novice) //———– ——–Function class——————————— package com.yaojian.com; public class hanshu { public int feibulaji(int n){…

Insert picture description here

Use Java simulation to implement disk array raid levels 0, 1, 3, 5, 6, 01, 10

Table of contents 1. Instructions for use 2. Overall design 3. Operation screenshots 4. Detailed design 4.1raid0 4.2raid1 4.3raid3 4.4raid5 4.5raid6 4.6raid01 4.7raid10 5. Source code 1. Instructions for use The development environment of this program is the Windows operating system Eclipse software – developed using Java language. When using, open the project file and run Main.java under the raidMain package. According to the prompts, enter the file to be written “full path of the file” and the file to be read. The entered file path indicates file reading. The saved path “contains the file name to be read” and the file can be restored. The disk “folder” used by each disk array level data is different. For example, the main disk path of raid0 is disk/raid0 and raid6 is disk/raid6. The other disk/read and disk/read are used to demonstrate the file path for writing and reading. Of course, you can also choose other files for operation. Data when the disk is damaged when raid3, 5, and 6 are not completed. Restoration: After writing, I still found that there were still big problems with the program structure. However, the changes took a lot of time and I just let it…

java11235_Use java to calculate the sum of the 120th digit of 1,1,2,3,5,8…

Use java to calculate the sum of the numbers 1, 1, 2, 3, 5, 8… 1-20th digits Attention: 254 Answer: 4 mip version Solution time 2021-01-27 00:01 The questioner is sorry and sorry 2021-01-26 16:29 Use java to calculate 1,1,2,3,5 ,8…The sum of the 1-20th digits Best answer Second-level knowledge expert Takaki Nono 2021-01-26 16:54 public class Test1 { public static void main(String args[]) { int a[] = new int[20]; a[0] = a[1] = 1; int sum = a[0] + a[1]; for (int i = 2; i <20; i++) { a[i] = a[i – 2] + a[i – 1]; sum += a[i]; } System.out.println(” The sum of the first 20 digits is :” + sum); } } The result is :17710 Answer all 1F Liuli Zhishi 2021-01-26 19:27 If you observe the rules of numbers, you will know that except for the first number And the second number is unexpected, the other numbers are equal to the first 2 numbers, and I wrote a function to see if you want to see it, but I didn’t pay much attention to the function name (I am a novice) //———– ——–Function class——————————— package com.yaojian.com; public class hanshu { public int feibulaji(int n){…

Use java to make the sum of the first two numbers equal to the next number 1,1,,2,3,5,8,13,…print the first 40 numbers

Use java to make the sum of the first two numbers equal to the next number 1,1,,2,3,5,8,13,… print the first 40 numbers I hope it can help you! @@@ public class Fibonacci { public static void main(final String[] args) { Fibonacci fibonacci = new Fibonacci(); for (int i = 1; i <= 40; i++) { int fibonacciNumber = fibonacci.getFi bonacciNumber(i); System .out.println(String.format("The %d fibonacci number is: %d", i, fibonacciNumber)); } } private int getFibonacciNumber(final int index) { if (index == 1 || index == 2 ) {Return 1;} int Previousnumber = 1; Int CurrentNumber = 1; int Temp = 0; for (int i = 2; I <in <index; I ++) {TEMP = Previousnumber+CurrentNumber Er; Previousnumber = Currentnumber; Currenumber = TEMP;} return temp; }} @@1@@ public class Fbi{public static void main(String[] args){for(int i=1;i<=10;i++){System.out.print(getFbi(i)+" ");}}private static int getFbi(int n){if(n==1){return 1;}else if(n==2){return 2;}else{return getFbi(n-2)+getFbi(n-1);}} } @@2@@ tatic void Fibonacci(int n){int [] numbers = new int[n];numbers[0] = 0;numbers[1] = 1;for(int i = 2; i<n; i++){numbers[i ] = numbers[i-1] + numbers[i-2];}for(int number : numbers)System.out.print(number+" ");} java please print from 1 to 100, as follows: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21…

Write java to merge two arrays, {1,2,3,4,5}{4,5,6,7,8}

Java writes two arrays to merge, {1,2,3,4,5} {4,5,6,7,8} It is divided into two steps: 1. Connect the two arrays.2. Clear duplicate elements.import java.util.Arrays; public class Combine{ public static void main(String[] args){ int a[]={1,2,3,4,5}; int b[]={ 4,5,6,7,8}; int temp[]=new int[a.length+b.length]; //Connect two arrays for(int i=0;ijava writes to merge two arrays, {1 ,2,3,4,5} {4,5,6,7,8} &lt How to combine java string arrays into one array in java? h3> java

Write picture description here

java (nine-nine multiplication table output 1,3,5,7,9)

1*1=1 1*3=3 2*3=6 3*3=9 1*5=5 2*5=10 3*5=15 4*5=20 5*5=25 1*7=7 2*7=14 3*7=21 4*7=28 5*7=35 6*7=42 7*7=49 1*9=9 2*9=18 3*9=27 4*9=36 5*9=45 6*9=54 7*9=63 8*9=72 9*9=81 The code is as follows: package jiujiu; import java.io.File; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; public class Jiu { public void Dayin(String filedy){ for(int i=1;i<=9;i++){ for(int j=1;j<=i ;j++){ if(i%2==1){ int ji=j*i; String str1=j+”*”+i+”=”+ji+” “; writefile(str1,filedy); }else{ } } String str2=”\r\n”; writefile(str2,filedy); } } private void writefile(String data,String filedy) { // TODO Auto-generated method stub File file=new File(filedy); if(!file.exists()){ try { file.createNewFile(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } OutputStream os=null; try { os=new FileOutputStream(file,true); byte[]bytes=data.getBytes(); os.write(bytes); os.flush(); } catch (FileNotFoundException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); }finally { try { if(os!=null){ os.close(); } } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } public static void main(String[] args){ Jiu jiu=new Jiu(); jiu.Dayin(“f:/test/444.txt”); } } Execution result:

java11235_Use java to calculate the sum of the 120th digit of 1,1,2,3,5,8…

Use java to calculate the sum of the numbers 1, 1, 2, 3, 5, 8… 1-20th digits Attention: 254 Answer: 4 mip version Solution time 2021-01-27 00:01 The questioner is sorry and sorry 2021-01-26 16:29 Use java to calculate 1,1,2,3,5 ,8…The sum of the 1-20th digits Best answer Second-level knowledge expert Takaki Nono 2021-01-26 16:54 public class Test1 { public static void main(String args[]) { int a[] = new int[20]; a[0] = a[1] = 1; int sum = a[0] + a[1]; for (int i = 2; i <20; i++) { a[i] = a[i – 2] + a[i – 1]; sum += a[i]; } System.out.println(” The sum of the first 20 digits is :” + sum); } } The result is :17710 Answer all 1F Liuli Zhishi 2021-01-26 19:27 If you observe the rules of numbers, you will know that except for the first number And the second number is unexpected, the other numbers are equal to the first 2 numbers, and I wrote a function to see if you want to see it, but I didn’t pay much attention to the function name (I am a novice) //———– ——–Function class——————————— package com.yaojian.com; public class hanshu { public int feibulaji(int n){…

Contact Us

Contact us

181-3619-1160

Online consultation: QQ交谈

E-mail: [email protected]

Working hours: Monday to Friday, 9:00-17:30, holidays off

Follow wechat
Scan wechat and follow us

Scan wechat and follow us

Follow Weibo
Back to top
首页
微信
电话
搜索