Python Scriping - 1 Python Fundamentals Flashcards

1
Q

What is type error ?

A

Type Error Occur when input entered in a different format that you didnt want.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which is the First High Level Language ?

A

Fortran in 1960s

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is slicing ?

A

Slicing is used to extract string from string object , common format is myStr[start:stop:step]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Default return value of input() method ?

A

input() method returns string , so always typecast

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

When C language is introduced ?

A

1980 , considered as middle Level Languge

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Format strings used for ?

A

Display values of variables with text , in curly braces we can execute any python code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Which feature is not be included in code editor ?

A

Avoid Rich Formats.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

When was First Intel CPU was Introduced ?

A

1971

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is Interprertor Language means ?

A

Interpreter run source code line by line , python code is first converted to bytecode , then bytecode is interpreted to machine code for cpu.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Common methods of string ?

A

find(),replace(), endswith()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How capable is the Intel First CPU ?

A

Capable to do 60,000 OPS (Operations Per Second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is type hinting ?

A

Adding type information to function ,introduced n python 3.5 ,specified in PEP-484

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Who Developed Boolean Logic ?

A

George Boole

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What means High Level in Programming Languages ?

A

High leve means Abstraction , Coding is in English language & easily understandable by humans , Compiler Based

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is OPS ?

A

Operations Per Second

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How many Trasistors are in Intel’s First CPU ?

A

2300 Transistors

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
17
Q

Can string typcasted to int .

A

yes , only numbers in string , string alphabests are not typcasted to int.

18
Q

First Intel CPU ?

A

Intel 4004
It is the first commercial CPU

19
Q

What means Dynamically typed ?

A

You dont want to define type of the variable , it automatically understood by value in it.

20
Q

How to check Truth Value of python object ?

A

By using bool() method

21
Q

What are membership Operators ?

A

in , not in

22
Q

Which Method gives Ascii Value ?

A

ord() method

23
Q

When Python is Introduced ?

A

1990s

24
Q

Basic Boolean Logic ?

A

And,Or,Not

25
Q

What are the Characterstics of Python ?

A

Python is an High Level Language.
Python is an Dynamically Typed Language
Python is an Interpreted Language

26
Q

What is U in vscode Explorer

A

U for untracked , related to github.

27
Q

Strings are mutable or imutable ?

A

Strings are immutable in Python, which means a string cannot be modified.
You cannot modify the string once created. If you change a string, Python creates a new string with the updated value and assigns it to the variable.
str1 = “first”
id(str1)
str1 = str1+ “ Two”
id(str1)
Output

28
Q

How to get the character from ASCII number ?

A

Using chr(number) method

29
Q

Which method should I use to convert String “welcome to the beautiful world of python” to “Welcome To The Beautiful World Of Python”

A

title() method

30
Q

How to convert the string “my name is James bond” to “My name is James bond”

A

use capitalize() method

31
Q

What is the output of the following code?

var = “James” * 2 * 3
print(var)

A

6 times james
JamesJamesJamesJamesJamesJames

32
Q

What is the Output of the following code?

for x in range(0.5, 5.5, 0.5):
print(x)

A

Program executed with errors

33
Q

Can we use the “else” block for for loop?

for example:

for i in range(1, 5):
print(i)
else:
print(“this is else block statement” )

A

We can use the else block after the end of for loop and while loop. The else block is used to check the successful execution of a loop. If the loop executed successfully without any issues, the else block executes.

34
Q

What is the output of the following code?

def calculate (num1, num2=4):
res = num1 * num2
print(res)

calculate(5, 6)

A

30
In Python, we can set default values for arguments. If the function is called without the argument, the default value is used.

35
Q

What is the output of the following code?

listOne = [20, 40, 60, 80]
listTwo = [20, 40, 60, 80]

print(listOne == listTwo)
print(listOne is listTwo)

A

True,False
The == (Equal To) operator used to compare the values of two objects and The is operator compares the identity of two objects.

36
Q

How to Print memory Location ?

A

use id() method.

37
Q

What is the Output of this code ?
str1=”Sandy”
str2=”Mohan”
str2=str1
print(id(str1),id(str2))

A

It print the same memory location

38
Q

In which version of python type hinting is introduced

A

Type hinting is introduced in Python 3.5

39
Q

In which type document type hinting is specified ?

A

Type hinting is specified in PEP 484 document

40
Q

Which function is required to get index in for loop

A

enumerate method