6 Hours of python

studied byStudied by 1 person
5.0(1)
Get a hint
Hint

How do you print the same text multiple times?

1 / 27

encourage image

There's no tags or description

Looks like no one added any tags here yet for you.

28 Terms

1

How do you print the same text multiple times?

By using a * and a number

eg. Print(“Gyat” * 3)

New cards
2

What are the 4 main variable types

integer - whole numbers (eg 1, 2, 3)

float - decimal points (eg 1.0, 2.5, 3.69)

string - text (eg hello world)

boolean - true or false

New cards
3

What must you be careful when using if else statements?

There is a colon (:) (and therefore indentation)

New cards
4

What is the difference between , and + when using the print function?

A comma will cause a space between the values vbeing printed whereas a + will cause them to print directly next to eachother

New cards
5

How do you limit the number of decimal points in Python?

By using the round fucntion (literally “round()”) or %.f

<p>By using the round fucntion (literally “round()”) or %.f</p>
New cards
6

What is the difference between / and // (arithmic)

/ will give a float while // gives an intiger

New cards
7

What does % do (arithmic)

Gives the remainder of the devision

New cards
8

What is the difference between * and **

  • * multiplies while ** makes it to the power

New cards
9

How do if, elif and else statements work together?

If condition 1 is true

do…

elif condition 2 is true ( and 1 is false)

do…

else (both condition 1 and 2 false)

do…

<p>If condition 1 is true</p><p>do…</p><p>elif condition 2 is true ( and 1 is false)</p><p>do…</p><p>else (both condition 1 and 2 false)</p><p>do…</p>
New cards
10

What does the “not” opetation do?

Converts boolean variables to the opposite (E.g true=flase)

New cards
11

What is the greater/less than or equal to sign in python

>= / <=

New cards
12

What does the len() function do?

Gives the number of characters

New cards
13

How do i make an input not case sensetive

lowercase_input = user_input.lower()

(The variable is equal to the previous input but it is not all lower case, the same can be done with .upper())

New cards
14

When using the print function, what foes f before quotation marks do?

print(f”text”) allows for variables to be placed inside the quotation marks as lond as they are in {curlyBrackets}

New cards
15

what does != mean?

not equal to ( while != “pink”, do …)

New cards
16
<p>What is the difference between the first codes?</p>

What is the difference between the first codes?

The second code with the indentation will print the total each time it adds a number while the first code will print the sum of all the numbers

<p>The second code with the indentation will print the total each time it adds a number while the first code will print the sum of all the numbers</p>
New cards
17
<p>Will x or y reach 1 first?</p>

Will x or y reach 1 first?

y (will reach 1 first)

New cards
18
<p>How do you make a system that will print the highest number?</p>

How do you make a system that will print the highest number?

(using a nested loop)

<p>(using a nested loop)</p>
New cards
19

What are the 2 ways to check if a number is in the list?

The ‘in’ operator - will provide a boolean value (true/false)

Or using .index - will provide the first location of the number (eg if the number comes up twice in a list it will only show the first location)

New cards
20

What is the difference between lists and tuples

Tuples cant be ammended

New cards
21
<p>What is the shorthand was of (image)</p>

What is the shorthand was of (image)

x,y,z = coordinates

New cards
22

What is def used for in python? and how would it be used

To define a function, will allow a function to be “used” whenever the variable name is called upon

New cards
23

What do the peramiters in def() do?

They act as variables, which have to be given a value

New cards
24

What is the except function used for?

To help debug code/ prevent if from crashing

New cards
25

What are classes used for in python?

To define new types

New cards
26

What is PascalCase

A naming convention where every first letter of the word is capitalised

New cards
27

How do you make a class inherit all the code from another class?

class newVariable(inheritingVariable)

New cards
28

What are modules used for?

To organise code into multiple sections

New cards

Explore top notes

note Note
studied byStudied by 74 people
Updated ... ago
4.0 Stars(1)
note Note
studied byStudied by 7 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 8 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 31 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 19 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 65 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 38 people
Updated ... ago
5.0 Stars(1)
note Note
studied byStudied by 61 people
Updated ... ago
5.0 Stars(1)

Explore top flashcards

flashcards Flashcard46 terms
studied byStudied by 11 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard51 terms
studied byStudied by 22 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard46 terms
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard56 terms
studied byStudied by 1 person
Updated ... ago
5.0 Stars(1)
flashcards Flashcard59 terms
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard42 terms
studied byStudied by 20 people
Updated ... ago
5.0 Stars(2)
flashcards Flashcard31 terms
studied byStudied by 2 people
Updated ... ago
5.0 Stars(1)
flashcards Flashcard28 terms
studied byStudied by 30 people
Updated ... ago
5.0 Stars(2)