Validation and Checking (IT) Flashcards

1
Q

Checking Minimum Length of a string

A

print(f”Enter String”)
string = input()
if len(string) > 5:
print(f”String okay”)
else:
print(f”String is too short”)

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

Check an empty string

A

print(f”Enter String”)
string = input()
if len(string) == 0:
print(f”String is empty”)

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

Checking if data entered is within the given range

A

number = int(input(“Enter a number”))
if number > 1 and number < 10:
print(f”Within range”)
else:
print(f”Not in range”)

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

Merging multiple strings

A

a = “Hello”
b = “World”
c = a + b
print(c)

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

Returning position of character

A

student = ‘Hermione’
student.index (i)
(Basically if I put in 2 ‘r’ is outputted)

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

Finding a character

A

student = ‘Hermione’
print (student[2]) (r)

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

Length of a string

A

len(“Hello”)

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

Letter to ASSCI character code

A

ord(a)

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

ASSCI character code to letter

A

chr(101)

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

From integers to floats

A

a = float(“12.3”)

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

Integer to string

A

a = str(12)

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

Real to string

A

a = str(12.3)

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

DIV (//)

A

a = 7 // 2 (3) (No remainder)

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

MOD %

A

a = 7 % 2 (1) (Remainder)

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

Outputting certain characters

A

Student = “Jeff Make”
print(Student [0:2])

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

Student = “Jeff Make”
print(Student [2:-2])