From 05d17c0d8ed843f39d15637c72f0b662bddad57b Mon Sep 17 00:00:00 2001 From: harbindsingh <60515499+harbindsingh@users.noreply.github.com> Date: Sun, 12 Apr 2020 12:57:23 -0700 Subject: [PATCH] python ass 1& 2 --- Harbind singh | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Harbind singh diff --git a/Harbind singh b/Harbind singh new file mode 100644 index 0000000..21be301 --- /dev/null +++ b/Harbind singh @@ -0,0 +1,43 @@ + Assignment - 2 +1) what will be the output of 3+4**6-9*10/2 +ans- exponent>multiplication=division>addition=subtraction +=3+4**6-9*5 +=3+4096-45 +=4099-45=4054 +so by this the answer will be 4054. + +2)lets say i have a string "hello this side regex". count the total no. of vowels present in the string. +ans- +string=input("Enter string:") +vowels=0 +for i in string: + if(i=='a' or i=='e' or i=='i' or i=='o' or i=='u' or i=='A' or i=='E' or i=='I' or i=='O' or i=='U'): + vowels=vowels+1 +print("Number of vowels are:",vowel) + +3)find out the area of the triangle . you have to take the value from the user about the base and the height. +ans- +h=int(input("enter the height of the triangle=)) +b=int(input("enter the base of the triangle=)) +print("area of the traingle is=",(1/2)*b*h) + +import calender +year=input("enter the year") +print (calender. calender(year)) + + +Assignment 1 solution +1)what is jpython and cpython? +ans.-cypthon is both the compiler as well as the interpreter. it will convert the written python code into the byte code before interpreting it. +it is the default and most widely used implementation of the language. +jpython-it is the implementation of python working on the java platform. + +2) basic difference between pyhton2 and pyhton3. +ans.- in python2 it takes the user input and default storing os string is in the ASCII code.whereas in python3 we take only input and default storing of string is in unicode. + +3)difference between ASCII Code and unicode. +ans- +Unicode and ASCII both are standards for encoding texts +ASCII CODE-ASCII is a character-encoding scheme and it was the first character encoding standard.ASCII uses 7 bits to represent a character. It has 128 code points, 0 through 127. It is a code for representing English characters as numbers, with each letter assigned a number from 0 to 127. + +UNICODE-Unicode is a universal international standard character encoding that is capable of representing most of the world's written languages. It assigns each character a unique number, or code point.