DATA TYPES IN PYTHON A. Tick the correct option 1. Which of the following is not a valid variable name? ANS1. a. Print 2. Which of the following is not a string? ANS2. a. 89 3. How many types of number data type are there in Python? ANS C. 4 4. Which of the following is a data type? ANS A. TUPLE 5. Which of the following will you use to access a value stored in a dictionary? ANS C. [ ] B. Fill in the blanks 1. A multiline string spreads across multiple lines. 2. Data type is used to represent data in the memory of the computer. 3. A tuple can consist of different types of values. 4. A conditional statement can also be called a decision making statement. 5. The IF conditional statement has code for the condition being true only. C Write the output of the following code snippets. 1. >>> number_of_pages=200 >>>print( number_of_pag...
Q1. Write the html code and find the output Q2. Write the HTML CODE using Ordered List:- 1. English 2. Mathematics 3. Science Q3 . C Write the output of the following code snippets. 1. >>> number_of_pages=200 >>>print( number_of_pages) 2. Given a list lst=["Monday","Tuesday","Wednesday","Thursday", "Friday","Saturday"] a. What statements will you write to print the elements stored at even indices? b. Write a statement to replace incorrect spelling with the correct spelling of Friday. c. Write a statement to print the number of elements in the list. d. Write a statement to print the first element of this list. 3. fruits=["apple,"mango","orange"] numbers=(5,4,3) alphabets={'a':'apple','b':'ball','c':'cat'} print(fruits) print(numbers) print(alphabets['b']) 4. >>>list1=[1,2,3,4] >>>list2=['i...
You can use the basic mathematical operators: 1 >>> 3 + 3 6 >>> 3 - 3 0 >>> 3 / 3 1.0 >>> 3 / 2 1.5 >>> 3 * 3 9 >>> 3 ** 3 27 >>> num = 3 >>> num = num - 1 >>> print(num) 2 >>> num = num + 10 >>> print(num) 12 >>> num += 10 print(num) 22 >>> num -= 12 >>> print(num) 10 >>> num *= 10 >>> num 100 There’s also a special operator called modulus, % , that returns the remainder after integer division. >>> 10 % 3 1 One common use of modulus is determining if a number is divisible by another number. For example, we know that a number is even if it’s divided by 2 and the remainder is 0. >>> 10 % 2 0 >>> 12 % 2 0 Finally, make sure to use parentheses to enforce ...
Comments
Post a Comment