Sofyware Development Flashcards

(17 cards)

1
Q

How do you round a number

A

Number =round(1.67830)
Print(number)

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

How do you round to a whole number

A

Number = 4.6783
Print(int(number))

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

How to do an if statement

A

Ticket = str(input(“do you wish to but a ticket”))
If ticket == “Y”:
Print(“welcome to the ticket office”)

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

How to do an else statement

A

Ticket = str(input(“do you wish to but a ticket”))
If ticket == “Y”:
Print(“welcome to the ticket office”)
Else:
Print(“we are sorry to hear that”)
Print(“please return soon”)

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

How do you use complex conditions such as, and, or

A

Ticket = str(input(“do you wish to but a ticket”))
If ticket == “Y”:
Print(“welcome to the ticket office”)

Else:
Print(“we are sorry to hear that”)
Print(“please return soon”)
Age = int(input(“please enter your age”))
If age >= 5 and age <= 17:
Print(“please purchase a junior ticket”)
If age > 17 and age < 65:
Print(“please purchase an adult ticket”)
If age >= 65:
Print(“get a senior ticket”)

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

How do to a fixed loop

A

For counter in range(4):
Print(“this is a fixed loop”)

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

Fixed loop with user input

A

Times = int(input(“enter a number”))
For counter in range(times):
Print(“i must try harder”)

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

More about the range statement

A

Total = 0
Print(“please enter the 3 test marks”)
For counter in range(1,4):
Print(“please enter test”,counter)
Mark = int(input())
Total = total + mark
Print(“the total number of marks =“,total)

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

How to do a conditional loop

A

Choice = “”
While choice != “Y” and choice != “N”:
Choice = str(input(make your choice -Y/N”))
Print(“thank you for making your choice”)

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

Input validation with conditional loop

A

Score = int(input(“please enter your score”))
While not(score >= 10 and score <=20)):
Print(“your score must be between 10 and 20”)
Score = int(input(“please enter your score”))

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

How to store multiple values using lists

A

Names = [ “anton”, “Dominic”, “Joseph”, “Michael”, “sean”, “kiera”, “Niamh”]
Ages = [15, 12, 18, 25, 21, 23, 20]
For counter in range(len(names)):
Print( names[counter], ages[counter] )

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

Pre defined function

A

Numbers = [12,4,67,55,29,289,23,99,6]
Largest = max(numbers)
Print(“the largest value is”,largest)
Print(“the smallest value is”,min(numbers))

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

Running a total

A

Total = 0
Items = [12,3,54,35,23,56,34,3,77,9]
For count in range(len(items)):
Total = total + items[count]
Print(“the total=“,total)

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

Input validation

A

Number = int(input(“enter a value between 0 and 10”))
While number <0 or number >10:
Print(“your value was not between 0 and 10”)
Number = int(input(“enter a value again”))
Print(“number=“, number)

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

Traversing an array

A

Values = [12,3,54,35,23,56,34,3,77,9]
Print(“the following values are > 50”)
For count in range(len(values)):
If values[count]>50:
Print(values[count])

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

How to import a random number between 0 and 1

A

Import random
Print (random.random())

17
Q

How to do a running total within a loop

A

People = int(input(“how many people are there”)
Total = 0
For x in range (people):
Age = int(input( “what is your age”))
Total = total + age
Print(“the total age is”, total)