Hi! I'm a Digital Marketer Intern at hotels.ng and I have a moderate knowledge on programming.
First, your question is not very explanatory. The term "view" is often used in back-end web development. A view is simply a Python function that takes a Web request and returns a Web response.
But I'm not sure this is what you want, so I'll just go ahead and write a python function involving class to return the total number of credits taken by a student.
I'll answer this question using Python.
class student(object):
credits = None
year = None
def num_credits(self):
#get credit value
self.credits = input("Enter the total number of credits: " )
pass
def getYear(self):
self.year = input("Enter current year: ")
pass
def tot_credits(self):
TotalCredits = tempTotalCredits + self.num_credits
print "Your total credits are :"+" "+str(TotalCredits)
Answer:
- public class FindDuplicate{
-
- public static void main(String[] args) {
- Scanner input = new Scanner(System.in);
-
- int n = 5;
- int arr[] = new int[n];
-
- for(int i=0; i < arr.length; i++){
- int inputNum = input.nextInt();
- if(inputNum >=1 && inputNum <=n) {
- arr[i] = inputNum;
- }
- }
-
- for(int j =0; j < arr.length; j++){
- for(int k = 0; k < arr.length; k++){
- if(j == k){
- continue;
- }else{
- if(arr[j] == arr[k]){
- System.out.println("True");
- return;
- }
- }
- }
- }
- System.out.println("False");
- }
- }
Explanation:
Firstly, create a Scanner object to get user input (Line 4).
Next, create an array with n-size (Line 7) and then create a for-loop to get user repeatedly enter an integer and assign the input value to the array (Line 9 - 14).
Next, create a double layer for-loop to check the each element in the array against the other elements to see if there is any duplication detected and display "True" (Line 21 - 22). If duplication is found the program will display True and terminate the whole program using return (Line 23). The condition set in Line 18 is to ensure the comparison is not between the same element.
If all the elements in the array are unique the if block (Line 21 - 23) won't run and it will proceed to Line 28 to display message "False".
Answer:
I get 0x55 and this the linking address of the main function.
use this function to see changes:
/* bar6.c */
#include <stdio.h>
char main1;
void p2()
{
printf("0x%X\n", main1);
}
Output is probably 0x0
you can use your original bar6.c with updaated foo.c
char main;
int main() // error because main is already declared
{
p2();
//printf("Main address is 0x%x\n",main);
return 0;
}
Will give u an error
again
int main()
{
char ch = main;
p2(); //some value
printf("Main address is 0x%x\n",main); //some 8 digit number not what printed in p2()
printf("Char value is 0x%x\n",ch); //last two digit of previous line output
return 0;
}
So the pain in P2() gets the linking address of the main function and it is different from address of the function main.
Now char main (uninitialized) in another compilation unit fools the compiler by memory-mapping a function pointer on a char directly, without any conversion: that's undefined behavior. Try char main=12; you'll get a multiply defined symbol main...
Explanation:
The answer to the following question
<span>What kind of problems could you run into if you format a cell with the wrong format for the data type?
is:
there is a great possibility that your file format won't open because it has the wrong format</span>