answersLogoWhite

0


Best Answer

I suspect that you mean that you want to define constants, which is not possible in Python. Any variable can be rebound to something else at any time.

User Avatar

Wiki User

10y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you define Y as 1 and N as 0 in Python?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

How you can write python code to disply the prime factors of 60?

def factors(n): return [(x, sum([1 for y in range(1,int(ceil(log(n, x)))+1) if n%x**y == 0])) for x in range(2,int(n/2)) if all([x%q!=0 for q in range(2,int(x/2)+1)]) and n % x == 0] This will give you a list of factors with their exponents: print(factors(60)) # prints: [(2, 2), (3, 1), (5, 1)]


C program to print nos divisible by 8?

#include #include#define N 100 /* change the upper limit by changing value of N */int main(){int i;clrscr();printf("\nPROGRAM TO PRINT NUMBERS DIVISIBLE BY 8 between 1 and 100\n");for(i=1;i


How do you draw a cycle in a c program?

/*PROGRAM TO IMPLEMENT GAUSS-jordan method.#include#define MX 20main(){float a[MX] [MX+1],m,p;int i,j,k,n;puts("\n how many equations?:");scanf("%d",&n);for(i=0;i


What is the Algorithm for transpose of matrix in python?

Algorithm: transpose Input: a matrix M[x][y] Output: the transpose of M (a matrix of order y * x) allocate N[y][x] for r = 0 to x-1 // iterate over rows for c = 0 to y-1 // iterate over columns N[c][r] = M[r][c] next c next r return N


Write a c program that reverse a given integer number and check whether the number is palindrome or not?

#include <stdio.h> #include <string.h> #define N 100 #define PALINDROME 0 #define NONPALINDROME 1 /*Program that tells you whether what you enter is a palindrome or not*/ char pal[N]; //input line int i; //counter int k; //counter int tag; int flag = PALINDROME; /*flag=0 ->palindrome, flag =1 ->nonpalindrome*/ int main() { printf("Enter something: \n"); scanf("%s", pal); tag = strlen(pal); /*determine length of string*/ /* pointer running from the beginning and the end simultaneously looking for two characters that don't match */ /* initially assumed that string IS a palindrome */ /* the following for loop looks for inequality and flags the string as a non palindrome the moment two characters don't match */ for (i=0,k=tag-1; i=0; i++,k--) { if(pal[i] != pal[k]) { flag=NONPALINDROME; break; } } if(flag == PALINDROME) { printf("This is a palindrome\n"); } else { printf("This is NOT a palindrome\n"); } return 0; } #include <stdio.h> #include <string.h> #define N 100 #define PALINDROME 0 #define NONPALINDROME 1 /*Program that tells you whether what you enter is a palindrome or not*/ char pal[N]; //input line int i; //counter int k; //counter int tag; int flag = PALINDROME; /*flag=0 ->palindrome, flag =1 ->nonpalindrome*/ int main() { printf("Enter something: \n"); scanf("%s", pal); tag = strlen(pal); /*determine length of string*/ /* pointer running from the beginning and the end simultaneously looking for two characters that don't match */ /* initially assumed that string IS a palindrome */ /* the following for loop looks for inequality and flags the string as a non palindrome the moment two characters don't match */ for (i=0,k=tag-1; i=0; i++,k--) { if(pal[i] != pal[k]) { flag=NONPALINDROME; break; } } if(flag == PALINDROME) { printf("This is a palindrome\n"); } else { printf("This is NOT a palindrome\n"); } return 0; }

Related questions

Define a macro to find the factorial of a given number?

#define fact(n) ( n == 0 ? 1 ; (n*(fact(n-1) ) ) )


What is the factorial of 0?

A recursive formula for the factorial is n! = n(n - 1)!. Rearranging gives (n - 1)! = n!/n, Substituting 'n - 1' as 0 -- i.e. n = 1 -- then 0! = 1!/1, which is 1/1 = 1.


Algorithm to determine if a binary tree is strictly binary?

// Author : SAGAR T.U, PESIT #define TRUE 1 #define FALSE 0 int isStrictBinaryTree (struct tree * n) { if( n NULL ) return TRUE; return FALSE; }


How you can write python code to disply the prime factors of 60?

def factors(n): return [(x, sum([1 for y in range(1,int(ceil(log(n, x)))+1) if n%x**y == 0])) for x in range(2,int(n/2)) if all([x%q!=0 for q in range(2,int(x/2)+1)]) and n % x == 0] This will give you a list of factors with their exponents: print(factors(60)) # prints: [(2, 2), (3, 1), (5, 1)]


C program to print nos divisible by 8?

#include #include#define N 100 /* change the upper limit by changing value of N */int main(){int i;clrscr();printf("\nPROGRAM TO PRINT NUMBERS DIVISIBLE BY 8 between 1 and 100\n");for(i=1;i


Why factorial is not possible in negative?

The simplest answer is - because it is only defined for n = 0 (0! = 1) and n > 0 (n! = (n-1)! x n).


What is the answer to the equation 0 equals n2-n?

equation works for n = 0 and n = 1 as factors are n and n - 1


How do you draw a cycle in a c program?

/*PROGRAM TO IMPLEMENT GAUSS-jordan method.#include#define MX 20main(){float a[MX] [MX+1],m,p;int i,j,k,n;puts("\n how many equations?:");scanf("%d",&n);for(i=0;i


How is 0 factorial equals 1?

The simple answer is that it is defined to be 1. But there is reason behind the decision.As you know, the factorial of a number (n) is equal to:n! = n * (n-1) * (n-2) ... * 1Another way of writing this is:n! = n * (n-1)!Suppose n=1:1! = 1 * 0!or1 = 1 * 0!or1 = 0!So by defining 0! as 1, formula involving factorials will work for all integers, including 0.


Solve 2xsquared plus 5x equals 5?

n! = n * (n-1) ! n!/n = n*(n-1)!/n //divid by n both sides n!/n = (n-1)! let n = 1 1!/1 = (1-1)! 1 = 0! Hence proved that 0! = 1.


How do you convert Binary code to BCD code?

#include#includevoid main(){int a[10],i=0,c=0,n;printf("\n enter the gray code");scanf("%d",&n);while(n!=0){a[i]=n%10;n/=10;i++;c++;}for(i=c-1;i>=0;i--){if(a[i]==1){if(a[i-1]==1)a[i-1]=0;elsea[i-1]=1;}}printf("\n the binary code is");for(i=c-1;i>=0;i--)printf("%d",a[i]);getch();}


What are the solutions for the equation 8nsquared plus 4 equals 12n?

8n2+4=12n 8n2-12n+4=0 2n2-3n+1=0 (2n-1)(n-1)=0 2n-1=0 or n-1=0 2n=1 n=1/2 or n=1